Skip to content

Commit

Permalink
DIP-273 Content Addressing
Browse files Browse the repository at this point in the history
* Update the definition of DSNP Content Hash to include DSNP CIDs
* Change ProfileResource to use bytes, not string, for cid field, in line with Announcement usage
* Update Activity Content Hash extension to include CID option
* Update various example hashes to use CIDv1
* Update to pre-1.3.0 versioning and sync prerelease changelogs
  • Loading branch information
Wes Biggs committed Jul 1, 2024
1 parent 1e3982a commit 9332b55
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .spellcheckerdict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CC0
Changelog
changeType
(cid|CID)s?
CIDv1
[Cc]odec('s)?
contentHash
cryptographic
Expand All @@ -19,7 +20,7 @@ CtxSharedSecretBob
Curve25519
decrypt(ed)?
Delegator
Deserialize
[Dd]eserialize(d)?
Diffie-Hellman
discoverability
[Dd]iscoverable
Expand Down Expand Up @@ -71,6 +72,7 @@ PNG
Polkadot
Poly1305
pre-configured
Prerelease
PRId([ABs])?
ProfileResource
[Pp]ublicKey
Expand Down
6 changes: 4 additions & 2 deletions pages/ActivityContent/Associated/Attachments.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"href": "https://upload.wikimedia.org/wikipedia/commons/d/d9/Wilhelm_Scream.ogg",
"mediaType": "audio/ogg",
"hash": [
"QmQrGdv6Ky5sJhaVdw27y4aod5pdfihDkBTxiBkRaSGJJ7"
"bafkreibwacl4s4k7kwv4yjvlopys62nxgddgb67qdh6ghsvgqw72tnsylm",
"QmQrGdv6Ky5sJhaVdw27y4aod5pdfihDkBTxiBkRaSGJJ7"
]
}
],
Expand Down Expand Up @@ -106,7 +107,7 @@
"height": 228,
"mediaType": "image/jpg",
"hash": [
"2Drjgb5yoVWTpubcWmDBLJqkxrFkZamekzJoYLSWwM2ezpFkab"
"bafkreieuibebwm2ih2yv6rhbknv6m5kdu5nlyi2dz5r6vl7yee2sqwuvrq"
]
}
]
Expand Down Expand Up @@ -169,6 +170,7 @@
"height": 2250,
"mediaType": "video/webm",
"hash": [
"bafybeiberftlan32pi5ef45kb363kc3ouleui636fmbhvjdi4fgwqif5ou",
"2Drjgb4a8eC4XheBKCBcbAcaVdEWcKjMbCSZ2L2c9CQs4x98jf"
]
}
Expand Down
15 changes: 4 additions & 11 deletions pages/ActivityContent/Associated/Hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@

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.
AT LEAST ONE hash in the array MUST be one of the [supported algorithms](#supported-algorithms), although others may also be used.

Hashes MUST be encoded using the [multihash](https://github.com/multiformats/multihash) specification, and serialized as a [multibase](https://github.com/multiformats/multibase) string.

### Supported Algorithms

| Algorithm | Multihash Name | Leading bytes (as [varint](https://github.com/multiformats/unsigned-varint)) | 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 |
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.
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 SHA-256 and BLAKE2b hashes for the [PDF version of the DSNP whitepaper](https://github.com/LibertyDSNP/papers/raw/main/whitepaper/dsnp_whitepaper.pdf).
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).

```json
{
"hash": [
"bafybeida7z24mig7j3oagjru7s2gw6xbfkh7fryvah6ho2ar77xb7aleom",
"QmQNHNfHnbgJJ6nK4UPx2VtTUCafAKCbqZJ6ZRYUGjoeFj",
"2DrjgbGgSsXRhTiBWckoVwBFC6H4qiBWWNumSsRwdUt82YnTdN"
]
Expand Down
7 changes: 4 additions & 3 deletions pages/ActivityContent/Overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Activity Content Specification
__Version 1.2.0__
__Version pre-1.3.0__

Content references shared via the DSNP consist of URLs pointing to documents containing Activity Streams JSON objects.
For the purposes of the DSNP, restrictions are placed on the [Activity Streams 2.0](https://www.w3.org/TR/activitystreams-core/) specification.
Expand Down Expand Up @@ -45,9 +45,10 @@ URLs in DSNP-compatible Activity Content MUST use one of the following URL schem
| [LibertyDSNP/activity-content-java](https://github.com/LibertyDSNP/activity-content-java) | Java/Kotlin |
| [LibertyDSNP/activity-content-swift](https://github.com/LibertyDSNP/activity-content-swift) | Swift |

<!--- Uncomment for pre-release changes and prefix the version with `pre-[next version]`
<!--- Uncomment for pre-release changes and prefix the version with `pre-[next version]` --->
## Prerelease Changelog
--->

- DIP-273 Content Addressing

## Releases

Expand Down
12 changes: 6 additions & 6 deletions pages/ActivityContent/Types/Profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ Profiles are used to provide additional user information display.
"icon": [
{
"type": "Link",
"href": "https://placekitten.com/256/256",
"href": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/1-month-old_kittens_32.jpg/256px-1-month-old_kittens_32.jpg",
"mediaType": "image/jpeg",
"width": "256",
"height": "256",
"height": "171",
"hash": [
"QmVmUqGYtHcVgpTFR64bHNcLGGFEeWxmUP6pV2C2RbWpKT"
"bafkreiddyiraqlkgoybzrydxqs5vikejphecjoizfk5rlghd7tohxahbfa"
]
},
{
"type": "Link",
"href": "https://placekitten.com/64/64",
"href": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/1-month-old_kittens_32.jpg/64px-1-month-old_kittens_32.jpg",
"mediaType": "image/jpeg",
"width": "64",
"height": "64",
"height": "43",
"hash": [
"QmcAh1rov5GcddekCffGeRnaSyiji6ATmfGWpxXYJHgJZx"
"bafkreid7m3fxtdxokdb4vmvpjuu7ngo72dpjsgpttfh7bfh2gdhq6ydbjm"
]
}
],
Expand Down
9 changes: 5 additions & 4 deletions pages/DSNP/Identifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ Graph connections are formed through the DSNP User Id.
## DSNP Content Hash

- Variable length byte array (fixed length for a given hashing algorithm)
- MUST be a valid [multihash](https://github.com/multiformats/multihash) encoding of the hash output for the bytes of the content, generated with a [Supported Hashing Algorithm](Announcements.md#supported-hashing-algorithms)
- MUST be a valid [multihash](https://github.com/multiformats/multihash) encoding of the hash or content address output for the bytes of the content, generated with a [Supported Hashing Algorithm](Announcements.md#supported-hashing-algorithms)

### Supported Hashing Algorithms

| Algorithm | Multihash Name | Leading bytes (as [varint](https://github.com/multiformats/unsigned-varint)) | 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 |

## DSNP Protocol Scheme

Expand Down Expand Up @@ -60,7 +61,7 @@ dsnp://78187493520/QmQNHNfHnbgJJ6nK4UPx2VtTUCafAKCbqZJ6ZRYUGjoeFj

## DSNP CID

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

### Supported CID Parameters

Expand All @@ -69,9 +70,9 @@ In order for DSNP applications to interoperate, the required functionality is li

- 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`
- Encoding: MUST be `base58btc` or `base32`
- 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 ...`.

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).
9 changes: 6 additions & 3 deletions pages/DSNP/Overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DSNP Specification
__Version 1.2.0__
__Version pre-1.3.0__

DSNP (Decentralized Social Networking Protocol) is a social networking protocol designed to run on a blockchain.
It specifies a set of social primitives along with requirements for interoperability.
Expand Down Expand Up @@ -29,9 +29,12 @@ Compliant DSNP system specifications MUST document how each of the required DSNP

A compliant specification MUST specify a mapping from its system-specific state change data (for example, the events emitted by a blockchain) to the DSNP State Change Records that data represents.

<!--- Uncomment for pre-release changes and prefix the version with `pre-[next version]`
<!--- Uncomment for pre-release changes and prefix the version with `pre-[next version]` --->
## Prerelease Changelog
--->

- DIP-263 User Data for Public Keys
- DIP-267 User Data for Profile Resources
- DIP-273 Content Addressing

## Releases

Expand Down
4 changes: 2 additions & 2 deletions pages/DSNP/Types/ProfileResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ProfileResource object serialization MUST conform to the following [Avro](https:
},
{
"name": "cid",
"type": "string",
"type": "bytes",
"doc": "Content IDentifier of resource"
},
{
Expand Down Expand Up @@ -48,7 +48,7 @@ All other document type values are reserved for future expansion.

### cid

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

### length

Expand Down

0 comments on commit 9332b55

Please sign in to comment.