const verify_sig = new StaticArray<u8>(SIGNATURE_BYTELENGTH)
/**
* Verify a 64-byte detached signature for a variable-length message against a
- * 32-byte public key. Parameters are read as bytes from the input buffer in the
- * following order:
- *
- * - `[0,63]: signature`
- * - `[64,95]: public key`
- *
- * The message itself is read from a separate buffer.
+ * 32-byte public key. Input parameters are read as bytes from separate buffers.
* @param {u64} mlen Byte length of message that was signed, up to 32768
* @returns {boolean} True if message was signed by public key's private key
*/
const verify_blocks_sig = new StaticArray<u8>(SIGNATURE_BYTELENGTH)
/**
* Verify a 64-byte detached signature for a 32-byte Nano block hash against a
- * 32-byte public key. Parameters are read as bytes from the input buffer in the
- * following order:
+ * 32-byte public key. Input parameters are read as bytes from separate buffers.
*
- * - `[0,63]: signature`
- * - `[64,95]: public key`
- *
- * The message buffer can hold up 1024 block hashes to verify many signatures
- * for a single public key.
+ * The message buffer and the signature buffer can hold up 1024 block hashes and
+ * signatures to verify many blocks for a single public key.
* @param {u64} mlen Byte length of message that was signed, up to 32768
* @returns {boolean} True if message was signed by public key's private key
*/
}
// Clear local buffers
- verify_pub.fill(0)
- verify_sig.fill(0)
+ verify_blocks_pub.fill(0)
+ verify_blocks_sig.fill(0)
// Copy input buffer to local parameters, then clear input buffer
- memory.copy(changetype<usize>(verify_sig), changetype<usize>(PUB_BUFFER), SIGNATURE_BYTELENGTH)
+ memory.copy(changetype<usize>(verify_blocks_sig), changetype<usize>(PUB_BUFFER), SIGNATURE_BYTELENGTH)
PUB_BUFFER.fill(0)
- memory.copy(changetype<usize>(verify_pub), changetype<usize>(SIGNATURE_BUFFER), KEY_BYTELENGTH)
+ memory.copy(changetype<usize>(verify_blocks_pub), changetype<usize>(SIGNATURE_BUFFER), KEY_BYTELENGTH)
SIGNATURE_BUFFER.fill(0)
// Verify message from buffer, then clear local input
- const verified = crypto_verify_relaxed(verify_sig, MESSAGE_BUFFER, mlen, verify_pub)
+ const verified = crypto_verify_relaxed(verify_blocks_sig, MESSAGE_BUFFER, mlen, verify_blocks_pub)
MESSAGE_BUFFER.fill(0)
- verify_pub.fill(0)
- verify_sig.fill(0)
+ verify_blocks_pub.fill(0)
+ verify_blocks_sig.fill(0)
// Output buffer not used, so just return
return verified