Wraps the chain's own crypto crates for the browser: qp-rusty-crystals-dilithium
(ML-DSA-65 and ML-DSA-87), qp-poseidon-core for the account-id hash, and
qp-rusty-crystals-hdwallet for BIP44 derivation. Nothing is reimplemented — a
browser wallet that disagreed with the chain about a key or a signature would
emit well-formed output the chain rejects, with nothing on this side able to
tell.
A separate crate rather than more files in wasm-crypto, because the two cannot
share a Cargo graph. wasm-crypto builds with nightly-2022-06-24 against a
2019-era dependency set; the ML-DSA crates use inline `const {}` blocks that
need Rust >= 1.79. Bumping the older one would mean rewriting upstream's
sr25519/ed25519 build, which is the thing most worth leaving alone so rebases
stay boring. wasm-crypto is untouched here.
The scheme selector is the chain's own signature-enum variant index (0 for
ML-DSA-87, 1 for ML-DSA-65), so the number threaded through this API is the
byte that ends up on the wire and there is no mapping to get backwards. Key and
signature sizes are exported rather than left for JS to hardcode: they are
consensus-critical and a drifted constant would mis-frame every byte after the
signature while looking healthy.
Logic is split from the #[wasm_bindgen] wrappers because JsError cannot be
constructed off-wasm, which made every error path untestable by cargo test —
and the error paths are what most needs testing.
Verified against the `quantus` CLI 2.2.2 as an independent oracle, not against
our own output: the three dev-genesis account ids, and HD derivation at both
schemes' default paths from the public Substrate dev phrase. Context separation
is pinned too — a signature made under QUANTUS_EXTRINSIC must not verify under
the empty context, which is what makes the spec-148 boundary detectable rather
than a silent chain rejection.
Refs quantus/wasm#1
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uDUodEcRbBwNRi3UCmw8f
* chore: revert asm build
* chore: revert info in build-wasm.sh
* chore: revert install-build-deps.sh
* chore: lock libc version
* chore: lock libc version in xargo
* chore: use --locked while building
* Fix: Switch `RUST_VER` to 1.63.0-nightly
* chore(CI): revert continue-on-error to false
* Revert "chore(CI): revert continue-on-error to false"
This reverts commit 425a93ea4d6c18e94ca04a0142818dd440442182.
---------
Co-authored-by: Francisco Valentim Castilho <franciscoannyon@gmail.com>
* run CI
* run CI
* setup nightly as default
* install nightly-2024-11-22
* rustup show
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* get rust versions
* modify build-wasm
* switch to nightly on build-wasm
* prevent script from using stable
* extra log
* new log
* run CI on current branch
* run CI on current branch
* Minor fixes
* Remove rust installation
* nightly on build.sh
* add log
* logs
* small change
* rust version is nightly
* auto-approve
* re add lock file
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* get rust versions
* modify build-wasm
* switch to nightly on build-wasm
* prevent script from using stable
* extra log
* new log
* run CI on current branch
* run CI on current branch
* Minor fixes
* Remove rust installation
* nightly on build.sh
* add log
* logs
* small change
* rust version is nightly
* auto-approve
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* chore: added validation checks in PBKDF2 and Scrypt functions
* chore(eslint): ignore linting for mod.ts
* chore(ci): bump RUST_VER
* chore(ci): bump RUST_VER
* chore(CI): downgrade RUST_VER and update xargo build script
* chore(CI): revert last change and use RUST_VER as stable
* chore(CI): bump BINDGEN_VER
* chore(CI): bump BINDGEN_VER
* chore(CI): bump BINARYEN_VER
* chore(CI): downgrade BINARYEN_VER
* chore(CI): recomended fix for wasm-bindgen
* chore(test): point wasm to package
* Revert "chore(test): point wasm to package"
This reverts commit 66104540fdff0e760ca0a6a666d4e09d162c5769.
* chore(test): temporary test
* Revert "chore(test): temporary test"
This reverts commit af10b8d8b9bb597e02ea9c8d6cc3bf62676a6609.
* chore(test): added more logs to build-wasm.sh script
* Revert "chore(test): added more logs to build-wasm.sh script"
This reverts commit c5073005ae9daa84308296736a41636da8f3d21b.
* chore(test): added more logs to test all
* Revert "chore(test): added more logs to test all"
This reverts commit 9b0ac43c2c053ac408164bbf9b31b46d0844af1b.
* chore: add references for RFCs