Skip to content

Commit

Permalink
Revert to multihash only, but with blake3 in place of blake2b-256 as …
Browse files Browse the repository at this point in the history
…an option
  • Loading branch information
Wes Biggs committed Jul 11, 2024
1 parent a6f5ac2 commit 7da7a6d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 41 deletions.
11 changes: 5 additions & 6 deletions pages/ActivityContent/Associated/Attachments.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
"href": "https://upload.wikimedia.org/wikipedia/commons/d/d9/Wilhelm_Scream.ogg",
"mediaType": "audio/ogg",
"hash": [
"bafkreibwacl4s4k7kwv4yjvlopys62nxgddgb67qdh6ghsvgqw72tnsylm",
"QmQrGdv6Ky5sJhaVdw27y4aod5pdfihDkBTxiBkRaSGJJ7"
"bdyqbcji3okmzxobvaqgduz5prixmumyndzopyufultmslndi4pdebii"
]
}
],
Expand Down Expand Up @@ -74,7 +73,7 @@
| `type` | [Activity Vocabulary 2.0](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type) | YES | Identifies the type of the object | MUST be set to `Link` |
| `href` | [Activity Vocabulary 2.0](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-href) | YES | The URL for the given image | MUST be a [Supported URL Schema](../Overview.md#supported-url-schema) |
| `mediaType` | [Activity Vocabulary 2.0](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype) | YES | MIME type of `href` content | |
| `hash` | [DSNP 1.0](Hash.md) | YES | Array of hashes for linked content validation | MUST include at least one [supported hash](Hash.md#supported-algorithms) |
| `hash` | [DSNP 1.0](Hash.md) | YES | Array of hashes for linked content validation | MUST include at least one [supported hash](../../DSNP/Identifiers.md#supported-hashing-algorithms) |
| `height` | [Activity Vocabulary 2.0](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height) | no | A hint as to the rendering height in device-independent pixels | |
| `width` | [Activity Vocabulary 2.0](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-width) | no | A hint as to the rendering width in device-independent pixels | |

Expand Down Expand Up @@ -107,7 +106,8 @@
"height": 228,
"mediaType": "image/jpg",
"hash": [
"bafkreieuibebwm2ih2yv6rhbknv6m5kdu5nlyi2dz5r6vl7yee2sqwuvrq"
"bciqjiqcidmzuqpvrl5cocu3l4z2uhj22xqruht3d5kx7qijvfbnjlda",
"bdyqbjzt5drgji5w7xhsddsynusgx2vdmakcsrr4sfin5fyfkwlpup6q"
]
}
]
Expand Down Expand Up @@ -170,8 +170,7 @@
"height": 2250,
"mediaType": "video/webm",
"hash": [
"bafybeiberftlan32pi5ef45kb363kc3ouleui636fmbhvjdi4fgwqif5ou",
"2Drjgb4a8eC4XheBKCBcbAcaVdEWcKjMbCSZ2L2c9CQs4x98jf"
"bdyqed7dnok3batd7tr64trqmovfxam5tqsgxkiv2op5765pq43swtui"
]
}
]
Expand Down
9 changes: 4 additions & 5 deletions pages/ActivityContent/Associated/Hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

