From: Chris Duncan Date: Tue, 25 Aug 2026 18:41:13 +0000 (-0700) Subject: Update verify documentation and separate function variables. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=89f502e67e574d4dca4c1778c56bd390fe032619;p=nano25519.git Update verify documentation and separate function variables. --- diff --git a/src/assembly/index.ts b/src/assembly/index.ts index 4e4e2c5..5027c5f 100644 --- a/src/assembly/index.ts +++ b/src/assembly/index.ts @@ -129,13 +129,7 @@ const verify_pub = new StaticArray(KEY_BYTELENGTH) const verify_sig = new StaticArray(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 */ @@ -172,14 +166,10 @@ const verify_blocks_pub = new StaticArray(KEY_BYTELENGTH) const verify_blocks_sig = new StaticArray(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 */ @@ -192,20 +182,20 @@ export function verify_blocks (mlen: i32): i32 { } // 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(verify_sig), changetype(PUB_BUFFER), SIGNATURE_BYTELENGTH) + memory.copy(changetype(verify_blocks_sig), changetype(PUB_BUFFER), SIGNATURE_BYTELENGTH) PUB_BUFFER.fill(0) - memory.copy(changetype(verify_pub), changetype(SIGNATURE_BUFFER), KEY_BYTELENGTH) + memory.copy(changetype(verify_blocks_pub), changetype(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