From 8b2734a780c07a2d5c0f5884e0ed65393eb59671 Mon Sep 17 00:00:00 2001 From: Daniel Bourdrez <3641580+bytemare@users.noreply.github.com> Date: Sat, 22 Apr 2023 01:28:11 +0200 Subject: [PATCH] update secp256k1 dependency (#42) Signed-off-by: bytemare <3641580+bytemare@users.noreply.github.com> --- README.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/secp256k1/group.go | 8 +++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bdd9f94..7eba719 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ The following table indexes supported groups with hash-to-curve capability and l | 4 | P-384 | filippo.io/nistec | | 5 | P-521 | filippo.io/nistec | | 6 | Edwards25519 | filippo.io/edwards25519 | -| 7 | Secp256k1 | github.com/bytemare/crypto | +| 7 | Secp256k1 | github.com/bytemare/secp256k1 | | 8 | Double-Odd | not yet supported | ## Prime-order group interface diff --git a/go.mod b/go.mod index bb03855..f201c5b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( filippo.io/edwards25519 v1.0.0 filippo.io/nistec v0.0.2 github.com/bytemare/hash2curve v0.2.2 - github.com/bytemare/secp256k1 v0.0.0-20230421210201-f2244bd0effa + github.com/bytemare/secp256k1 v0.1.0 github.com/gtank/ristretto255 v0.1.2 ) diff --git a/go.sum b/go.sum index e296000..af79dc6 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/bytemare/hash v0.1.5 h1:VW+X1YQ2b3chjRFHkRUnO42uclsQjXimdBCPOgIobR4= github.com/bytemare/hash v0.1.5/go.mod h1:+QmWXTky/2b63ngqM5IYezGydn9UTFDhpX7mLYwYxCA= github.com/bytemare/hash2curve v0.2.2 h1:zaGx6Z4/N4Pl9B7aGNtpbZ09vu1NNJGoJRRtHHl8oTw= github.com/bytemare/hash2curve v0.2.2/go.mod h1:Wma3DmJdn8kqiK9j120hkWvC3tQVKS1PyA8ZzyG23BI= -github.com/bytemare/secp256k1 v0.0.0-20230421210201-f2244bd0effa h1:vrXhOGi25aItUpmJo1ItTZhcv5L7U9/1vdcxL+pKa88= -github.com/bytemare/secp256k1 v0.0.0-20230421210201-f2244bd0effa/go.mod h1:hzquMsr3GXhVcqL9qFX7GGjmcT5dlQldKrArd7tcXHE= +github.com/bytemare/secp256k1 v0.1.0 h1:kjVJ06GAHSa+EJ7Rz1LdVgE0DQWdvUT77tmcGf7epXQ= +github.com/bytemare/secp256k1 v0.1.0/go.mod h1:hzquMsr3GXhVcqL9qFX7GGjmcT5dlQldKrArd7tcXHE= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= diff --git a/internal/secp256k1/group.go b/internal/secp256k1/group.go index f0b1b03..abe2b58 100644 --- a/internal/secp256k1/group.go +++ b/internal/secp256k1/group.go @@ -27,8 +27,6 @@ const ( elementLength = 33 ) -var group = secp256k1.New() - // Group represents the Secp256k1 group. It exposes a prime-order group API with hash-to-curve operations. type Group struct{} @@ -55,19 +53,19 @@ func (g Group) Base() internal.Element { // HashToScalar returns a safe mapping of the arbitrary input to a Scalar. // The DST must not be empty or nil, and is recommended to be longer than 16 bytes. func (g Group) HashToScalar(input, dst []byte) internal.Scalar { - return &Scalar{scalar: group.HashToScalar(input, dst)} + return &Scalar{scalar: secp256k1.HashToScalar(input, dst)} } // HashToGroup returns a safe mapping of the arbitrary input to an Element in the Group. // The DST must not be empty or nil, and is recommended to be longer than 16 bytes. func (g Group) HashToGroup(input, dst []byte) internal.Element { - return &Element{element: group.HashToGroup(input, dst)} + return &Element{element: secp256k1.HashToGroup(input, dst)} } // EncodeToGroup returns a non-uniform mapping of the arbitrary input to an Element in the Group. // The DST must not be empty or nil, and is recommended to be longer than 16 bytes. func (g Group) EncodeToGroup(input, dst []byte) internal.Element { - return &Element{element: group.EncodeToGroup(input, dst)} + return &Element{element: secp256k1.EncodeToGroup(input, dst)} } // Ciphersuite returns the hash-to-curve ciphersuite identifier.