I'm trying to use the elliptic curve secp256k1 in Go with the library "crypto/x509". After the key pair generation, I obtain respectively the public key pubKey and the private key privKey. After that, I want to generate a certificate that include the public key, but before I want to store the private key in a .pem file:
keyDer, err := x509.MarshalECPrivateKey(privKey)
if err != nil {
log.Fatalf("Failed to serialize ECDSA key: %s\n", err)
}
but when I try to marshal an EC private key into ASN.1, DER format and to compile the code, I receive an error that said:
Failed to serialize ECDSA key: x509: unknown elliptic curve
In this case it's necessary for me to work with that particular curve, so I cannot change to prime256v1 or ''similar curve''. Is there a solution that permits to add the support for secp256k1 in crypto/x509 library, or another way/suggestion?
x509.ParseCertificate()
and resolving all dependencies. Noted: i'm not affiliated in anyway with the lib – Prince