Skip to content

[PERF] Build Gas-Optimized EIP-712 Typed Data Hash Calculator #688

Description

@mijinummi

Labels: medium-difficulty, yul, cryptography, gasguard
Difficulty: Medium
Module: contracts/crypto/


🧠 Concept

Build a Yul-based EIP-712 domain separator and struct hash evaluator that computes typed message digests with minimal memory allocations.

⚠️ Problem

Standard EIP-712 implementations execute multiple abi.encode steps, generating redundant memory allocations for every field in the typed struct.

📁 Implementation Scope

  • contracts/crypto/YulEIP712.sol
  • test/crypto/YulEIP712.test.ts

🛠️ Requirements

  1. Cache pre-computed TYPEHASH constants in immutable bytecode storage.
  2. Construct EIP-712 struct payload in scratch space and execute single-pass hashing.
  3. Compute final _hashTypedDataV4 digest via inline Yul.

🎯 Acceptance Criteria

  • Outperforms standard EIP-712 implementations in gas benchmarks.
  • Verifies typed signatures accurately against standard test vectors.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions