Skip to content

Commit

Permalink
crypto/secp256r1: remove malleability check due to spec
Browse files Browse the repository at this point in the history
(cherry picked from commit cec0b058115282168c5afc5197de3f6b5479dc4a)
  • Loading branch information
ulerdogan authored and anshalshukla committed Nov 3, 2023
1 parent ab2f20e commit 738107b
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions crypto/secp256r1/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ package secp256r1

import (
"crypto/ecdsa"
"crypto/elliptic"
"math/big"
)

var (
// Half of the order of the subgroup in the elliptic curve
secp256k1halfN = new(big.Int).Div(elliptic.P256().Params().N, big.NewInt(2))
)

// Verifies the given signature (r, s) for the given hash and public key (x, y).
func Verify(hash []byte, r, s, x, y *big.Int) bool {
// Create the public key format
Expand All @@ -21,17 +15,7 @@ func Verify(hash []byte, r, s, x, y *big.Int) bool {
return false
}

// Check the malleability issue
if checkMalleability(s) {
return false
}

// Verify the signature with the public key,
// then return true if it's valid, false otherwise
return ecdsa.Verify(publicKey, hash, r, s)
}

// Check the malleability issue
func checkMalleability(s *big.Int) bool {
return s.Cmp(secp256k1halfN) > 0
}

0 comments on commit 738107b

Please sign in to comment.