]> git.codecow.com Git - libnemo.git/commitdiff
Replace another ternary operator.
authorChris Duncan <chris@zoso.dev>
Mon, 18 Aug 2025 15:05:04 +0000 (08:05 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 18 Aug 2025 15:05:04 +0000 (08:05 -0700)
src/lib/crypto/nano-nacl.ts

index 7598dac3aa964b4ef032b2438cae6a7170cbe6a9..225e50e932a02f23138562265a3427012dff6198 100644 (file)
@@ -346,7 +346,7 @@ export class NanoNaCl {
                this.modL(r, x)\r
        }\r
 \r
-       static unpackneg (r: Float64Array[], p: Uint8Array): -1 | 0 {\r
+       static unpackneg (r: Float64Array[], p: Uint8Array): number {\r
                const t: Float64Array = new Float64Array(16)\r
                const chk: Float64Array = new Float64Array(16)\r
                const num: Float64Array = new Float64Array(16)\r
@@ -378,7 +378,7 @@ export class NanoNaCl {
                this.Multiply(chk, chk, den)\r
 \r
                // if neq is true, multiply r[0] by I, else multiply by 1 for a no-op\r
-               const neq = this.neq25519(chk, num)\r
+               let neq = this.neq25519(chk, num)\r
                const I = new Float64Array(this.I)\r
                for (let i = 0; i < 16; i++) {\r
                        I[i] *= neq\r
@@ -389,11 +389,11 @@ export class NanoNaCl {
                this.Square(chk, r[0])\r
                this.Multiply(chk, chk, den)\r
 \r
-               const result = this.neq25519(chk, num) ? -1 : 0\r
+               neq = 0 - this.neq25519(chk, num)\r
 \r
                this.Subtract(this.par25519(r[0]) === (p[31] >> 7) ? r[0] : new Float64Array(16), new Float64Array(16), r[0])\r
                this.Multiply(r[3], r[0], r[1])\r
-               return result\r
+               return neq\r
        }\r
 \r
        static crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void {\r