]> git.codecow.com Git - libnemo.git/commitdiff
Reorder functions.
authorChris Duncan <chris@zoso.dev>
Sun, 3 Aug 2025 22:08:05 +0000 (15:08 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 3 Aug 2025 22:08:05 +0000 (15:08 -0700)
src/lib/nano-nacl.ts

index f0aec9340aa99eefcd30facc61953da5a701953e..c0c283c1bccbcc0918b0700658b0f3873dd31460 100644 (file)
@@ -339,37 +339,6 @@ export class NanoNaCl {
                this.modL(r, x)\r
        }\r
 \r
-       static crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void {\r
-               const p: Float64Array[] = [new Float64Array(16), new Float64Array(16), new Float64Array(16), new Float64Array(16)]\r
-\r
-               const d = new Blake2b(64).update(sk).digest()\r
-               d[0] &= 248\r
-               d[31] &= 127\r
-               d[31] |= 64\r
-\r
-               sm.set(m.subarray(0, n), 64)\r
-               sm.set(d.subarray(32, 64), 32)\r
-\r
-               const r = new Blake2b(64).update(sm.subarray(32)).digest()\r
-               this.reduce(r)\r
-               this.scalarbase(p, r)\r
-               this.pack(sm, p)\r
-\r
-               sm.set(pk, 32)\r
-               const h = new Blake2b(64).update(sm).digest()\r
-               this.reduce(h)\r
-\r
-               const x = new Float64Array(64)\r
-               x.set(r.subarray(0, 32))\r
-               for (let i = 0; i < 32; i++) {\r
-                       for (let j = 0; j < 32; j++) {\r
-                               x[i + j] += h[i] * d[j]\r
-                       }\r
-               }\r
-\r
-               this.modL(sm.subarray(32), x)\r
-       }\r
-\r
        static unpackneg (r: Float64Array[], p: Uint8Array): -1 | 0 {\r
                const t: Float64Array = new Float64Array(16)\r
                const chk: Float64Array = new Float64Array(16)\r
@@ -414,6 +383,37 @@ export class NanoNaCl {
                return 0\r
        }\r
 \r
+       static crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void {\r
+               const p: Float64Array[] = [new Float64Array(16), new Float64Array(16), new Float64Array(16), new Float64Array(16)]\r
+\r
+               const d = new Blake2b(64).update(sk).digest()\r
+               d[0] &= 248\r
+               d[31] &= 127\r
+               d[31] |= 64\r
+\r
+               sm.set(m.subarray(0, n), 64)\r
+               sm.set(d.subarray(32, 64), 32)\r
+\r
+               const r = new Blake2b(64).update(sm.subarray(32)).digest()\r
+               this.reduce(r)\r
+               this.scalarbase(p, r)\r
+               this.pack(sm, p)\r
+\r
+               sm.set(pk, 32)\r
+               const h = new Blake2b(64).update(sm).digest()\r
+               this.reduce(h)\r
+\r
+               const x = new Float64Array(64)\r
+               x.set(r.subarray(0, 32))\r
+               for (let i = 0; i < 32; i++) {\r
+                       for (let j = 0; j < 32; j++) {\r
+                               x[i + j] += h[i] * d[j]\r
+                       }\r
+               }\r
+\r
+               this.modL(sm.subarray(32), x)\r
+       }\r
+\r
        static crypto_sign_open (m: Uint8Array, sm: Uint8Array, n: number, pk: Uint8Array): number {\r
                const t = new Uint8Array(32)\r
                const p: Float64Array[] = [new Float64Array(16), new Float64Array(16), new Float64Array(16), new Float64Array(16)]\r