zkemail / email-wallet

A smart contract wallet controlled using email
https://emailwallet.org
MIT License
141 stars 18 forks source link

Email Wallet

A smart contract wallet controlled using emails.

Email Wallet is an Ethereum contract wallet that can be controlled by sending emails. The contract validates the authenticity of emails by verifying the ZK Proof of DKIM signature of the email. This ensures email is generated by the user without leaking user's email address on-chain.

For documentation on our email wallet extension click here

This is first proposed at ICBC2023[1].

Things you can do:

Features:

Security Considerations:

  1. Safety guarantee: if your email domain server does not forge your emails, no one can send assets in your wallet.
  2. Liveness guarantee: if your email domain server does not block your emails and you stores an invitation email that you have received before, you can execute a new transaction on-chain.
  3. Privacy protection against DoS scanning attacks: no adversary can learn an address or existence of the wallet for your email address for free.
    • Sender might be able learn the recipient's wallet address by scanning blockchain for the specific amount.


☞ How it works

Emails you send are (usually) signed using a private key controlled by your email domain server according to a DKIM protocol. This signature is included in the headers section of the email.

Email Wallet verify the DKIM signature of an email to ensure the mail was sent by the user and the contents are not forged. Instead of verifying the signature directly on-chain, a zk proof of signature is created (by a permissionless entity called Relayer) and verified on-chain.

ZK circuit also helps to hide the sender's email address and the recipient's email address on-chain.

Here is how a typical interaction with the wallet looks like:

This is a simplified flow, but underneath we use many parameters to ensure security and make the Relayer permissionless. You can read a more detailed spec on Saleel's blog.


☞ Directory structure

This is a mono-repo that contains the circom circuits, smart contracts, the relayer and a prover server.

/packages
├── /circuits
├──── /src              # Circom circuits.
├──── /build            # Compiled circuits.
├──── /helpers          # Helper functions to generate circuit input.
├──── /scripts          # CLI scripts to generate input, zkeys.
├──── /test             # Circom tests for circuit
├
├── /contracts
├──── /src              # Solidity contracts.
├──── /test             # Solidity tests for contracts.
├──── /script           # Scripts to deploy wallet.
├
├── /relayer
├──── /src              # Relayer code.
├──── /eml_templates    # eml templates.
saved here.
├── /prover             # Prover server code.
├
├── /scripts            # scripts for registry contracts
├
├── /frontend           # UI to generate emails
├
├── /utils
├──── /src              # Helper functions for email parsing, proving circuits, etc.
├
├── /subgraph          # indexing and querying events generated by circuits.


☞ Building and Running

To build the docs

In directory docs/, run:

cargo install mdbook

And to serve the website:

mdbook serve

References

  1. S. Suegami and K. Shibano, "Contract Wallet Using Emails," 2023 IEEE International Conference on Blockchain and Cryptocurrency (ICBC), Dubai, United Arab Emirates, 2023, pp. 1-2, doi: 10.1109/ICBC56567.2023.10174932.




☆ Built using zk-email