Build tooling and new recovery phrases use cryptography outside ethers #758

Open
opened 2026-11-10 20:54:18 +01:00 by clawbot · 1 comment
Collaborator

Three places use cryptography outside ethers and libsodium-wrappers-sumo:

  • build.js hashes the files it writes for the build receipt with Node's crypto.createHash("sha256");
  • script/lib/package.js hashes the release files for SHA256SUMS the same way;
  • generateMnemonic() in src/shared/wallet.js takes the entropy for a new recovery phrase from globalThis.crypto.getRandomValues().

The rule: RULES.md Cryptography, "All crypto goes through ethers or libsodium-wrappers-sumo" and "No exceptions without an explicit code comment citing the Crypto Policy". sneak's Crypto Policy in README.md: "All cryptographic operations must go through ethers or libsodium-wrappers-sumo. Exceptions require explicit authorization in a code comment referencing this policy, but as of now there are none."

Found in the RULES.md read on #672 (comment).

Fix

  • build.js and script/lib/package.js: hash with sha256 from ethers. The output stays lowercase hex without the 0x prefix, so the receipt and SHA256SUMS keep their format. Drop the crypto require where nothing else uses it.
  • generateMnemonic(): entropy from randomBytes(16) from ethers. The DEBUG branch and its comment stay as they are.
  • No exception comments: nothing is left that needs one.

Definition of done

  • grep finds no createHash, getRandomValues or require("crypto") in build.js, script/ or src/.
  • make build, make package and their checks give the same receipt and SHA256SUMS format; existing tests stay green. Add a test only where none covers a changed line (for example, SHA256SUMS lines match sha256sum output for a fixture file).
  • make check green. Gate runs: flock -w 3600 /srv/code/tmp/.autistmask-gate.lock script/cibuild.

Model: opus-5-5

Three places use cryptography outside `ethers` and `libsodium-wrappers-sumo`: - `build.js` hashes the files it writes for the build receipt with Node's `crypto.createHash("sha256")`; - `script/lib/package.js` hashes the release files for `SHA256SUMS` the same way; - `generateMnemonic()` in `src/shared/wallet.js` takes the entropy for a new recovery phrase from `globalThis.crypto.getRandomValues()`. The rule: `RULES.md` Cryptography, "All crypto goes through `ethers` or `libsodium-wrappers-sumo`" and "No exceptions without an explicit code comment citing the Crypto Policy". sneak's Crypto Policy in `README.md`: "All cryptographic operations must go through `ethers` or `libsodium-wrappers-sumo`. Exceptions require explicit authorization in a code comment referencing this policy, but as of now there are none." Found in the `RULES.md` read on https://git.eeqj.de/sneak/AutistMask/issues/672#issuecomment-160312. ## Fix - `build.js` and `script/lib/package.js`: hash with `sha256` from `ethers`. The output stays lowercase hex without the `0x` prefix, so the receipt and `SHA256SUMS` keep their format. Drop the `crypto` require where nothing else uses it. - `generateMnemonic()`: entropy from `randomBytes(16)` from `ethers`. The DEBUG branch and its comment stay as they are. - No exception comments: nothing is left that needs one. ## Definition of done - `grep` finds no `createHash`, `getRandomValues` or `require("crypto")` in `build.js`, `script/` or `src/`. - `make build`, `make package` and their checks give the same receipt and `SHA256SUMS` format; existing tests stay green. Add a test only where none covers a changed line (for example, `SHA256SUMS` lines match `sha256sum` output for a fixture file). - `make check` green. Gate runs: `flock -w 3600 /srv/code/tmp/.autistmask-gate.lock script/cibuild`. Model: opus-5-5
clawbot self-assigned this 2026-11-10 20:54:18 +01:00
clawbot added this to the 1.0.0 milestone 2026-11-10 20:54:24 +01:00
Author
Collaborator

Fixed in #767. build.js and script/lib/package.js now hash with sha256 from ethers, and generateMnemonic() uses randomBytes from ethers. The README Crypto policy no longer lists them as exceptions. A test now covers the SHA256SUMS hash.

The first gate run failed once because jest force-stopped a worker that a test had left an open handle in. That is unrelated to this change and is filed as #766.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/AutistMask/pulls/767. `build.js` and `script/lib/package.js` now hash with `sha256` from `ethers`, and `generateMnemonic()` uses `randomBytes` from `ethers`. The README Crypto policy no longer lists them as exceptions. A test now covers the `SHA256SUMS` hash. The first gate run failed once because jest force-stopped a worker that a test had left an open handle in. That is unrelated to this change and is filed as https://git.eeqj.de/sneak/AutistMask/issues/766. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#758