From: Chris Duncan Date: Thu, 8 Oct 2026 15:44:42 +0000 (-0700) Subject: Reorder variables. X-Git-Tag: v2.0.0~2^2~9 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=0bdf0bf1f7bc59df41673dda9091c73e4f988857;p=nano25519.git Reorder variables. --- diff --git a/scripts/blake2b-gen.mjs b/scripts/blake2b-gen.mjs index feacf86..528e98d 100644 --- a/scripts/blake2b-gen.mjs +++ b/scripts/blake2b-gen.mjs @@ -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 = new StaticArray(${B_LENGTH}) - c: u8 = 0 h: StaticArray = new StaticArray(${H_LENGTH}) p: StaticArray = new StaticArray(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 ` diff --git a/src/assembly/ed25519/blake2b.ts b/src/assembly/ed25519/blake2b.ts index 3efa08e..4d77d67 100644 --- a/src/assembly/ed25519/blake2b.ts +++ b/src/assembly/ed25519/blake2b.ts @@ -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 = new StaticArray(128) - c: u8 = 0 h: StaticArray = new StaticArray(8) p: StaticArray = new StaticArray(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