w3c-ccg / did-method-key

DID (Decentralized Identifier) did:key method for embedding keys in DID urls
https://w3c-ccg.github.io/did-method-key
Other
18 stars 12 forks source link

Clarify Multicodec Identifiers #35

Open Matt-Spence opened 3 years ago

Matt-Spence commented 3 years ago

The draft spec says that the Multibase step is a base58 encoding of "a concatenation of the Multicodec [MULTICODEC] identifier for the public key type and the raw bytes". The multicodec table it references is here, and doesn't seem to match the examples in the spec. For instance, for an ed25519 pub key (line 85 in the csv), the Multicodec identifier is listed as 0xed, but the example keys all begin with 0xed01. This extra 01 is also present in the Secp256k1 examples (0xe7 in the list, 0xe701 in the example). The extra 01 byte should either be dropped, or the spec should be clarified to make it clear why these don't match the cited multicodec list.

paulbastian commented 3 years ago

I just came through the same thought process. Have a look here: https://github.com/multiformats/unsigned-varint https://lists.w3.org/Archives/Public/public-credentials/2021Mar/0042.html

Matt-Spence commented 3 years ago

That explains it. Thank you for the information, I was unaware of the strange way multicodec handles integers. This should be clarified in the spec.

paulbastian commented 3 years ago

Yes, I agree as well, it's pretty unintuitive and makes it hard to read the codec as the values in the csv are stored as "real" ints and not varints. You got to live with that or choose others like JWK+base64 or similar

OR13 commented 2 years ago

How can I help to address this concern?

miketery commented 2 years ago

Had same trouble as above when I was trying to figure out mapping from key (z6Mkp...) to publicKeyBase58 (B12NY...).

@OR13 , I think an example showing the hex of the public key, and then the steps to add 0xED01 (0xED for ed25519 per multicodec table, 0x01 due to integer encoding) then to base58, then add z.

OR13 commented 2 years ago

yes, i have also struggled with this.... I agree with the proposed approach:

define a table, include the public key bytes, public key kty / crv, multicodec prefix, base58 encoding.

provide an example for all supported multicodec public keys.