In prior, is there any reason to omit secp256k1 in this package? I know it's widely used for ECDSA so I was wondering if there is specific reason to not support the curve for Diffie-Hellman

What did you do?

I'm trying to implement a protocol that involves ecdh as key agreement in a blockchain context, precisely ethereum. secp256k1 is the curve used natively so I'd just wanted to leverage on it to not create another set of public key with another curve that this package actually supports (P256, P384, P521)

What did you expect to see?

ability to init public key from a secp256k1 curve

func DHSharedKey(pk *ecdh.PrivateKey, remoteX []byte, remoteY []byte) ([]byte, error) {
    pub, err := ecdh.S256().NewPublicKey(append([]byte{0x04}, append(remoteX, remoteY...)...))
    if err != nil {
        return nil, err
    }

    return pk.ECDH(pub)
}

What did you see instead?

unsupported curve by crypto/ecdh

Comment From: irzhywau

@FiloSottile do you have any thoughts please?

Comment From: seankhliao

cc @golang/security

Comment From: MichaelMure

Properly supporting this curve should also include support in x509.ParsePKCS8PrivateKey() and x509.ParsePKIXPublicKey().