Skip to content

Updated class diagram for IthacaAccount Merkle signature support #65

Description

@Dargon789

Reviewer's Guide

Adds Merkle tree–based signature wrapping/verification support to IthacaAccount, updates the wrapped-signature format to include a merkle flag, adjusts all test helpers and call sites accordingly, and introduces fuzz tests for Merkle signature validation while bumping the account contract version.

Updated class diagram for IthacaAccount Merkle signature support

classDiagram
    class IthacaAccount {
        +unwrapAndValidateSignature(bytes32 digest, bytes signature) bool isValid
        +unwrapAndValidateSignature(bytes32 digest, bytes signature) bytes32 keyHash
        -_verifyMerkleSig(bytes32 digest, bytes signature) bool isValid
        -_verifyMerkleSig(bytes32 digest, bytes signature) bytes32 keyHash
        +getNameAndVersion() string name
        +getNameAndVersion() string version  "0.5.11"
    }

    class MerkleProofLib {
        <<library>>
        +verifyCalldata(bytes32[] proof, bytes32 root, bytes32 leaf) bool
    }

    class LibBytes {
        <<library>>
        +loadCalldata(bytes data, uint256 offset) bytes32
        +truncatedCalldata(bytes data, uint256 newLength) bytes
    }

    class EfficientHashLib {
        <<library>>
        +sha2(bytes32 input) bytes32
    }

    class ECDSA {
        <<library>>
        +recoverCalldata(bytes32 digest, bytes signature) address
    }

    class IIthacaAccount {
        <<interface>>
    }

    class EIP712 {
    }

    class GuardedExecutor {
    }

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

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

File-Level Changes

Change Details Files
Introduce Merkle-based wrapped signature verification path in IthacaAccount and extend unwrapAndValidateSignature format.
  • Import MerkleProofLib and add internal _verifyMerkleSig that decodes (proof, root, rootSig) from calldata using assembly and verifies the digest against the Merkle root via MerkleProofLib.verifyCalldata, then validates the root with unwrapAndValidateSignature
  • Update unwrapAndValidateSignature encoding contract comment to include an extra bool merkle flag, adjust trailer parsing to read two flag bytes (prehash and merkle), and branch to _verifyMerkleSig when the merkle flag is set before falling back to direct key-based verification
src/IthacaAccount.sol
Update wrapped signature construction in tests to include the new merkle flag byte and keep non-Merkle paths compatible.
  • Modify P-256, secp256k1, multi-sig, and helper intent-signature builders to append an extra uint8(0) merkle flag after the existing prehash byte
  • Update all test scenarios that build junk or simulation signatures to include the new trailing merkle flag byte so length and parsing match the contract expectations
test/Base.t.sol
test/Orchestrator.t.sol
test/SimulateExecute.t.sol
Add fuzz test coverage for Merkle-based signatures and adjust EIP-712 domain decoding to ignore removed fields.
  • Import a Merkle implementation for testing, construct randomized Merkle trees over digests, and test valid proofs, invalid digests, tampered proofs, and tampered roots through unwrapAndValidateSignature using the new Merkle signature encoding
  • Simplify eip712Domain destructuring in tests to only read verifyingContract, ignoring removed name/version fields now that the domain type hash is fixed
test/Account.t.sol
Bump IthacaAccount contract version string to reflect bytecode/signature format changes.
  • Update eip712NameAndVersion to return version 0.5.11 instead of 0.5.10
src/IthacaAccount.sol

Possibly linked issues

  • Porto.sh #46: They both concern adding Merkle wrapped signature support, updating wrapped signature layout, tests, and bumping the account version.

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 #60 (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
Backlog
Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions