Make the EIP-7702 derivation path fully customizable (chain-scoped) - #25
Merged
Conversation
The EOA path is [account(W0), chainId(W1), ephemeralIndex(W2)] — chainId is part of the derivation, so each chain yields a distinct EOA and a wallet can operate on multiple chains at once without reusing a 7702 address. All three words are already caller-settable through prepareEthereumSigner, the engine signer provider, and the controller; the one gap was get7702Signer, which hard-coded the account. Expose it via an optional railgunAccountIndex on Railgun7702SignerRequest (defaulting to the signer's account). Lock the chain-scoped, per-word-customizable behavior with a multi-chain unit test.
Address review of the customizable-path change: - Add a get7702Signer test that a custom railgunAccountIndex overrides the signer's own account (the branch the change exists to enable) — a revert to the hard-coded account would now fail the suite, not pass silently. - Document that each path word (account/chainId/ephemeralIndex) is a hardened BIP-32 index and must fit in 31 bits, so EVM chains with chainId >= 2**31 are rejected fail-closed (never collapsed onto another chain's slot).
…th chainId Defense-in-depth for chain-scoping: when a caller passes an explicit derivation path to signEip7702Authorization, assert its chainId word (W1) equals the authorization's target chainId, so a path can't derive one chain's EOA while the authorization targets another. Session and fallback paths are built from the chainId and are unaffected.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the RAILGUN Ledger EIP-7702 auth-signing derivation path fully caller-customizable while keeping it chain-scoped.
Model
The 7702 EOA is derived at
m/…/7702'/W0'/W1'/W2'with W0 = account, W1 = chainId, W2 = ephemeralIndex. chainId stays in the path, so each chain yields a distinct EOA — a wallet can operate on multiple chains at once without reusing a 7702 address. (Device-verified: slot(0,0,0)and(0,1,0)derive different addresses.)Changes
get7702Signernow honors a customrailgunAccountIndex(optional onRailgun7702SignerRequest, defaulting to the signer's account). This was the one place the account was hard-coded; every other entry point (prepareEthereumSigner, the engine signer provider, the controller) already threaded all three words, so the whole stack is now fully customizable.pathis passed tosignEip7702Authorization, its chainId word (W1) must equal the authorization's target chainId — so a path can't derive one chain's EOA while authorizing on another. Session/fallback paths are built from the chainId and are unaffected.chainId >= 2**31are rejected fail-closed (never collapsed onto another chain's slot).Tests
get7702Signeroverride wins over the signer's account (a revert to the hard-coded account now fails).Reviewed (correctness + security); typecheck + lint clean; full suite green. The signing paths are device-verifiable with
scripts/probe-clear-sign-v1.ts.