Skip to content

Commit

Permalink
Apply review changes
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
  • Loading branch information
lidel committed Sep 2, 2019
1 parent 8ab79d2 commit 4e2c796
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions RFC/0001-text-peerid-cid.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 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

The old text representation (Multihash encoded as [`base58btc`][base58btc])
Expand Down
12 changes: 10 additions & 2 deletions peer-ids/peer-ids.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ behavior.

### 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:

```
<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

Expand All @@ -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)
- `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:

- SHA256 Peer Id encoded as canonical [CIDv1][cid-versions]:
Expand Down

0 comments on commit 4e2c796

Please sign in to comment.