util_verify
Behaviour
Section titled “Behaviour”Verify a cryptographic signature
- If the public key is prefixed with
0xED
then useED25519
- Otherwise assume
SECP256k1
Definition
Section titled “Definition”int64_t util_verify ( uint32_t dread_ptr, uint32_t dread_len, uint32_t sread_ptr, uint32_t sread_len, uint32_t kread_ptr, uint32_t kread_len);
function util_verify( signedData: ByteArray | HexString, signature: ByteArray | HexString, pubkey: ByteArray | HexString ): 0 | 1
Example
Section titled “Example”if (!util_verify(payload_ptr, payload_len, signature_ptr, signature_len, publickey_ptr, publickey_len)) rollback("Invalid Signature", 17, 60);
if (util_verify(signedData,signature,pubkey)) rollback("Invalid Signature", 60)
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
dread_ptr | uint32_t | Pointer to the signed data |
dread_len | uint32_t | Length of the signed data |
sread_ptr | uint32_t | Pointer to the signature |
sread_len | uint32_t | Length of the signature |
kread_ptr | uint32_t | Pointer to the public key |
kread_len | uint32_t | Length of the public key |
Name | Type | Description |
---|---|---|
signedData | number / string | The signed data to verify, can be provided as an array of numbers or a string. |
signature | number / string | The signature to verify, can be provided as an array of numbers or a string. |
pubkey | number / string | The public key responsible for the signature, can be provided as an array of numbers or a string. |
Return Code
Section titled “Return Code”Type | Description |
---|---|
int64_t | 0 - validation failed, the signature is invalid.1 - validation succeeded, the signature is valid.If negative, an error: OUT_OF_BOUNDS - pointers/lengths specified outside of hook memory. |
Type | Description |
---|---|
number | 0 - validation failed, the signature is invalid.1 - validation succeeded, the signature is valid. |