Skip to content

← All work

Case study

Wallet recovery with private guardians

Master’s thesis: an ERC-4337 smart-contract wallet that guardians can recover without their identities ever appearing on-chain.

Role
Solo: research, circuit, contracts, bundler, wallet UI
Stack
  • Solidity
  • ERC-4337
  • Circom
  • snarkjs
  • Poseidon
  • BabyJubJub
  • wagmi
Links
Thesis (opens in a new tab)Contracts (opens in a new tab)Bundler (opens in a new tab)Wallet UI (opens in a new tab)

An ordinary Ethereum account is one private key: lose it and the funds are gone. Social recovery lets a group of guardians restore access, but in the usual design the guardians are listed on-chain and sign in public, so anyone can see who protects a wallet and whom to phish or pressure. This thesis keeps the guardians private and still verifies everything on-chain.

non-linear constraints in the guardian circuit
19,311
average proof generation (M1 Pro)
~2.0 s
gas to verify one proof on BSC testnet
~272k
repositories: contracts, bundler, UI
3

Approach

The wallet is an ERC-4337 smart-contract account, so its recovery rules live in code rather than in a single key, and it works without changes to the consensus protocol. Instead of guardian addresses it stores their hashes. A guardian approves a recovery by proving, in zero knowledge, that they know a key whose hash is on the list and that they signed the new owner’s address with it.

  1. Guardian signs

    EdDSA on BabyJubJub, over the new owner address

  2. Proof

    Circom circuit, generated with snarkjs

  3. Bundler

    UserOperation to the EntryPoint

  4. Wallet contract

    verifier checks the proof against stored hashes

  5. Threshold met

    ownership change is unlocked

The circuit

  • Inputs: a fixed-size message, the guardian’s public key, and the R and S parts of an EdDSA signature. None of them are public.
  • Outputs: the Poseidon hash of the guardian’s key, an increment value, and the new owner address taken from the signed 256-bit message. The contract compares the hash with its stored list.
  • Built with circomlib’s EdDSAVerifier and Poseidon; circom compiles it to WebAssembly and R1CS, and snarkjs exports a Solidity verifier contract.
  • Before choosing Poseidon and BabyJubJub, the thesis compares hash functions and curves by how cheap they are inside a circuit: a hash or curve that is cheap on a CPU can cost far more constraints.

Measurements

Proof timings were measured on a MacBook M1 Pro (16 GB). Gas was measured on a local Hardhat network and on BSC testnet (3 December 2024); the testnet figures are below.

  • Circuit: 19,311 non-linear and 817 linear constraints, 21,131 wires; witness 660 KB, constraint file 3.97 MB.
  • Proof generation 2,047 ms on average; verification 14.9 ms.
  • First transfer, which also deploys the account: 288,088 gas. A later transfer: 96,942 gas.
  • Deploying the guardian contract: 2,854,890 gas. Verifying one guardian proof: 272,074 gas.

Trade-offs

Hashes and zero-knowledge proofs instead of a public guardian list

A public guardian list tells an attacker exactly whom to target, and public signatures show who trusts whom.

Gain
Guardian identities never appear on-chain
Cost
About 2 s of proving per guardian and about 272k gas per verification

Circuit-friendly cryptography (Poseidon, EdDSA on BabyJubJub)

Verifying keccak and an Ethereum ECDSA signature inside a circuit takes far more constraints.

Gain
A circuit small enough to prove in about 2 s on a laptop
Cost
Guardians need a separate BabyJubJub key pair, not their Ethereum key

Limits and next steps

A research prototype. The thesis names its main gap: only the current owner can submit the new owner address, so recovery works when a key is leaked or compromised but not when it is lost outright. The proposed fix lets anyone submit it, relying on guardians to approve only requests they trust. Future work: lower gas and latency, a paymaster, limits and delays on large transfers, and hiding transaction parameters with zero knowledge too.