From: Chris Duncan Date: Wed, 30 Sep 2026 14:18:02 +0000 (-0700) Subject: Strip extra newlines from generator output. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d44aac9bc614e5de8ba502c1692156c9a1ac0f69;p=nano25519.git Strip extra newlines from generator output. --- diff --git a/scripts/fe.gen.mjs b/scripts/fe.gen.mjs index 41e1b3e..9dc9f06 100644 --- a/scripts/fe.gen.mjs +++ b/scripts/fe.gen.mjs @@ -49,8 +49,8 @@ import { load_3, load_4, sodium_is_zero } from './utils' * two reasons: * 1. There is no vectorized 64-bit data type in Wasm, only 128-bit, so \`v128\` * must be used in the form of \`i32x4\` to achieve SIMD parallelism, and - * 2. \`i32x4.load\` will load lanes \`[0, 1]\` for elements [8,9] just fine but - * risks retrieving garbage data for lanes \`[2, 3]\` from some other chunk of + * 2. \`i32x4.load\` will load lanes \`[0,1]\` for elements [8,9] just fine but + * risks retrieving garbage data for lanes \`[2,3]\` from some other chunk of * memory if it is not allocated to this FieldElement, so elements [10,11] are * reserved, initialized to zero, and simply ignored throughout computation. */ @@ -720,16 +720,16 @@ export function fe_reduce (h: FieldElement, f: FieldElement): void { * Square a FieldElement and store the result. * * Some iterations of the inner loop can be skipped since - * \`f[x] * f[y] + f[y] * f[x] = 2 * f[x] * f[y]\` + * \`f[x]*f[y] + f[y]*f[x] = 2*f[x]*f[y]\` * * \`\`\` - * // non-constant-time example + * // non-constant-time example * for (let i = 0; i < 10; i++) { * for (let j = i; j < 10; j++) { - * h[i + j] += f[i] * g[j] - * if (i < j) { - * h[i + j] *= 2 - * } + * h[i + j] += f[i] * g[j] + * if (i < j) { + * h[i + j] *= 2 + * } * } * } * \`\`\` @@ -913,16 +913,16 @@ export function fe_sq (h: FieldElement, f: FieldElement): void { * Square a FieldElement and store the result. * * Some iterations of the inner loop can be skipped since - * \`f[x] * f[y] + f[y] * f[x] = 2 * f[x] * f[y]\` + * \`f[x]*f[y] + f[y]*f[x] = 2*f[x]*f[y]\` * * \`\`\` - * // non-constant-time example + * // non-constant-time example * for (let i = 0; i < 10; i++) { * for (let j = i; j < 10; j++) { - * h[i + j] += f[i] * g[j] - * if (i < j) { - * h[i + j] *= 2 - * } + * h[i + j] += f[i] * g[j] + * if (i < j) { + * h[i + j] *= 2 + * } * } * } * \`\`\` diff --git a/scripts/index.mjs b/scripts/index.mjs index 490e3a1..06f7885 100644 --- a/scripts/index.mjs +++ b/scripts/index.mjs @@ -17,7 +17,10 @@ import { FE } from './fe.gen.mjs' import { GE } from './ge.gen.mjs' import { P } from './p.gen.mjs' -await writeFile('src/assembly/ed25519/blake2b.ts', BLAKE2b) -// await writeFile('src/assembly/ed25519/fe.ts', FE) -// await writeFile('src/assembly/ed25519/ge.ts', GE) -// await writeFile('src/assembly/ed25519/p.ts', P) +/** @type {(s: string) => any} */ +const stripNewline = s => s.replaceAll(/\n(\s*\n){2,}/gm, '\n\n') + +await writeFile('src/assembly/ed25519/blake2b.ts', stripNewline(BLAKE2b)) +// await writeFile('src/assembly/ed25519/fe.ts', stripNewline(FE)) +// await writeFile('src/assembly/ed25519/ge.ts', stripNewline(GE)) +// await writeFile('src/assembly/ed25519/p.ts', stripNewline(P))