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
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,54 @@ 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] canonically represented with [CIDs](https://github.com/ipld/cid) when encoded into strings.
135
+
136
+
Encoding and decoding of string representation MUST follow [CID specification][cid-decoding].
137
+
138
+
Implementations parsing IDs from text MUST support both base58 CIDv0 and CIDv1 in base32, and they MUST generate base32-encoded CIDv1 by default. Generating CIDv0 is allowed as an opt-in (behind a flag).
139
+
140
+
CIDv0 is a multihash encoded in Base58.
141
+
CIDv1 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
192
155
-
In all cases, implementation MAY allow the user to enable/disable specific key types via configuration.
193
+
In all cases, implementation MAY allow the user to enable/disable specific key types via configuration.
156
194
Note that disabling support for compulsory key types may hinder connectivity.
157
195
158
196
Keys are encoded into byte arrays and serialized into the `Data` field of the
@@ -204,4 +242,3 @@ We encode the public key using ASN.1 DER.
204
242
We encode the private key using DER-encoded PKIX.
205
243
206
244
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