Files
AutistMask/tests/wallet.test.js
clawbot 2dcea6c306
Some checks failed
check / check (push) Has been cancelled
test: known-answer coverage for HD derivation and the vault (closes #159)
wallet.js and vault.js — the two modules that hold user funds — had no
derivation or encryption tests. Add them, pinned to published vectors
rather than to whatever the implementation returns today.

wallet.js: hdWalletFromMnemonic, hdWalletFromXprv, deriveAddressFromXpub
and getSignerForAddress are pinned to the standard development recovery
phrase's first three accounts at m/44'/60'/0'/0/n and to the BIP-39
all-zero-entropy phrase's first address; addressFromPrivateKey is pinned
to the published key/address pairs, so the HD path and the bare-key path
must meet at the same address from two directions. isValidMnemonic and
isValidXprv cover bad checksum, wrong word count, wrong key type and
empty/garbage input. The absolute-vs-relative path asymmetry between
hdWalletFromMnemonic and hdWalletFromXprv is proven harmless: for the
same master key both reach the same xpub and the same addresses.

vault.js: round trip (including non-ASCII and an empty password), wrong
password rejected as a rejected promise with no partial plaintext,
tampered ciphertext / auth tag / nonce / salt rejected, truncated and
spliced blobs rejected, missing fields rejected, fresh salt and nonce per
encryption, the documented { salt, nonce, ciphertext } shape, and no
trace of the plaintext or password anywhere in the serialized blob. The
Argon2id cost parameters are pinned three ways — the INTERACTIVE
constants still mean 2 passes over 64 MiB, a key independently derived at
that cost opens the vault, and both encrypt and decrypt are observed
calling crypto_pwhash with those constants — because the KDF cost is the
vault's only defence against offline attack on a stolen blob and nothing
else in the suite would notice it being lowered. The tamper cases share
one encrypted fixture to stay inside script/test's 30-second budget.

One test is skipped: isValidXprv accepts an extended private key with a
one-character typo, because ethers skips base58 checksum verification for
the usual 82-byte payload. That defect is tracked separately and is not
fixed here; the skipped test asserts the correct behaviour and cites the
issue.
2026-08-11 12:48:38 +00:00

15 KiB