How to convert PrivKey to crypto/ecdsa.PrivateKey?

Can anyone help me with the sample snippet to convert libp2p PrivKey to https://pkg.go.dev/crypto/ecdsa PrivateKey ?

Hi,
If you want to libp2p ECDSAPrivateKey to crypto ecdsa key;
you can use ‘ MarshalECDSAPrivateKey’ function (which is in go-libp2p-core/crypto) to marshal your private key to byte slice and then
‘’’
// using crypto/x509 package
priv, err := x509.ParseECPrivateKey(data)
if err != nil {
return nil, err
}
‘’’

But if you mean any libp2p ‘PrivKey’ to ecdsa.PrivateKey, sorry i dont know :frowning:

Hope this will help.