From: Chris Duncan Date: Tue, 1 Sep 2026 05:53:28 +0000 (-0700) Subject: Fix terminology. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=900744b3d49d0013acfe55adad895d0805916785;p=nano25519.git Fix terminology. --- diff --git a/src/assembly/crypto_sign.ts b/src/assembly/crypto_sign.ts index a6605ce..cfc9523 100644 --- a/src/assembly/crypto_sign.ts +++ b/src/assembly/crypto_sign.ts @@ -4,7 +4,6 @@ import { KEY_BYTELENGTH } from '.' import { Blake2b } from './blake2b' import { crypto_derive } from './crypto_derive' -import { errors } from './errors' import { ge_scalarmult_base_tobytes } from './ge' import { sc_muladd, sc_reduce } from './sc' import { clamp } from './utils' @@ -28,7 +27,7 @@ const S = new StaticArray(64) * In this implementation, both the private key and the public key are required. * This ensures the user has a full correct keypair for data integrity. It also * offers a small performance improvement in the case of an invalid public key - * by throwing early and avoiding expensive point multiplication; RFC 8032 + * by returning early and avoiding expensive point multiplication; RFC 8032 * indicates the public key should be recomputed from the private key when * signing anyway, so there is no penalty for checking key validity first. * @@ -41,12 +40,13 @@ const S = new StaticArray(64) * @param {StaticArray} pub 32-byte public key from input buffer */ export function crypto_sign (RS: StaticArray, M: StaticArray, mlen: i32, prv: StaticArray, pub: StaticArray): i32 { - // Derive `A` from private key and throw if it does not match public key + // Derive `A` from private key crypto_derive(A, prv) let c = 0 for (let i = 0; i < KEY_BYTELENGTH; i++) { c |= A[i] ^ pub[i] } + // Return early if `A` does not match public key if (c != 0) return 1 // Hash private key to `h` @@ -87,6 +87,6 @@ export function crypto_sign (RS: StaticArray, M: StaticArray, mlen: i32, R.fill(0) memory.copy(changetype(RS) + 32, changetype(S), 32) S.fill(0) - + return 0 } diff --git a/src/assembly/index.ts b/src/assembly/index.ts index 67fbdc5..278d5a1 100644 --- a/src/assembly/index.ts +++ b/src/assembly/index.ts @@ -136,8 +136,8 @@ export function sign (mlen: i32): void { prv.fill(0) pub.fill(0) INPUT_MSG.fill(0) - - // Clear signature output buffer if signing failed + + // Clear signature output buffer if signing failed if (result != 0) { OUTPUT_SIGN.fill(0) throw new Error(errors[result])