MCPcopy
hub / github.com/gtank/cryptopasta / Verify

Function Verify

sign.go:94–105  ·  view source on GitHub ↗

Verify checks a raw ECDSA signature. Returns true if it's valid and false if not.

(data, signature []byte, pubkey *ecdsa.PublicKey)

Source from the content-addressed store, hash-verified

92// Verify checks a raw ECDSA signature.
93// Returns true if it's valid and false if not.
94func Verify(data, signature []byte, pubkey *ecdsa.PublicKey) bool {
95 // hash message
96 digest := sha256.Sum256(data)
97
98 curveOrderByteSize := pubkey.Curve.Params().P.BitLen() / 8
99
100 r, s := new(big.Int), new(big.Int)
101 r.SetBytes(signature[:curveOrderByteSize])
102 s.SetBytes(signature[curveOrderByteSize:])
103
104 return ecdsa.Verify(pubkey, digest[:], r, s)
105}

Callers 2

TestSignFunction · 0.85
TestSignWithP384Function · 0.85

Calls

no outgoing calls

Tested by 2

TestSignFunction · 0.68
TestSignWithP384Function · 0.68