Verify checks a raw ECDSA signature. Returns true if it's valid and false if not.
(data, signature []byte, pubkey *ecdsa.PublicKey)
| 92 | // Verify checks a raw ECDSA signature. |
| 93 | // Returns true if it's valid and false if not. |
| 94 | func 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 | } |
no outgoing calls