]> git.codecow.com Git - nano25519.git/commitdiff
Update verify documentation and separate function variables.
authorChris Duncan <chris@codecow.com>
Tue, 25 Aug 2026 18:41:13 +0000 (11:41 -0700)
committerChris Duncan <chris@codecow.com>
Tue, 25 Aug 2026 18:41:13 +0000 (11:41 -0700)
src/assembly/index.ts

index 4e4e2c55f71cabeac1bea4d6a66a5824c0ec971c..5027c5f9f8617f9dde8de66e08c9fe38b8d80819 100644 (file)
@@ -129,13 +129,7 @@ const verify_pub = new StaticArray<u8>(KEY_BYTELENGTH)
 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
  */
@@ -172,14 +166,10 @@ const verify_blocks_pub = new StaticArray<u8>(KEY_BYTELENGTH)
 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
  */
@@ -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<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