]> git.codecow.com Git - nano25519.git/commitdiff
Reorder variables.
authorChris Duncan <chris@codecow.com>
Thu, 8 Oct 2026 15:44:42 +0000 (08:44 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 8 Oct 2026 15:44:42 +0000 (08:44 -0700)
scripts/blake2b-gen.mjs
src/assembly/ed25519/blake2b.ts

index feacf861a566a188200f08ee50b58442d0b46f02..528e98d87d345eb9a6982fe71facd7a4e41e16ed 100644 (file)
@@ -65,16 +65,16 @@ const DECLARATIONS = (() => {
        let output = `  /**
         * Buffers and counters
         * - b: input buffer, filled and refilled by input data in ${B_LENGTH} byte increments
-        * - c: buffer counter, points to current index in \`b\`
         * - h: chain buffer, updated after each compression
         * - p: set according to BLAKE2 layout from constructor arguments
+        * - c: buffer counter, points to current index in \`b\`
         * - t: total byte counter, incremented by \`c\`
         *   - Note: BLAKE2b reference supports 2¹²⁸-1, but this implementation restricts to 2⁶⁴-1 for compatibility with WASM without SIMD)
         */
        b: StaticArray<u8> = new StaticArray<u8>(${B_LENGTH})
-       c: u8 = 0
        h: StaticArray<u64> = new StaticArray<u64>(${H_LENGTH})
        p: StaticArray<u8> = new StaticArray<u8>(64)
+       c: u8 = 0
        t: u64 = 0
 `
        return output
@@ -82,9 +82,9 @@ const DECLARATIONS = (() => {
 
 function CLEAR () {
        let output = `          this.b.fill(0)
-               this.c = 0
                this.h.fill(0)
                this.p.fill(0)
+               this.c = 0
                this.t = 0
 `
 
index 3efa08e007dd1a2396bfcea100138bdd89f3442e..4d77d677ee8b0344330f3965721edf8dd0b475de 100644 (file)
@@ -5,24 +5,24 @@ export class Blake2b {
        /**
         * Buffers and counters
         * - b: input buffer, filled and refilled by input data in 128 byte increments
-        * - c: buffer counter, points to current index in `b`
         * - h: chain buffer, updated after each compression
         * - p: set according to BLAKE2 layout from constructor arguments
+        * - c: buffer counter, points to current index in `b`
         * - t: total byte counter, incremented by `c`
         *   - Note: BLAKE2b reference supports 2¹²⁸-1, but this implementation restricts to 2⁶⁴-1 for compatibility with WASM without SIMD)
         */
        b: StaticArray<u8> = new StaticArray<u8>(128)
-       c: u8 = 0
        h: StaticArray<u64> = new StaticArray<u64>(8)
        p: StaticArray<u8> = new StaticArray<u8>(64)
+       c: u8 = 0
        t: u64 = 0
 
        init (): Blake2b {
                // reset buffers and counters
                this.b.fill(0)
-               this.c = 0
                this.h.fill(0)
                this.p.fill(0)
+               this.c = 0
                this.t = 0
 
                // initialize parameter block
@@ -1037,9 +1037,9 @@ export class Blake2b {
 
                // clear internal buffers and counters
                this.b.fill(0)
-               this.c = 0
                this.h.fill(0)
                this.p.fill(0)
+               this.c = 0
                this.t = 0
 
                return