Verify calls ecdsa.Verify to verify the signature of hash using the public key. It returns true if the signature is valid, false otherwise.
(hash []byte, signee *PublicKey)
| 96 | // Verify calls ecdsa.Verify to verify the signature of hash using the public key. It returns true |
| 97 | // if the signature is valid, false otherwise. |
| 98 | func (s *Signature) Verify(hash []byte, signee *PublicKey) bool { |
| 99 | if BypassSignature { |
| 100 | return true |
| 101 | } |
| 102 | if signee == nil || s == nil { |
| 103 | return false |
| 104 | } |
| 105 | |
| 106 | cacheKey := make([]byte, 64+len(hash)+ec.PubKeyBytesLenUncompressed) |
| 107 | signature := cacheKey[:64] |
| 108 | copy(signature, utils.PaddedBigBytes(s.R, 32)) |
| 109 | copy(signature[32:], utils.PaddedBigBytes(s.S, 32)) |
| 110 | copy(cacheKey[64:64+len(hash)], hash) |
| 111 | signeeBytes := (*ec.PublicKey)(signee).SerializeUncompressed() |
| 112 | copy(cacheKey[64+len(hash):], signeeBytes) |
| 113 | |
| 114 | if _, ok := verifyCache.Get(string(cacheKey)); ok { |
| 115 | return true |
| 116 | } |
| 117 | valid := secp256k1.VerifySignature(signeeBytes, hash, signature) |
| 118 | if valid { |
| 119 | verifyCache.Add(string(cacheKey), nil) |
| 120 | } |
| 121 | return valid |
| 122 | //return ecdsa.Verify(signee.toECDSA(), hash, s.R, s.S) |
| 123 | } |
| 124 | |
| 125 | // MarshalBinary does the serialization. |
| 126 | func (s *Signature) MarshalBinary() (keyBytes []byte, err error) { |
nothing calls this directly
no test coverage detected