lambdaclass / lambdaclass/eth-agent
BIP-32 key derivation modulo operation may produce invalid keys
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The BIP-32 key derivation uses a simple modulo operation that may not correctly handle edge cases per the BIP-32 specification.
Location
src/protocol/account.ts:209
Current Code
finalKey = childKeyBigInt % curveOrder;
Concern
According to BIP-32 spec:
- If the resulting key is zero or >= curve order, the child key is invalid
- Should skip to next index rather than use modulo
- Modulo could produce keys with different security properties
Recommendation
- Verify against BIP-32 test vectors
- Implement proper invalid key handling:
if (childKeyBigInt === 0n || childKeyBigInt >= curveOrder) {
// Invalid key - derive next index per BIP-32 spec
return this.deriveChild(index + 1);
}
Priority
Medium - Edge case but security-sensitive
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/protocol/account.ts:209 and trace the child-key derivation flow around the modulo operation. Compare the behavior with the BIP-32 specification and test vectors, then verify the invalid-key handling for zero and values at or above the curve order. Done means the edge cases are handled according to the specification and the relevant derivation tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100