Verify a cryptographic signature

Behaviour

Verify a cryptographic signature

  • If the public key is prefixed with 0xED then use ED25519
  • Otherwise assume SECP256k1

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
);

Example

if (!util_verify(payload_ptr,    payload_len,
                 signature_ptr,  signature_len,
                 publickey_ptr,  publickey_len))
	rollback("Invalid Signature", 17, 60);

Parameters

NameTypeDescription
dread_ptruint32_tPointer to the signed data
dread_lenuint32_tLength of the signed data
sread_ptruint32_tPointer to the signature
sread_lenuint32_tLength of the signature
kread_ptruint32_tPointer to the public key
kread_lenuint32_tLength of the public key

Return Code

TypeDescription
int64_t0 - 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.