From 5f7387b9bb9090a368386b80d658433c72449453 Mon Sep 17 00:00:00 2001 From: Eugene Zagidullin Date: Thu, 23 Jan 2025 21:10:15 +0200 Subject: [PATCH] re-export S256() --- crypt/common.go | 11 +++++------ crypt/ecdsa.go | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crypt/common.go b/crypt/common.go index 84a371d..0dad7f6 100644 --- a/crypt/common.go +++ b/crypt/common.go @@ -10,7 +10,6 @@ import ( "fmt" "math/big" - "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/ecadlabs/goblst/minpk" tz "github.com/ecadlabs/gotez/v2" "github.com/ecadlabs/gotez/v2/b58" @@ -66,7 +65,7 @@ func NewPrivateKey(priv tz.PrivateKey) (PrivateKey, error) { return Ed25519PrivateKey(ed25519.NewKeyFromSeed(key[:])), nil case *tz.Secp256k1PrivateKey: - p, err := unmarshalPrivateKey(key[:], secp256k1.S256()) + p, err := unmarshalPrivateKey(key[:], S256()) if err != nil { return nil, err } @@ -106,7 +105,7 @@ func NewPublicKey(pub tz.PublicKey) (PublicKey, error) { ) switch key := pub.(type) { case *tz.Secp256k1PublicKey: - curve = secp256k1.S256() + curve = S256() data = key[:] case *tz.P256PublicKey: curve = elliptic.P256() @@ -134,7 +133,7 @@ func NewPrivateKeyFrom(priv crypto.PrivateKey) (PrivateKey, error) { switch priv := priv.(type) { case *ecdsa.PrivateKey: switch priv.Curve { - case secp256k1.S256(), elliptic.P256(): + case S256(), elliptic.P256(): return (*ECDSAPrivateKey)(priv), nil default: return nil, ErrUnsupportedKeyType @@ -154,7 +153,7 @@ func NewPublicKeyFrom(pub crypto.PublicKey) (PublicKey, error) { switch pub := pub.(type) { case *ecdsa.PublicKey: switch pub.Curve { - case secp256k1.S256(), elliptic.P256(): + case S256(), elliptic.P256(): return (*ECDSAPublicKey)(pub), nil default: return nil, ErrUnsupportedKeyType @@ -184,7 +183,7 @@ func NewSignature(sig tz.Signature) (Signature, error) { return &ECDSASignature{ R: r, S: s, - Curve: secp256k1.S256(), + Curve: S256(), }, nil case *tz.P256Signature: diff --git a/crypt/ecdsa.go b/crypt/ecdsa.go index 651bc67..3d03de7 100644 --- a/crypt/ecdsa.go +++ b/crypt/ecdsa.go @@ -12,6 +12,8 @@ import ( tz "github.com/ecadlabs/gotez/v2" ) +func S256() *secp256k1.KoblitzCurve { return secp256k1.S256() } + type ECDSAPrivateKey ecdsa.PrivateKey func (priv *ECDSAPrivateKey) ToBase58() []byte {