Skip to content

Conversation

Xe
Copy link
Contributor

@Xe Xe commented Sep 23, 2025

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
Copy link

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

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
Copy link

awilfox commented Sep 23, 2025

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
Copy link
Contributor Author

Xe commented Sep 23, 2025

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 <[email protected]>
@Xe
Copy link
Contributor Author

Xe commented Sep 28, 2025

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
Copy link
Contributor Author

Xe commented Sep 28, 2025

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

@Xe
Copy link
Contributor Author

Xe commented Sep 28, 2025

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.

@Xe
Copy link
Contributor Author

Xe commented Sep 28, 2025

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 <[email protected]>
@Xe
Copy link
Contributor Author

Xe commented Sep 30, 2025

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:30
check-spelling run (pull_request) for Xe/wasm3

Signed-off-by: check-spelling-bot <[email protected]>
on-behalf-of: @check-spelling <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
}

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

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern (\?['\"]|")[0-9a-f]{40,}\\g{-1} (candidate-pattern)
}

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

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern \\b[0-9a-fA-F]{16,}\\b (candidate-pattern)

Anubis offers the following WebAssembly proof of work functions:

- [hashx](#hashx) (via the [`hashx`](https://docs.rs/hashx/latest/hashx/index.html) crate)

Check warning

Code scanning / check-spelling

Candidate Pattern Warning documentation

Line matches candidate pattern (#\\S*?[a-zA-Z]\\S*?) (candidate-pattern)

:::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 entry: "\\bhigher than\\b". (forbidden-pattern)

:::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. (unrecognized-spelling)
Signed-off-by: Xe Iaso <[email protected]>
@Xe Xe marked this pull request as ready for review September 30, 2025 21:03
@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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants