From 0d63e90b67e52c8c3e13d6733a80ddf9735234c6 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Thu, 24 Oct 2024 10:54:43 -0400 Subject: [PATCH] docs(did): add comment explaining why some ECDSA public keys are "coerced" to Secp256k1 public keys --- did/crypto.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/did/crypto.go b/did/crypto.go index 8eed59a..da2a7aa 100644 --- a/did/crypto.go +++ b/did/crypto.go @@ -200,6 +200,13 @@ func codeForCurve(pubKey crypto.PubKey) (multicodec.Code, error) { } } +// secp256k1.S256 is a valid ECDSA curve, but the go-libp2p/core/crypto +// package treats it ask a different type and has a different format for +// the raw bytes of the public key. +// +// If a valid ECDSA public key was created the secp256k1.S256 curve, this +// function will "convert" it from a crypto.ECDSAPubKey to a +// crypto.Secp256k1PublicKey. func coerceECDSAToSecp256k1(pubKey crypto.PubKey) (crypto.PubKey, error) { stdPub, err := crypto.PubKeyToStdKey(pubKey) if err != nil {