Activity objects linking to external content such as audio, image or video files must include a `"hash"` field for users to validate linked content.
The value of this `"hash"` field must be an array of strings, each representing a hash output using a specific algorithm.
Each item in the array MUST be a valid [multihash](https://github.com/multiformats/multihash) value, serialized as a [multibase](https://github.com/multiformats/multibase) string using either the `base32` or `base58btc` encodings.
Each item in the array MUST be a valid [multihash](https://github.com/multiformats/multihash) value, serialized as a [multibase](https://github.com/multiformats/multibase) string using the `base32` encoding.
At least one of the deserialized multihash values must be a valid [DSNP Content Hash](../../DSNP/Identifiers.md#dsnp-content-hash).

### Example

This example gives CIDv1 (serialized as `base32`), SHA-256 (serialized as `base58btc`), and BLAKE2b (serialized as `base58btc`) hashes for the [PDF version of the DSNP whitepaper](https://github.com/LibertyDSNP/papers/raw/main/whitepaper/dsnp_whitepaper.pdf).
This example gives SHA-256 and BLAKE3 hashes for the [PDF version of the DSNP whitepaper](https://github.com/LibertyDSNP/papers/raw/main/whitepaper/dsnp_whitepaper.pdf).

```json
{
"hash": [
"bafybeida7z24mig7j3oagjru7s2gw6xbfkh7fryvah6ho2ar77xb7aleom",
"QmQNHNfHnbgJJ6nK4UPx2VtTUCafAKCbqZJ6ZRYUGjoeFj",
"2DrjgbGgSsXRhTiBWckoVwBFC6H4qiBWWNumSsRwdUt82YnTdN"
"bciqgb7tvyyqn6tw4amtdj7funn5ockup6ldrkap4o5ubd77od6awi4y",
"bdyqdua4t4pxgy37mdmjyqv3dejp5betyqsznimpneyujsur23yubzna"
]
}
```
4 changes: 2 additions & 2 deletions pages/ActivityContent/Types/Profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Profiles are used to provide additional user information display.
"width": "256",
"height": "171",
"hash": [
"bafkreiddyiraqlkgoybzrydxqs5vikejphecjoizfk5rlghd7tohxahbfa"
"bdyqphnphmjdoumkxqbsuspribxvlsx2hx6525u3fh2dkr5bxnqritzi"
]
},
{
Expand All @@ -42,7 +42,7 @@ Profiles are used to provide additional user information display.
"width": "64",
"height": "43",
"hash": [
"bafkreid7m3fxtdxokdb4vmvpjuu7ngo72dpjsgpttfh7bfh2gdhq6ydbjm"
"bdyqktr7p5hc27bx4ernmngs6tj7uyukfb4atrtq44mdmx4yntuh2s5y"
]
}
],
Expand Down
25 changes: 3 additions & 22 deletions pages/DSNP/Identifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ Graph connections are formed through the DSNP User Id.

### Supported Hashing Algorithms

| Algorithm | Multihash Name | Leading bytes (as [varint](https://github.com/multiformats/unsigned-varint)) | Reference | DSNP Version Added |
| Algorithm | Multihash Name | Leading bytes | Reference | DSNP Version Added |
| --- | --- | --- | --- | --- |
| SHA-256 | `sha2-256` | `0x1220` | [RFC 6234](https://tools.ietf.org/html/rfc6234) | 1.2.0 |
| BLAKE2b | `blake2b-256` | `0xa0e40220` | [RFC 7693](https://tools.ietf.org/html/rfc7693) | 1.2.0 |
| CIDv1 | `cidv1` | `0x01` | See [DSNP CID](#dsnp-cid) | 1.3.0 |
| SHA-256 | `sha2-256` | `0x1220` | [RFC 6234](https://tools.ietf.org/html/rfc6234) | 1.2 |
| BLAKE3 | `blake3` | `0x1e20` | [blake3.io](https://blake3.io) | 1.3 |

## DSNP Protocol Scheme

Expand Down Expand Up @@ -58,21 +57,3 @@ dsnp://78187493520/QmQNHNfHnbgJJ6nK4UPx2VtTUCafAKCbqZJ6ZRYUGjoeFj
| Scheme | `dsnp://` |
| User Id | `78187493520` |
| Content Hash | `QmQNHNfHnbgJJ6nK4UPx2VtTUCafAKCbqZJ6ZRYUGjoeFj` |

## DSNP CID

A DSNP CID is a valid binary [Content IDentifier](https://github.com/multiformats/cid) generated using the following parameters.

### Supported CID Parameters

The CID specification allows CIDs to be generated with a wide and ever-growing range of possible hashing algorithms, string encodings, and block sizes.
In order for DSNP applications to interoperate, the required functionality is limited as follows:

- CID version: MUST be version 1, in order to distinguish CIDs from simple multihash values in situations where either may be used
- Hash algorithm: MUST be `sha2-256` or `blake2b-256`
- Codec: MUST be `dag-pb` for data 256*1024 bytes or longer; `raw` for data less than 256*1024 bytes
- Chunking: Non-leaf nodes MUST be 256*1024 bytes

The rationale for these options is to allow consuming applications to attempt to generate a matching CID from a byte stream for validation purposes without the need to reprocess the stream.

These options are intentionally aligned to interoperate with the default output of the [Kubo](https://github.com/ipfs/kubo) IPFS command line utility when invoked as `ipfs add --cid-version=1 ...` (note that the output will additionally be serialized using a multibase prefix).
12 changes: 6 additions & 6 deletions pages/DSNP/Types/ProfileResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ ProfileResource object serialization MUST conform to the following [Avro](https:
"doc": "Type of resource"
},
{
"name": "cid",
"name": "contentHash",
"type": "bytes",
"doc": "Content IDentifier of resource"
"doc": "Multihash digest of resource content"
},
{
"name": "length",
"type": "int",
"doc": "Length of document in bytes"
"doc": "Length of resource in bytes"
}
]
}
Expand All @@ -46,11 +46,11 @@ ProfileResource object serialization MUST conform to the following [Avro](https:

All other document type values are reserved for future expansion.

### cid
### contentHash

- MUST be a valid (binary) [DSNP CID](../Identifiers.md#dsnp-cid)
- MUST be a valid [DSNP Content Hash](../Identifiers.md#dsnp-content-hash)

### length

- MUST be a positive integer
- MUST match the length in bytes of the document
- MUST match the length in bytes of the resource

0 comments on commit 7da7a6d

Please sign in to comment.