The short go file at ipfs-key/main.go at master · whyrusleeping/ipfs-key · GitHub generates keypairs and prints the peer ID in the
12D3KooW… format. I’d like to obtain the keys in the k51qzi5uqu5d… format.
I can obtain the k51… format using
ipfs key import some-name private-key-file followed by
ipfs key list -l, but I’m looking for a way to obtain the k51… in go, or at least without using an external process.
After a lot of searching, I found https://cid.ipfs.io/ which shows that, after decoding, that site shows some very similar info for the following two hashes (obtained using the standalone key generator and ipfs key import):
Once converted to CIDv1 base32, they become:
Aside from the bafy/bafz (which seems to indicate the codec 0x70 vs 0x72), there’s no difference.
I know how to convert the CIDv1 base32
bafz to a CIDv1 base36 k50 / k51 using
ipfs cid format -b base36 baf…, and from what I understand it’s a simple base conversion.
I’m still stumped about how I would get the CIDv1 base32 format from the
12D3KooW…, it seems that the multicodec identifier 0x72 gets inserted somehow into the mix (because the 12D… hash has everything implicit) and there’s something related to protobuf, but I haven’t used that.
So I guess my question is, “how do I protobuf the multicodec :-p to get from 12D… to one of the CIDv1 encodings?”.
Thanks a lot