You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an RFC to modify peerid spec to alter the default string
representation from Multihash to CIDv1 in Base32 and to support
encoding/decoding text peerids as CIDs.
It is also the first RFC ever, following suggestions from
#198
and creating a template for future RFCs as a side-effect.
License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
See the [lifecycle document](../00-framework-01-spec-lifecycle.md) for context
19
19
about maturity level and spec status.
@@ -53,7 +53,7 @@ Key encodings and message signing semantics are
53
53
54
54
## Keys
55
55
56
-
Our key pairs are wrapped in a [simple protobuf](https://github.com/libp2p/go-libp2p-crypto/blob/master/pb/crypto.proto),
56
+
Our key pairs are wrapped in a [simple protobuf](https://github.com/libp2p/go-libp2p-crypto/blob/master/pb/crypto.proto),
57
57
defined using the [Protobuf version 2 syntax](https://developers.google.com/protocol-buffers/docs/proto):
58
58
59
59
```protobuf
@@ -107,7 +107,7 @@ Here is the process by which we generate peer ids based on the public component
107
107
3. Serialize the protobuf containing the public key into bytes using the [canonical protobuf encoding](https://developers.google.com/protocol-buffers/docs/encoding).
108
108
4. If the length of the serialized bytes <= 42, then we compute the "identity" multihash of the serialized bytes. In other words, no hashing is performed, but the [multihash format is still followed](https://github.com/multiformats/multihash) (byte plus varint plus serialized bytes). The idea here is that if the serialized byte array is short enough, we can fit it in a multihash verbatim without having to condense it using a hash function.
109
109
5. If the length is >42, then we hash it using it using the SHA256 multihash.
110
-
110
+
111
111
### Note about deterministic encoding
112
112
113
113
Deterministic encoding of the `PublicKey` message is desirable, as it ensures
@@ -131,16 +131,43 @@ behavior.
131
131
132
132
### String representation
133
133
134
-
Peer Ids are multihashes, and they are often encoded into strings.
135
-
The canonical string representation of a Peer Id is a base58 encoding with
136
-
[the alphabet used by bitcoin](https://en.bitcoinwiki.org/wiki/Base58#Alphabet_Base58).
137
-
This encoding is sometimes abbreviated as `base58btc`.
134
+
Peer Ids are [multihashes][multihash] represented with [CIDs](https://github.com/ipld/cid) when encoded into strings.
135
+
136
+
CID is a multihash with a prefix that specifies things like base encoding, cid version and the type of data behind it:
Implementations MUST support RSA and Ed25519. Implementations MAY support Secp256k1 and ECDSA, but nodes using those keys may not be able to connect to all other nodes.
154
181
155
-
In all cases, implementation MAY allow the user to enable/disable specific key types via configuration.
182
+
In all cases, implementation MAY allow the user to enable/disable specific key types via configuration.
156
183
Note that disabling support for compulsory key types may hinder connectivity.
157
184
158
185
Keys are encoded into byte arrays and serialized into the `Data` field of the
@@ -204,4 +231,3 @@ We encode the public key using ASN.1 DER.
204
231
We encode the private key using DER-encoded PKIX.
205
232
206
233
To sign a message, we hash the message with SHA 256, and then sign it with the [ECDSA standard algorithm](https://tools.ietf.org/html/rfc6979), then we encode it using [DER-encoded ASN.1.](https://wiki.openssl.org/index.php/DER)
0 commit comments