Skip to content

Sequence diagram for Merkle-backed wrapped signature verification in IthacaAccount #34

Description

@Dargon789

Reviewer's Guide

Adds Merkle tree–backed wrapped signature support to IthacaAccount, extends unwrapAndValidateSignature with a Merkle flag, fixes EIP712 domain handling in tests, and updates tests/benchmarks (including a new orchestrator benchmark) to use the extended wrapped signature format and cover Merkle verification paths.

Sequence diagram for Merkle-backed wrapped signature verification in IthacaAccount

sequenceDiagram
    actor User
    participant Orchestrator
    participant IthacaAccount
    participant MerkleProofLib

    User->>Orchestrator: submit_authorized_action(wrappedSignature)
    Orchestrator->>IthacaAccount: unwrapAndValidateSignature(digest, wrappedSignature)
    IthacaAccount->>IthacaAccount: detect_wrapped_signature()
    IthacaAccount->>IthacaAccount: parse_keyHash_prehash_flag_merkle_flag()
    alt merkle_flag_is_set
        IthacaAccount->>IthacaAccount: _verifyMerkleSig(digest, innerMerkleSignature)
        IthacaAccount->>MerkleProofLib: verifyCalldata(proof, root, digest)
        alt merkle_proof_valid
            MerkleProofLib-->>IthacaAccount: true
            IthacaAccount->>IthacaAccount: unwrapAndValidateSignature(root, rootSig)
            IthacaAccount-->>Orchestrator: isValid,keyHash
        else merkle_proof_invalid
            MerkleProofLib-->>IthacaAccount: false
            IthacaAccount-->>Orchestrator: false,0x0
        end
    else merkle_flag_not_set
        IthacaAccount->>IthacaAccount: optional_prehash(digest)
        IthacaAccount->>IthacaAccount: load_key_by_keyHash()
        IthacaAccount-->>Orchestrator: isValid,keyHash
    end
    Orchestrator-->>User: action_result
Loading

Updated class diagram for IthacaAccount Merkle signature support

classDiagram
    class IthacaAccount {
        +unwrapAndValidateSignature(digest_bytes32, signature_bytes_calldata) bool,bytes32
        -_verifyMerkleSig(digest_bytes32, signature_bytes_calldata) bool,bytes32
        +_eip712Version() string,string
    }

    class MerkleProofLib {
        +verifyCalldata(proof_bytes32_array_calldata, root_bytes32, leaf_bytes32) bool
    }

    class EfficientHashLib {
        +sha2(input_bytes32) bytes32
    }

    class LibBytes {
        +loadCalldata(data_bytes_calldata, offset_uint256) bytes32
        +truncatedCalldata(data_bytes_calldata, newLength_uint256) bytes_calldata
    }

    class IIthacaAccount
    class EIP712
    class GuardedExecutor

    IthacaAccount --|> IIthacaAccount
    IthacaAccount --|> EIP712
    IthacaAccount --|> GuardedExecutor

    IthacaAccount ..> MerkleProofLib : uses
    IthacaAccount ..> EfficientHashLib : uses
    IthacaAccount ..> LibBytes : uses
Loading

File-Level Changes

Change Details Files
Add Merkle-backed signature verification path to IthacaAccount via a new internal verifier and an extended wrapped signature format.
  • Import MerkleProofLib and introduce _verifyMerkleSig to decode an encoded Merkle proof/root/rootSig from calldata, verify the leaf against the Merkle root, then recursively call unwrapAndValidateSignature on the root digest
  • Extend unwrapAndValidateSignature encoding to abi.encode(innerSignature, bytes32 keyHash, bool prehash, bool merkle), adjust parsing logic for the extra flag byte, and branch to _verifyMerkleSig when the Merkle flag is set
  • Preserve existing EOA/self-signature handling and key lookup/usage flow while routing Merkle signatures through the new verification path
src/IthacaAccount.sol
Update version metadata and EIP712 domain usage to align with simplified domain separator expectations.
  • Bump IthacaAccount version string returned by getNameAndVersion from 0.5.10 to 0.5.11
  • Change Account.t.sol to ignore EIP712 name and version when reading the domain, only using verifyingContract to compute the domain separator
src/IthacaAccount.sol
test/Account.t.sol
Extend test helpers and existing test/benchmark flows to the new wrapped signature format that includes a Merkle flag.
  • Update Base.t.sol signature helpers (_p256Sig, _secp256k1Sig, _multiSig, and gas-estimation helpers) to append an extra zero-valued Merkle flag byte to all constructed signatures
  • Adjust Orchestrator, Benchmark, and SimulateExecute tests to construct wrapped signatures with the new trailing Merkle flag byte in all places that previously encoded only keyHash and prehash
  • Add a new benchmark test for ERC20 transfers via the orchestrator using passkey-based authorization to exercise the updated flow
test/Base.t.sol
test/Benchmark.t.sol
test/Orchestrator.t.sol
test/SimulateExecute.t.sol
snapshots/BenchmarkTest.json
Add fuzz coverage for Merkle-based signatures on accounts using the new wrapped signature format.
  • Introduce testMerkleSignature in Account.t.sol that generates a random Merkle tree of digests, derives the root and proof, wraps a root signature into the new Merkle signature format, and checks valid verification for an in-tree digest
  • Exercise negative cases including invalid digests not in the Merkle tree, tampered proofs, and signatures against an incorrect Merkle root to ensure unwrapAndValidateSignature rejects them
test/Account.t.sol

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #30 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededinvalidThis doesn't seem rightquestionFurther information is requestedwontfixThis will not be worked on

Projects

Status
To-do
Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions