]> git.codecow.com Git - nano25519.git/commitdiff
Strip extra newlines from generator output.
authorChris Duncan <chris@codecow.com>
Wed, 30 Sep 2026 14:18:02 +0000 (07:18 -0700)
committerChris Duncan <chris@codecow.com>
Wed, 30 Sep 2026 14:18:02 +0000 (07:18 -0700)
scripts/fe.gen.mjs
scripts/index.mjs

index 41e1b3e45d916224ff98bf0182e8146c08040fea..9dc9f06b98b5879e691d1228e0393acc8224feb6 100644 (file)
@@ -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
+ *             }
  *     }
  * }
  * \`\`\`
index 490e3a19a0a92ba6ee0d9aab92934701cc1fa246..06f7885e912bae652e0a5008db87c6736ddb6850 100644 (file)
@@ -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))