VerifySignature checks that the given pubkey created signature over message. The signature should be in [R || S] format.
(pubkey, msg, signature []byte)
| 120 | // VerifySignature checks that the given pubkey created signature over message. |
| 121 | // The signature should be in [R || S] format. |
| 122 | func VerifySignature(pubkey, msg, signature []byte) bool { |
| 123 | if len(msg) != 32 || len(signature) != 64 || len(pubkey) == 0 { |
| 124 | return false |
| 125 | } |
| 126 | sigdata := (*C.uchar)(unsafe.Pointer(&signature[0])) |
| 127 | msgdata := (*C.uchar)(unsafe.Pointer(&msg[0])) |
| 128 | keydata := (*C.uchar)(unsafe.Pointer(&pubkey[0])) |
| 129 | return C.secp256k1_ext_ecdsa_verify(context, sigdata, msgdata, keydata, C.size_t(len(pubkey))) != 0 |
| 130 | } |
| 131 | |
| 132 | // DecompressPubkey parses a public key in the 33-byte compressed format. |
| 133 | // It returns non-nil coordinates if the public key is valid. |
no outgoing calls