Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions ecdsa_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,6 @@ func publicKeyECDSASecp256k1(a *ecdsaContext, XYBytes []byte) (*pubKeyECDSASecp2
}

x, y := readTwoBigInts(XYBytes, pLen)

// check the coordinates are valid field elements.
// This check is unconditional and must not be removed when go-ethereum is upgraded:
// it keeps the set of accepted key encodings independent of the go-ethereum version
// that Go module resolution selects, which this package does not control.
// Without it, a non-canonical encoding such as `x+p` is accepted whenever
// the resolved go-ethereum is v1.16.8 or earlier.
if x.Cmp(a.curveP) >= 0 || y.Cmp(a.curveP) >= 0 {
return nil, invalidInputsErrorf("at least one coordinate is larger than the field prime for %s", a.algo)
}

// `IsOnCurve` includes checks for x<p and y<p (in go-ethereum versions from v1.16.9 onwards)
if !secp256k1.S256().IsOnCurve(x, y) {
return nil, invalidInputsErrorf("input point has invalid coordinates or is not on curve")
Expand Down
2 changes: 1 addition & 1 deletion ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func TestECDSAEncodeDecode(t *testing.T) {
// - public key decoding handles input x-coordinates with x and y larger than p (doesn't result in an exception)
// - public key decoding only accepts reduced x and y
t.Run("public key with non-reduced coordinates", func(t *testing.T) {
onflowCryptoErr := "at least one coordinate is larger than the field prime"
onflowCryptoErr := "input point has invalid coordinates or is not on curve"
goCryptoErr := "invalid P256 element encoding"

invalidPKs := []struct {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
// Minimum version, not a pin: Go builds with the highest version required across the build.
// Keeping this floor low lets consumers choose their own go-ethereum version;
// raising it forces the new version on all of them.
// Only raise it if this module needs something v1.16.8 lacks,
// Only raise it if this module needs something the current version lacks,
// and audit the changes under go-ethereum/crypto/secp256k1 when doing so.
github.com/ethereum/go-ethereum v1.17.0
github.com/sirupsen/logrus v1.9.3
Expand Down
Loading