mirror of
https://github.com/vacp2p/specs.git
synced 2026-01-09 15:28:03 -05:00
Apply review changes
License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
@@ -41,6 +41,12 @@ from Multihash to CIDv1 in Base32 and to support encoding/decoding text Peer Ids
|
|||||||
|
|
||||||
[rfc4648]: https://tools.ietf.org/html/rfc4648
|
[rfc4648]: https://tools.ietf.org/html/rfc4648
|
||||||
|
|
||||||
|
### Upgrade path
|
||||||
|
|
||||||
|
1. Release support for reading Peer Id represented with CIDv1
|
||||||
|
2. Wait three months or until the next release (whichever comes first)
|
||||||
|
3. Switch the default Peer Id output format to CIDv1 in Base32
|
||||||
|
|
||||||
### Backward compatibility
|
### Backward compatibility
|
||||||
|
|
||||||
The old text representation (Multihash encoded as [`base58btc`][base58btc])
|
The old text representation (Multihash encoded as [`base58btc`][base58btc])
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ behavior.
|
|||||||
|
|
||||||
### String representation
|
### String representation
|
||||||
|
|
||||||
Peer Ids are [multihashes][multihash] represented with [CIDs](https://github.com/ipld/cid) when encoded into strings.
|
Peer Ids are [multihashes][multihash] canonically represented with [CIDs](https://github.com/ipld/cid) when encoded into strings.
|
||||||
|
|
||||||
CID is a multihash with a prefix that specifies things like base encoding, cid version and the type of data behind it:
|
CID is a multihash with a prefix that specifies things like base encoding, cid version and the type of data behind it:
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ CID is a multihash with a prefix that specifies things like base encoding, cid v
|
|||||||
<cidv1> ::= <multibase><cid-version><multicodec><multihash>
|
<cidv1> ::= <multibase><cid-version><multicodec><multihash>
|
||||||
```
|
```
|
||||||
|
|
||||||
Encoding and decoding of string representation must follow [CID spec][cid-decoding].
|
Encoding and decoding of string representation must follow [CID spec][cid-decoding].
|
||||||
|
|
||||||
#### libp2p-key CID
|
#### libp2p-key CID
|
||||||
|
|
||||||
@@ -153,6 +153,14 @@ with `base32` [multibase][multibase] ([RFC4648](https://tools.ietf.org/html/rfc4
|
|||||||
- `libp2p-key` multicodec is mandatory when serializing to text (ensures Peer Id is self-describing)
|
- `libp2p-key` multicodec is mandatory when serializing to text (ensures Peer Id is self-describing)
|
||||||
- `base32` is the default multibase encoding: projects are free to use a different one if it is more suited to their needs
|
- `base32` is the default multibase encoding: projects are free to use a different one if it is more suited to their needs
|
||||||
|
|
||||||
|
##### Decoding string representation
|
||||||
|
|
||||||
|
To decode a CID, follow the following algorithm:
|
||||||
|
|
||||||
|
- If it is 46 characters long and starts with `Qm...`, it's a CIDv0. Decode it as base58btc multihash.
|
||||||
|
- Otherwise, decode it according to the multibase and [CID spec][cid-decoding].
|
||||||
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- SHA256 Peer Id encoded as canonical [CIDv1][cid-versions]:
|
- SHA256 Peer Id encoded as canonical [CIDv1][cid-versions]:
|
||||||
|
|||||||
Reference in New Issue
Block a user