fix(evm-core): Replace expect() in the BIP-44 path builder with a fallible construction

Open
#657 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start in crates/evm-core/src/derive.rs and trace how evm_derivation_path builds the path and how derive_signing_key handles its result. Preserve m/44'/60'/0'/0/{index} for valid indices, return an error for index = 1 << 31, and add or update tests; the BIP-32 and known-address vectors should still pass. Run just fmt-check, just lint, and just test.

Written by the indexing model from the issue text.

Description

area/contract bug good first issue help wanted

Description

evm_derivation_path in crates/evm-core/src/derive.rs calls .expect(..) five times, contradicting the crate's own #![deny(clippy::expect_used)] and its comment about never panicking in key-handling code. ChildNumber::new(index, false) also fails for index >= 2^31.

Requirements and context

  • Where: crates/evm-core/src/derive.rs
  • Security: Key-handling crate: a panic can leak material through a backtrace.
  • Testing: just fmt-check, just lint and just test must pass; add or update tests for the change.
  • Documentation: Update the nearest doc if behaviour changes; otherwise no doc change is needed.

Suggested execution

  • Comment on this issue to claim it, then fork the repository and branch from main.
  • Branch name: git checkout -b fix/evm-core-derivation-path-expect

Implement changes

  • Make evm_derivation_path return Result<DerivationPath, EvmCoreError>.
  • Propagate the error through derive_signing_key.
  • Keep the produced path m/44'/60'/0'/0/{index} identical for valid indices.

Test and commit

  • The BIP-32 / known-address test vectors still pass; add a test that index = 1 << 31 returns an error.
  • Run just fmt, just lint and just test locally before pushing (see CONTRIBUTING.md).
  • Commit with a conventional message and keep the change small and focused.

Example commit message

fix(evm-core): make derivation path construction fallible

Guidelines

  • Open the PR against main and link it with Closes #<this issue>.
  • Keep the diff focused on this issue; no unrelated refactors or formatting churn.
  • One line per comment, no bloated code; follow patterns already used in the crate.
  • Never commit secrets, .env files or real keys; use public test vectors only.
  • CI (fmt, clippy -D warnings, tests) must be green before requesting review.
  • Ask in the issue thread if anything is unclear before starting.
Dominant language
Rust
Stars
0
Forks
91
Avg merge
5h 23m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Octo-Protocol-org/Octo-Protocol

All issues in Octo-Protocol-org/Octo-Protocol

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.