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

index 225e50e932a02f23138562265a3427012dff6198..7417d0581dab875139da18cb9ad9f5d0c9edff20 100644 (file)
@@ -391,7 +391,12 @@ export class NanoNaCl {
 \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
+               // if par25519, subtract r[0] from 0 to swap sign, else keep current values\r
+               //@ts-expect-error\r
+               const par = (this.par25519(r[0]) === p[31] >> 7) ^ 1\r
+               for (let i = 0; i < 16; i++) {\r
+                       r[0][i] = (2 * par * r[0][i]) - r[0][i]\r
+               }\r
                this.Multiply(r[3], r[0], r[1])\r
                return neq\r
        }\r