From: Chris Duncan Date: Wed, 13 Aug 2025 16:33:24 +0000 (-0700) Subject: Privatize vn method and deprecate wrapper method. X-Git-Tag: v0.10.5~41^2~108 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=2f85b33e56d6ef0b7b8aa6e7e5c05fc34396fbee;p=libnemo.git Privatize vn method and deprecate wrapper method. --- diff --git a/src/lib/crypto/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts index e23bdd6..c50116b 100644 --- a/src/lib/crypto/nano-nacl.ts +++ b/src/lib/crypto/nano-nacl.ts @@ -26,7 +26,7 @@ export class NanoNaCl { static I: Float64Array = new Float64Array([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]) static XY: Float64Array = new Float64Array([0xdd90, 0xa5b7, 0x8ab3, 0x6dde, 0x52f5, 0x7751, 0x9f80, 0x20f0, 0xe37d, 0x64ab, 0x4e8e, 0x66ea, 0x7665, 0xd78b, 0x5f0f, 0xe787]) - static vn (x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number): number { + static #vn (x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number): number { let d = 0 for (let i = 0; i < n; i++) { d |= x[xi + i] ^ y[yi + i] @@ -34,10 +34,6 @@ export class NanoNaCl { return (1 & ((d - 1) >>> 8)) - 1 } - static crypto_verify_32 (x: Uint8Array, xi: number, y: Uint8Array, yi: number): number { - return this.vn(x, xi, y, yi, 32) - } - static pow2523 (o: Float64Array, i: Float64Array): void { const c: Float64Array = new Float64Array(16) c.set(i.subarray(0, 16), 0) @@ -77,7 +73,7 @@ export class NanoNaCl { const d = new Uint8Array(32) this.pack25519(c, a) this.pack25519(d, b) - return this.crypto_verify_32(c, 0, d, 0) + return this.#vn(c, 0, d, 0, 32) } static pack25519 (o: Uint8Array, n: Float64Array): void { @@ -429,7 +425,7 @@ export class NanoNaCl { this.pack(t, p) n -= 64 - if (this.crypto_verify_32(sm, 0, t, 0)) { + if (this.#vn(sm, 0, t, 0, 32)) { m.fill(0, 0, n) return -1 }