ChainSafe/js-libp2p-noise

libp2p keys may be other types than ed25519

yusefnapora opened this issue · 1 comments

Hey 👋thanks for making this!

I noticed as I was reviewing this that the constructor accepts a privateKey argument which is used for signing / verifying payloads, and that the key is assumed to be an ed25519 key. Since libp2p keys can also be RSA or secp256k1 keys, this assumption might break.

Instead, you can grab the private key from the localPeer argument that's provided to secureInbound and secureOutbound. This will have a sign method you can use for signing the handshake payload. To verify the remote party's signatures, you can unmarshal the key and call its verify method, instead of calling ed25519.verify.

Hi @yusefnapora thanks for taking a look!

Yes, I am aware of this but didn't have time to take care of all the details so great that you raised the issue. Great tip, will do that!