Skip to content

feat: add non-SHA256 proof of work challenge method#1151

Closed
Xe wants to merge 27 commits into
mainfrom
Xe/wasm3
Closed

feat: add non-SHA256 proof of work challenge method#1151
Xe wants to merge 27 commits into
mainfrom
Xe/wasm3

Conversation

@Xe

@Xe Xe commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

Closes #283
Closes #1116
Closes #1159

  • Base implementation in Rust
  • Base implementation in the client
  • Add Rust to the build closure in CI
  • Fix package builds in CI
  • Fix smoke tests
  • Documentation
  • Add wasm feature detection to choose between baseline and simd128
  • Find a better algorithm than argon2id

This adds Rust to the build closure of Anubis. Any complaints about this will be deleted.

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 Xe self-assigned this Sep 23, 2025

@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.

@awilfox

awilfox commented Sep 23, 2025

Copy link
Copy Markdown

This adds Rust to the build closure of Anubis. Any complaints about this will be deleted.

Yes hello I would like to complain about the fact it still uses Go. Can't the rest of it be rewritten in Rust, so it can be more portable?

@Xe

Xe commented Sep 23, 2025

Copy link
Copy Markdown
Contributor Author

This adds Rust to the build closure of Anubis. Any complaints about this will be deleted.

Yes hello I would like to complain about the fact it still uses Go. Can't the rest of it be rewritten in Rust, so it can be more portable?

With enough money, anything is possible :)

Signed-off-by: Xe Iaso <me@xeiaso.net>
Xe added 4 commits September 27, 2025 18:33
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>
Comment thread .github/workflows/docker.yml Fixed
Comment thread .github/workflows/rust.yml Dismissed
Comment thread .github/workflows/rust.yml Fixed
Comment thread .github/workflows/rust.yml Fixed
Xe added 9 commits September 28, 2025 02:45
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>
…ng to go to bed

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

Xe commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

Update: wasm2js has a weird bug involving parsing the output of the Rust compiler. Gonna debug tomorrow when I'm not dog tired. I may need help from a WebAssembly expert on this.

@Xe

Xe commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

Trying this instead: https://www.npmjs.com/package/webassemblyjs

@Xe

Xe commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author
Screenshot 2025-09-28 at 10 46 22

This both requires a nightly compiler (to build this with the "MVP" CPU target, or without bulk memory instructions), and doesn't work.

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

Xe commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

I broke the pure JS flow out into #1159.

Closes #1159

This uses the binaryen tool wasm2js to compile the Anubis WASM blobs
to JavaScript. This produces biblically large (520Ki) outputs when you
inline both hashx and sha256 solvers, but this is a tradeoff that I'm
willing to accept. The performance is good enough in my testing with
JIT enabled. I fear that this may end up being terrible with JIT
disabled. I have no idea if this will work on big endian or not.

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

Xe commented Sep 30, 2025

Copy link
Copy Markdown
Contributor Author

Aha! I figured it out! I have to use wasm2js on the "baseline" build. This causes everything to work correctly.

Xe added 2 commits September 30, 2025 14:27
Signed-off-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Xe added 2 commits September 30, 2025 14:30
check-spelling run (pull_request) for Xe/wasm3

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Comment thread wasm/pow/hashx/src/lib.rs Fixed
Comment thread wasm/pow/sha256/run.js
}

// Example usage:
const data = hexToUint8Array("98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4");

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern (sha-... -- uses a fancy capture) (\?['\"]|")[0-9a-f]{40,}\\g{-1}
Comment thread wasm/pow/sha256/run.js
}

// Example usage:
const data = hexToUint8Array("98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4");

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern (hex runs) \\b[0-9a-fA-F]{16,}\\b
Comment thread wasm/pow/sha256/src/lib.rs Fixed
Xe added 4 commits September 30, 2025 14:39
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>
Comment thread docs/docs/admin/configuration/challenges/wasm.mdx Dismissed

:::note

The difficulty values for the WebAssembly based checks are going to be much higher than the equivalent difficulty values for the [JavaScript based checks](./proof-of-work.mdx). Generally these count the number of leading _bits_ that much match instead of the number of leading _nibbles_ that must match. Here's a rough translation table:

Check failure

Code scanning / check-spelling

Forbidden Pattern Error documentation

higher than matches a line_forbidden.patterns rule: Should be 'greater than' - '\\bhigher than\\b'

:::note

This is included mostly as a fallback for usecases that specifically require this hashing function. There are known tools that solve this particular challenge. Prefer [hashx](#hashx) unless you know what you are doing.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error documentation

usecases is not a recognized word
Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe marked this pull request as ready for review September 30, 2025 21:03
Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe changed the title feat: add wasm rigging feat: add non-SHA256 proof of work challenge method Sep 30, 2025
Signed-off-by: Xe Iaso <me@xeiaso.net>
@s5bug

s5bug commented Jun 15, 2026

Copy link
Copy Markdown

What's left to do here (or new now that there's conflicts)?

@Xe

Xe commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

There are a bunch of things I need to do in order to better rethink how this should work. I'm going to start from a fresh fork and publish it as Xe/wasm4. There's been private/offline experimentation and load testing that has informed the designs at play.

@Xe Xe mentioned this pull request Jun 15, 2026
9 tasks
@Xe

Xe commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

moved to #1684

@Xe Xe closed this Jun 15, 2026
@s5bug

s5bug commented Jun 15, 2026

Copy link
Copy Markdown

Awesome, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants