Skip to content

Commit 945f985

Browse files
authored
Merge pull request #50 from onflow/tarak/minor-update
Minor ECDSA public key decoding update
2 parents b36f13d + b443720 commit 945f985

3 files changed

Lines changed: 2 additions & 13 deletions

File tree

ecdsa_secp256k1.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,6 @@ func publicKeyECDSASecp256k1(a *ecdsaContext, XYBytes []byte) (*pubKeyECDSASecp2
152152
}
153153

154154
x, y := readTwoBigInts(XYBytes, pLen)
155-
156-
// check the coordinates are valid field elements.
157-
// This check is unconditional and must not be removed when go-ethereum is upgraded:
158-
// it keeps the set of accepted key encodings independent of the go-ethereum version
159-
// that Go module resolution selects, which this package does not control.
160-
// Without it, a non-canonical encoding such as `x+p` is accepted whenever
161-
// the resolved go-ethereum is v1.16.8 or earlier.
162-
if x.Cmp(a.curveP) >= 0 || y.Cmp(a.curveP) >= 0 {
163-
return nil, invalidInputsErrorf("at least one coordinate is larger than the field prime for %s", a.algo)
164-
}
165-
166155
// `IsOnCurve` includes checks for x<p and y<p (in go-ethereum versions from v1.16.9 onwards)
167156
if !secp256k1.S256().IsOnCurve(x, y) {
168157
return nil, invalidInputsErrorf("input point has invalid coordinates or is not on curve")

ecdsa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func TestECDSAEncodeDecode(t *testing.T) {
203203
// - public key decoding handles input x-coordinates with x and y larger than p (doesn't result in an exception)
204204
// - public key decoding only accepts reduced x and y
205205
t.Run("public key with non-reduced coordinates", func(t *testing.T) {
206-
onflowCryptoErr := "at least one coordinate is larger than the field prime"
206+
onflowCryptoErr := "input point has invalid coordinates or is not on curve"
207207
goCryptoErr := "invalid P256 element encoding"
208208

209209
invalidPKs := []struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
// Minimum version, not a pin: Go builds with the highest version required across the build.
77
// Keeping this floor low lets consumers choose their own go-ethereum version;
88
// raising it forces the new version on all of them.
9-
// Only raise it if this module needs something v1.16.8 lacks,
9+
// Only raise it if this module needs something the current version lacks,
1010
// and audit the changes under go-ethereum/crypto/secp256k1 when doing so.
1111
github.com/ethereum/go-ethereum v1.17.0
1212
github.com/sirupsen/logrus v1.9.3

0 commit comments

Comments
 (0)