From 9332b5580f1d70cca45a90541e3837fd653c7d18 Mon Sep 17 00:00:00 2001 From: Wes Biggs Date: Mon, 1 Jul 2024 14:38:47 -0500 Subject: [PATCH] DIP-273 Content Addressing * 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 --- .spellcheckerdict.txt | 4 +++- pages/ActivityContent/Associated/Attachments.md | 6 ++++-- pages/ActivityContent/Associated/Hash.md | 15 ++++----------- pages/ActivityContent/Overview.md | 7 ++++--- pages/ActivityContent/Types/Profile.md | 12 ++++++------ pages/DSNP/Identifiers.md | 9 +++++---- pages/DSNP/Overview.md | 9 ++++++--- pages/DSNP/Types/ProfileResource.md | 4 ++-- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/.spellcheckerdict.txt b/.spellcheckerdict.txt index ec34aeab..98f5c699 100644 --- a/.spellcheckerdict.txt +++ b/.spellcheckerdict.txt @@ -9,6 +9,7 @@ CC0 Changelog changeType (cid|CID)s? +CIDv1 [Cc]odec('s)? contentHash cryptographic @@ -19,7 +20,7 @@ CtxSharedSecretBob Curve25519 decrypt(ed)? Delegator -Deserialize +[Dd]eserialize(d)? Diffie-Hellman discoverability [Dd]iscoverable @@ -71,6 +72,7 @@ PNG Polkadot Poly1305 pre-configured +Prerelease PRId([ABs])? ProfileResource [Pp]ublicKey diff --git a/pages/ActivityContent/Associated/Attachments.md b/pages/ActivityContent/Associated/Attachments.md index 5f2d76aa..ccd8d72e 100644 --- a/pages/ActivityContent/Associated/Attachments.md +++ b/pages/ActivityContent/Associated/Attachments.md @@ -44,7 +44,8 @@ "href": "https://upload.wikimedia.org/wikipedia/commons/d/d9/Wilhelm_Scream.ogg", "mediaType": "audio/ogg", "hash": [ - "QmQrGdv6Ky5sJhaVdw27y4aod5pdfihDkBTxiBkRaSGJJ7" + "bafkreibwacl4s4k7kwv4yjvlopys62nxgddgb67qdh6ghsvgqw72tnsylm", + "QmQrGdv6Ky5sJhaVdw27y4aod5pdfihDkBTxiBkRaSGJJ7" ] } ], @@ -106,7 +107,7 @@ "height": 228, "mediaType": "image/jpg", "hash": [ - "2Drjgb5yoVWTpubcWmDBLJqkxrFkZamekzJoYLSWwM2ezpFkab" + "bafkreieuibebwm2ih2yv6rhbknv6m5kdu5nlyi2dz5r6vl7yee2sqwuvrq" ] } ] @@ -169,6 +170,7 @@ "height": 2250, "mediaType": "video/webm", "hash": [ + "bafybeiberftlan32pi5ef45kb363kc3ouleui636fmbhvjdi4fgwqif5ou", "2Drjgb4a8eC4XheBKCBcbAcaVdEWcKjMbCSZ2L2c9CQs4x98jf" ] } diff --git a/pages/ActivityContent/Associated/Hash.md b/pages/ActivityContent/Associated/Hash.md index 69c6886f..39f21b5c 100644 --- a/pages/ActivityContent/Associated/Hash.md +++ b/pages/ActivityContent/Associated/Hash.md @@ -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" ] diff --git a/pages/ActivityContent/Overview.md b/pages/ActivityContent/Overview.md index 0b9d73f2..564f3472 100644 --- a/pages/ActivityContent/Overview.md +++ b/pages/ActivityContent/Overview.md @@ -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. @@ -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 | - ## Prerelease Changelog ----> + +- DIP-273 Content Addressing ## Releases diff --git a/pages/ActivityContent/Types/Profile.md b/pages/ActivityContent/Types/Profile.md index ad2c3dc8..3cd5d55f 100644 --- a/pages/ActivityContent/Types/Profile.md +++ b/pages/ActivityContent/Types/Profile.md @@ -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" ] } ], diff --git a/pages/DSNP/Identifiers.md b/pages/DSNP/Identifiers.md index 2020e237..9f225b3a 100644 --- a/pages/DSNP/Identifiers.md +++ b/pages/DSNP/Identifiers.md @@ -12,7 +12,7 @@ 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 @@ -20,6 +20,7 @@ Graph connections are formed through the DSNP User Id. | --- | --- | --- | --- | --- | | 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 @@ -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 @@ -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). diff --git a/pages/DSNP/Overview.md b/pages/DSNP/Overview.md index 8b3ee813..9c72a340 100644 --- a/pages/DSNP/Overview.md +++ b/pages/DSNP/Overview.md @@ -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. @@ -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. - ## Prerelease Changelog ----> + +- DIP-263 User Data for Public Keys +- DIP-267 User Data for Profile Resources +- DIP-273 Content Addressing ## Releases diff --git a/pages/DSNP/Types/ProfileResource.md b/pages/DSNP/Types/ProfileResource.md index b8419653..3004ccca 100644 --- a/pages/DSNP/Types/ProfileResource.md +++ b/pages/DSNP/Types/ProfileResource.md @@ -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" }, { @@ -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