crypto/secp256r1: remove malleability check due to spec
This commit is contained in:
parent
7e0bc9271b
commit
cec0b05811
|
@ -2,15 +2,9 @@ package secp256r1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"crypto/elliptic"
|
|
||||||
"math/big"
|
"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).
|
// 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 {
|
func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
||||||
// Create the public key format
|
// Create the public key format
|
||||||
|
@ -21,17 +15,7 @@ func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the malleability issue
|
|
||||||
if checkMalleability(s) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the signature with the public key,
|
// Verify the signature with the public key,
|
||||||
// then return true if it's valid, false otherwise
|
// then return true if it's valid, false otherwise
|
||||||
return ecdsa.Verify(publicKey, hash, r, s)
|
return ecdsa.Verify(publicKey, hash, r, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the malleability issue
|
|
||||||
func checkMalleability(s *big.Int) bool {
|
|
||||||
return s.Cmp(secp256k1halfN) > 0
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue