From: Chris Duncan Date: Mon, 18 Aug 2025 15:05:04 +0000 (-0700) Subject: Replace another ternary operator. X-Git-Tag: v0.10.5~41^2~72 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=88466c49ca7b938534498e78941d5ddd7d686b14;p=libnemo.git Replace another ternary operator. --- diff --git a/src/lib/crypto/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts index 7598dac..225e50e 100644 --- a/src/lib/crypto/nano-nacl.ts +++ b/src/lib/crypto/nano-nacl.ts @@ -346,7 +346,7 @@ export class NanoNaCl { this.modL(r, x) } - static unpackneg (r: Float64Array[], p: Uint8Array): -1 | 0 { + static unpackneg (r: Float64Array[], p: Uint8Array): number { const t: Float64Array = new Float64Array(16) const chk: Float64Array = new Float64Array(16) const num: Float64Array = new Float64Array(16) @@ -378,7 +378,7 @@ export class NanoNaCl { this.Multiply(chk, chk, den) // if neq is true, multiply r[0] by I, else multiply by 1 for a no-op - const neq = this.neq25519(chk, num) + let neq = this.neq25519(chk, num) const I = new Float64Array(this.I) for (let i = 0; i < 16; i++) { I[i] *= neq @@ -389,11 +389,11 @@ export class NanoNaCl { this.Square(chk, r[0]) this.Multiply(chk, chk, den) - const result = this.neq25519(chk, num) ? -1 : 0 + neq = 0 - this.neq25519(chk, num) this.Subtract(this.par25519(r[0]) === (p[31] >> 7) ? r[0] : new Float64Array(16), new Float64Array(16), r[0]) this.Multiply(r[3], r[0], r[1]) - return result + return neq } static crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void {