Skip to content

feat: WASM based checks#1684

Open
Xe wants to merge 60 commits into
mainfrom
Xe/wasm4
Open

feat: WASM based checks#1684
Xe wants to merge 60 commits into
mainfrom
Xe/wasm4

Conversation

@Xe

@Xe Xe commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Closes #283
Closes #1116
Closes #1159
Replaces #1151

Adds argon2id and sha256 WASM based checks. These checks run faster than JavaScript can and will use exponentially less memory on both client and server:

=== RUN   TestAlgos/argon2id.wasm
    wasm_test.go:50: used 333 pages of wasm memory (21102592 bytes)
=== RUN   TestAlgos/sha256.wasm
    wasm_test.go:50: used 18 pages of wasm memory (1179648 bytes)
=== RUN   TestAlgos/argon2id.wasm#01
    wasm_test.go:50: used 333 pages of wasm memory (21102592 bytes)
=== RUN   TestAlgos/sha256.wasm#01
    wasm_test.go:50: used 18 pages of wasm memory (1179648 bytes)

TODO:

  • Import Rust code
  • Wire up to config validation
  • Wire up in Browser JS
  • Test in a few browsers
  • Error message for clients without WASM telling them to enable WASM and that this is NOT an Anubis bug

I have been putting off finishing this due to some burnout and fear of retaliation from the privacy community.

Checklist:

  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Added test cases to the relevant parts of the codebase
  • Ran integration tests npm run test:integration (unsupported on Windows, please use WSL)
  • All of my commits have verified signatures

Xe added 4 commits June 15, 2026 15:54
I'm working on actually shipping this for real this time. In order to
get started, import all the existing logic from PR Xe/wasm3.

Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe self-assigned this Jun 15, 2026
Comment thread .github/workflows/asset-verification.yml Fixed
Comment thread .github/workflows/docker-pr.yml Fixed
Comment thread .github/workflows/docker.yml Fixed
Comment thread .github/workflows/go.yml Fixed
Comment thread .github/workflows/package-builds-stable.yml Fixed
Comment thread .github/workflows/package-builds-unstable.yml Fixed
Comment thread .github/workflows/smoke-tests.yml Fixed

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-spelling found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Xe and others added 21 commits June 15, 2026 16:15
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
… errors

Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
…github actions directly for reasons I hate

Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <xe.iaso@techaro.lol>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Assisted-by: Claude Opus 4.8 via Claude Code
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Xe added 6 commits June 16, 2026 11:46
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
There are a nontrivial fraction of hashx inputs that are unsolvable. Tor
handles this by just incrementing a padding byte until it gets a
solvable input. In spot testing, this seems to be rare (did not show up
given 2048 random inputs), but it's better to be defensive here by
incrementing a padding byte until it's solvable.

Also mend the commentary and some small remnants of things being
copy/pasted from the sha256 hash solver.

Signed-off-by: Xe Iaso <me@xeiaso.net>
This new check uses the bit shift operator to check if it's been at
least 1024 iterations, not a brittle if statement that I've found out
parses incorrectly.

Some commentary has been updated to better reflect reality.

Signed-off-by: Xe Iaso <me@xeiaso.net>
%w is preferred for wrapping errors in fmt.Errorf instead of passing the
value with %v.

Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe

Xe commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Check spelling results are known. Ignoring for now.

Comment thread docs/docs/admin/configuration/challenges/wasm.mdx Outdated
Comment thread web/js/algorithms/wasm.ts
throw new WASMUnsupportedError();
}

return new Promise(async (resolve, reject) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the fetch and WebAssembly.compileStreaming could raise, but aren't handled, therefore not rejecting the promise.

Xe added 9 commits June 17, 2026 16:47
Assisted-by: Claude Opus 4.8 via Claude Code
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe

Xe commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@Kurtoid I figured out how to obviate the need for wasm. I had to build parts of binaryen to webassembly with a script claude puzzled out and commit the resulting binaries to the repo, but this works enough. I'll write more about this in the near future. It's working in Chrome on my workstation at least.

@Xe

Xe commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Did a smoke test on an aarch64 system and found that hashx verification never terminates. Gonna remove hashx for now.

Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe

Xe commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Oh what it's the wazero compiler being broken on aarch64 somehow. I'm gonna disable it on GOOS=arm64.

Xe added 2 commits June 17, 2026 18:44
This reverts commit fb04172.

Signed-off-by: Xe Iaso <me@xeiaso.net>
Xe added 3 commits June 17, 2026 19:36
Signed-off-by: Xe Iaso <me@xeiaso.net>
Assisted-by: Claude Opus 4.8 via Claude Code
Signed-off-by: Xe Iaso <me@xeiaso.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants