mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-08 21:13:46 +00:00
Implement RIP-7212/EIP-7212 according to reference implementation at https://github.com/ulerdogan/go-ethereum/pull/1 Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
22 lines
569 B
Go
22 lines
569 B
Go
package secp256r1
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"math/big"
|
|
)
|
|
|
|
// Verify verifies the given signature (r, s) for the given hash and public key (x, y).
|
|
// It returns true if the signature is valid, false otherwise.
|
|
func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
|
// Create the public key format
|
|
publicKey := newPublicKey(x, y)
|
|
|
|
// Check if they are invalid public key coordinates
|
|
if publicKey == nil {
|
|
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)
|
|
}
|