digitalbazaar / did-method-key

A did-io driver for the DID "key" method
Other
26 stars 10 forks source link

multibase multikey header explanation? #62

Closed merlinstardust closed 1 year ago

merlinstardust commented 1 year ago

So I understand that the multibaseMultikeyHeader is the first 4 characters of a multibase public key and that the first character is the algorithm identifier as defined by this spec.

Example: This public key from the docs z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH has a header of z6Mk

Where do the other 3 characters come from? Are these 3 characters where I could use a mnemonic for hierarchical deterministic wallets?

dlongley commented 1 year ago

The other three characters decode to a varint representation of an entry in the multicodec table:

https://github.com/multiformats/multicodec/blob/master/table.csv

The codec value for an Ed25519 public key is 0xed. When encoded as a varint, 0xed is two bytes: [0xed, 0x01]. These two bytes, when encoded using the base58btc alphabet are: 6Mk. The prefixed z indicates that the base58btc alphabet was used for the encoding, thus the total z6Mk prefix for an Ed25519 public key.