Skip to content

[good first issue] BIP-39 mnemonic + BIP-44 derivation with golden test vectors #7

@abhicris

Description

@abhicris

Context

src/wallet/mod.rs exposes Wallet::generate() and Wallet::from_private_key(&str), but has no BIP-39 mnemonic or BIP-44 derivation-path support. Any agent operator reaching for a standard m/44'/60'/0'/0/i path (what MetaMask, Rabby, ledgers etc. emit) can't use arka today without hand-deriving first. Adding BIP-44 support is self-contained and contributor-friendly.

Scope

  • Add a bip39 + coins-bip32 (or alloy's mnemonic feature) dependency to Cargo.toml.
  • Add to src/wallet/mod.rs:
    • Wallet::from_mnemonic(phrase: &str, index: u32) -> Result<Self> — derives m/44'/60'/0'/0/{index}.
    • Wallet::from_mnemonic_with_path(phrase: &str, path: &str) -> Result<Self> — arbitrary derivation path.
  • Add a wallet::bip44 submodule (or inline) with golden test vectors from the official BIP-44 spec. Use at least two vectors so regression against the derivation logic is obvious:
    • Mnemonic: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about — path m/44'/60'/0'/0/0 → address 0x9858EfFD232B4033E47d90003D41EC34EcaEda94.
    • Mnemonic: test test test test test test test test test test test junk (Foundry's default) — path m/44'/60'/0'/0/0 → address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266.
  • Tests should be deterministic — no network.

Acceptance criteria

  • cargo test wallet::bip44 passes with at least 2 golden vectors.
  • cargo clippy clean.
  • Rustdoc example on from_mnemonic showing how to derive wallet index 0.
  • examples/multi_chain.rs doesn't need changes; add a new examples/mnemonic_wallets.rs that derives 3 wallets from a test mnemonic and prints addresses.

Estimated effort

S (3–5 hours) — the derivation logic is a handful of lines; most of the work is picking the right crate and writing the vectors.

Reference: see PR #4 for the cargo test / CI conventions used in this repo.

kcolbchain / Abhishek Krishna

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions