MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / Verify

Method Verify

crypto/asymmetric/signature.go:98–123  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
98func (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.
126func (s *Signature) MarshalBinary() (keyBytes []byte, err error) {

Callers

nothing calls this directly

Calls 4

PaddedBigBytesFunction · 0.92
VerifySignatureFunction · 0.92
GetMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected