I see in the browser that the web socket connects and a message is sent but the browser logs that a connection is starting and that a peer has been discovered but never logs the connect, nor an error.
What’s the best way to have a browser node bootstrap to a go node?
You are correct that I’m using ecdsa keys on the go side. Specifically this:
func p2pPrivateFromEcdsaPrivate(key *ecdsa.PrivateKey) (libp2pcrypto.PrivKey, error) {
// private keys can be 31 or 32 bytes for ecdsa.PrivateKey, but must be 32 Bytes for libp2pcrypto,
// so we zero pad the slice if it is 31 bytes.
keyBytes := key.D.Bytes()
if (len(keyBytes) != expectedKeySize) && (len(keyBytes) != (expectedKeySize - 1)) {
return nil, fmt.Errorf("error: length of private key must be 31 or 32 bytes")
}
keyBytes = append(make([]byte, expectedKeySize-len(keyBytes)), keyBytes...)
libp2pKey, err := libp2pcrypto.UnmarshalSecp256k1PrivateKey(keyBytes)
if err != nil {
return libp2pKey, fmt.Errorf("error unmarshaling: %v", err)
}
return libp2pKey, err
}
And then using the results in a libp2p option: libp2p.Identity(priv),
The issue may be on the JS side and what you’re encountering sounds like that’s the case. Changing the JS keys, go is still doing the crypto handshake just fine, but changing go keys causes the crypto shake to fail. This would be a great test suite to get added to https://github.com/libp2p/interop. Going to add an issue there.