Skip to content

proposal: crypto/ecdh: support for secp256k1 curve #59368

Open
@irzhywau

Description

@irzhywau

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalProposal-CryptoProposal related to crypto packages or other security issues

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions