]> git.codecow.com Git - nano25519.git/commitdiff
Fix documentation of constants.
authorChris Duncan <chris@zoso.dev>
Sat, 29 Aug 2026 06:47:19 +0000 (23:47 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 29 Aug 2026 06:47:19 +0000 (23:47 -0700)
src/assembly/index.ts
src/index.ts
src/lib/sign.ts

index f8ed6c66ae1d69dea208ea098f991fc9f6ff48bb..b827b8aa52cdf31d7e1aac7196784ea72713145d 100644 (file)
@@ -45,7 +45,7 @@ export function ptrInputSig (): usize {
        return changetype<usize>(INPUT_SIG)
 }
 
-/** Returns a pointer to the derive() static output buffer (64 bytes). */
+/** Returns a pointer to the derive() static output buffer (32 bytes). */
 export function ptrOutputDerive (): usize {
        return changetype<usize>(OUTPUT_DERIVE)
 }
@@ -97,7 +97,7 @@ export function derive (): void {
 }
 
 /**
- * Sign up to 32 KiB of data using a 64-byte secret key. Parameters are read as
+ * Sign up to 64 KiB of data using a 64-byte secret key. Parameters are read as
  * bytes from the input buffer in the following order:
  *
  * - `[0,31]: private key`
@@ -105,7 +105,7 @@ export function derive (): void {
  *
  * The message itself is read from a separate buffer. The signature is detached
  * from the message and written to the output buffer.
- * @param {i32} mlen Byte length of message to be signed, up to 32768
+ * @param {i32} mlen Byte length of message to be signed, up to 65536
  */
 export function sign (mlen: i32): void {
        // Clear output buffer so errors do not retain stale prior data
@@ -146,7 +146,7 @@ export function sign (mlen: i32): void {
 /**
  * Verify a 64-byte detached signature for a variable-length message against a
  * 32-byte public key. Input parameters are read as bytes from separate buffers.
- * @param {i32} mlen Byte length of message that was signed, up to 32768
+ * @param {i32} mlen Byte length of message that was signed, up to 65536
  * @returns {boolean} True if message was signed by public key's private key
  */
 export function verify (mlen: i32): void {
@@ -187,14 +187,14 @@ export function verify (mlen: i32): void {
  * concatenated value. The performance gain of verifying in bulk scales as
  * `(1-(1/n)) x (k/(k+r))` where `n` is block count, `k` is the time required to
  * verify the public key, and `r` is the time required to compute all the
- * remaining verification steps. Testing shows `k` to be ~8.5% the total
- * verification time, so batching up to 32 block signature/hash pairs reaches
+ * remaining verification steps. Testing shows `k` to be ~12% the total
+ * verification time, so batching up to 64 block signature/hash pairs reaches
  * ~96% of that gain; any more blocks would simply add latency returning the
  * final results.
  *
  * All pairs are verified against a single public key. The results are written
  * to the output buffer in the same order they were received.
- * @param {i32} count Number of signatures to verify, up to 32
+ * @param {i32} count Number of signatures to verify, up to 64
  */
 export function verify_blocks (count: i32): void {
        // Set all output to false so errors fail closed
index c4ef6a9051cc716c795390e369939ee71b07a4f7..8d00b9e64e8602ab0328b6bff767a93d3cdff29c 100644 (file)
@@ -32,7 +32,7 @@ export function derive (prv: string | Uint8Array<ArrayBuffer>, out?: Uint8Array<
 /**
  * Signing using WebAssembly. To sign Nano blocks, the message should be a
  * 32-byte block hash.
- * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 32 KiB
+ * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 64 KiB
  * @param {Uint8Array<ArrayBuffer>} prv - 32-byte private key
  * @param {Uint8Array<ArrayBuffer>} pub - 32-byte public key
  * @returns 64-byte detached signature
@@ -41,7 +41,7 @@ export function sign (msg: Uint8Array<ArrayBuffer>, prv: Uint8Array<ArrayBuffer>
 /**
  * Signing using WebAssembly. To sign Nano blocks, the message should be a
  * 64-character hexadecimal block hash.
- * @param {string} msg - Variable-length hexadecimal message up to 32 KiB
+ * @param {string} msg - Variable-length hexadecimal message up to 64 KiB
  * @param {string} prv - 64-character hexadecimal private key
  * @param {string} pub - 64-character hexadecimal public key
  * @returns 128-character hexadecimal detached signature
@@ -52,7 +52,7 @@ export function sign (msg: string, prv: string, pub: string): string
  * 32-byte block hash. Instead of allocating an output buffer internally for the
  * return value, signature bytes are written to the the user-supplied output
  * buffer.
- * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 32 KiB
+ * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 64 KiB
  * @param {Uint8Array<ArrayBuffer>} prv - 32-byte private key
  * @param {Uint8Array<ArrayBuffer>} pub - 32-byte public key
  * @param {Uint8Array<ArrayBuffer>} out - buffer to receive 64-byte detached signature
@@ -66,7 +66,7 @@ export function sign (msg: string | Uint8Array<ArrayBuffer>, prv: string | Uint8
  * Signature verification using WebAssembly. To verify Nano block signatures,
  * use `verify_blocks()` instead.
  * @param {Uint8Array<ArrayBuffer>} sig - 64-byte detached signature
- * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 32 KiB
+ * @param {Uint8Array<ArrayBuffer>} msg - Variable-byte-length message up to 64 KiB
  * @param {Uint8Array<ArrayBuffer>} pub - 32-byte public key
  * @returns true if signature matches block hash and public key, else false
  */
@@ -75,7 +75,7 @@ export function verify (sig: Uint8Array<ArrayBuffer>, msg: Uint8Array<ArrayBuffe
  * Signature verification using WebAssembly. To verify Nano block signatures,
  * the message should be a 64-character block hash.
  * @param {string} sig - 128-character hexadecimal detached signature
- * @param {string} msg - Variable-length message up to 32 KiB
+ * @param {string} msg - Variable-length message up to 64 KiB
  * @param {string} pub - 64-character hexadecimal public key
  * @returns true if signature matches block hash and public key, else false
  */
@@ -87,7 +87,7 @@ export function verify (sig: string | Uint8Array<ArrayBuffer>, msg: string | Uin
 /**
  * Nano block signature bulk verification using WebAssembly.
  * @param {Uint8Array<ArrayBuffer>} publicKey - 32-byte public key
- * @param {object[]} blocks - Array of up to 32 block signature/hash pairs
+ * @param {object[]} blocks - Array of up to 64 block signature/hash pairs
  * @param {Uint8Array<ArrayBuffer>} blocks.signature - 64-byte block signature
  * @param {Uint8Array<ArrayBuffer>} blocks.hash - 32-byte block hash
  * @returns Array of results with, for each case, true if signature matches block hash and public key, else false
@@ -96,7 +96,7 @@ export function verify_blocks (publicKey: Uint8Array<ArrayBuffer>, blocks: { has
 /**
  * Nano block signature bulk verification using WebAssembly.
  * @param {string} publicKey - 64-character hexadecimal public key
- * @param {object[]} blocks - Array of up to 32 block signature/hash pairs
+ * @param {object[]} blocks - Array of up to 64 block signature/hash pairs
  * @param {string} blocks.signature - 128-character hexadecimal block signature
  * @param {string} blocks.hash - 64-character hexadecimal block hash
  * @returns Array of results with, for each case, true if signature matches block hash and public key, else false
index 9b543e7bfea8929b5e95cd0f029516743a3f2a4f..832e5a51701475bd6d8713718f88bcf42bd4a8db 100644 (file)
@@ -7,8 +7,8 @@ const { KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, SIGNATURE_BYTELENGTH, } = consta
 const { INPUT_MSG, INPUT_PRV, INPUT_PUB, OUTPUT_SIGN, } = pointers
 
 export function sign (msg: unknown, prv: unknown, pub: unknown, out?: unknown): string | Uint8Array<ArrayBuffer> | void {
-       if (typeof out !== 'undefined' && !(isBytes(out) && out.byteLength === 64)) {
-               throw new TypeError('Sign output buffer must be 64-byte Uint8Array<ArrayBuffer>')
+       if (typeof out !== 'undefined' && !(isBytes(out) && out.byteLength === SIGNATURE_BYTELENGTH)) {
+               throw new TypeError(`Sign output buffer must be ${SIGNATURE_BYTELENGTH}-byte Uint8Array<ArrayBuffer>`)
        }
        const message = normalize('message', 0, MAX_MESSAGE_BYTELENGTH, msg)
        const privateKey = normalize('private key', KEY_BYTELENGTH, KEY_BYTELENGTH, prv)