Closed felix314159 closed 6 days ago
I think you have a serialization problem. Try converting the keys to strings and see how they look like.
Still can't get this to work. For now my workaround is storing them as ed25519.PrivateKey and then at runtime casting them to go-libp2p/core/crypto.PrivKey with UnmarshalEd25519PrivateKey()
Use crypto.GenerateKeyPair( crypto.Ed25519, -1, )
You can use the Raw()
method to get the raw bytes and convert them to ed25519.PrivateKey
Hi, I want to generate an ed25519 keypair then use crypto/ssh to encrypt the key into the OpenSSH format. When I try to use an ed25519 key created with go-libp2p/core/crypto with the function ssh.MarshalPrivateKeyWithPassphrase(), then I get the error "ssh: unsupported key type *crypto.Ed25519PrivateKey". But when I use crypto/ed25519 to generate the ed25519 key it works as expected. Here is an example demonstrating both scenarios: https://go.dev/play/p/CzuK_YDL09G
Note: the libp2p version of the code does not run in playground due to timing out, so run it somewhere else
If this is not a bug: How to change the code so that I can continue using the go-libp2p/core/crypto instead of crypto/ed25519? I am using go version go1.22.3 if that matters.
Thanks, have a nice day!
Version Information