What’s the easiest way to go from a pkcs8-pem-formatted public key to a peer ID base58 multihash (“QmWhatever”)? It looks like js-libp2p-crypto’s
crypto.keys.import only accepts private keys and that’s the only thing I found to ingest PEMs.
I’m building a social network where your public key is central to your identity, so I’d rather keep them in a well-established standard format like pkcs8-pem than the libp2p protobuf-encoded format. One reason is that if this file changes I don’t want users’ main unique identifier to change. (right?)
I think it would be ideal to export some methods from crypto to help make this easier to do, and should probably happen with the privatekey improvement https://github.com/libp2p/js-peer-id/issues/82. The supportedKeys methods used in libp2p-crypto are exported so they could be used as they are here, https://github.com/libp2p/js-libp2p-crypto/blob/v0.17.0/src/keys/index.js#L59-L66, but you’d have to specify the key type, where the protobuf keeps track of that.
Something to note, the protobuf file should not change in a breaking manner. New key types might get added, but those will be backwards compatible changes. Breaking compatibility on that would be a huge issue for the network so we will avoid that at all costs. If it ever needs to happen, we’ll create a migration path.
Oh, I didn’t realize that about the protobufs. It seems like using those will be much easier then, thank you!