In crypto, the difficulty of managing seed phrases means account recovery is critical. Conventional methods of recovery, such as seed phrases and centralized recovery mechanisms, not only introduce friction for users but also pose security risks, undermining the decentralization of cryptocurrency. Smart account standards like ERC-4337 present promising new ways to avoid seed phrases like using secure element biometric signatures, but account recovery is still needed in the case of device loss or password reset. Currently, users are forced to only choose from crypto-native friends to be recovery signers, making broad adoption more difficult.
Ideally, we would bridge the gap between the security of blockchain technology and the user-friendly recovery methods found in traditional finance.
With the maturation of Acount Abstraction (AA) wallets, we have reached a stage where we can begin to build modules and extensions to support this technology, some of which are enabled by Zero Knowledge (ZK). This inspired us to develop an email-based account recovery tool using ZK Email. This solution simplifies the recovery process so much that even your mom, who is (probably) not very familiar with crypto, can recover the user’s wallet simply by replying to an email. We worked in close partership with Rhinestone to ensure it was ERC 7579 compatible, making it very easy to install and use with a wide variety of smart wallets via a simple installation via ModuleSDK. Note that even non-7579 compliant wallets can implement this module via manually calling the interfaces. It is being audited in Q2 2024 and released in production on mainnet in Q3 2024.
To understand the end to end flow in video form, watch our ZK Summit speech. We will explain it again here.
ZK email works by using two mechanisms:
DKIM - emails are signed by the email service using DKIM (DomainKeys Identified Mail) to verify the email was sent from the domain it claims to be sent from
ZK Regex - regular expressions are used in circom to match some pattern in the email and expose certain information as an output
Example Email:
recovery@4337wallet.net
george@gmail.com
Recover my account 0x123... to 0x84a...
Account abstraction is the ability for a smart contract accounts (in contrast to an EOA) to send and verify transactions. AA wallets have existed for some time (ie. Gnosis Safe), however, not with the ability to originate transactions. ERC-4337 enables things like sponsored transactions (where the protocol pays gas for the user), batched transactions (to reduce total gas fee), novel account sources (like passkeys), and more.
Specifically, ERC-4337 defines an interface for bundlers, entrypoint contracts, and smart contract accounts. This interface enables the deployment of smart contract accounts and sending of transactions without the need for users to have an EOA account, via an alternate mempool of bundlers.
As wallets shift from EOAs to smart account wallets, we thought an intuitive recovery interface via emails that they all could share, would benefit users and apps.
ERC 7579 is a minimal standard for modular smart accounts that makes it easy for smart wallets to share modules between them, by exposing the a standardized set of interfaces. It was developed by Rhinestone in partnership with Safe, OKX, Biconomy, Zerodev, and Etherspot, to replace the overly opinionated ERC-6900. We are working closely with Rhinestone to ensure that it is easy for new wallets to quickly integrate, and easy for established wallets to extend and change.
Email-based recovery is a solution for AA wallets to enable a more intuitive recovery method that allows anyone familiar with email the ability to act as a guardian. As the crypto space matures, the need for user interfaces and experiences that resonate with non-technical users becomes crucial for wider adoption. ZK Email's SDKs make this possible by providing developers with the tools needed to create recovery systems that are both user-friendly and uphold the principles of decentralization.
Account recovery has two main parts: setting a guardian
, and recovering your wallet
Here's a step by step guide to the account recovery process:
1. Proof Generation and Parsing at the Email Server:
Upon receipt of a recovery request, the relayer will process the email request using regex. Key details, particularly from the subject line and Message-ID, for action.
For instance:
FROM: `recovery@wallet.org`
TO: `guardian@gmail.com`
Subject: `Accept guardian request from 0x123...`
Message-ID: `ACCOUNT_CODE.0x1ad9839d...`
In this scenario, the relayer (recovery@wallet.org
) receives a set guardian request and forwards it to the guardian (guardian@gmail.com
). The relayer parses the subject of the email, which contains the wallet address that will be guarded, and the Message-ID, which contains the account key of the wallet owner. Upon the guardian's response to this email without any modification, the relayer generates a proof of the guardian's email to the wallet contract on-chain.
The ZK Email proof parses the subject to ensure that the correct addresses are being rotated, and anonymizes the email address on-chain (via a salted hash) so that no one can learn the email address used by looking at the chain.
2. Enabling either 7579 or Safe Module for Wallets
We partnered with John from the Wax team at PSE to develop an email account recovery demo, accessible here: ZK Email Recovery Demo. For detailed steps on integrating with the demo, please refer to the documentation provided here.
Here's a concise guide on incorporating the Recovery Module into your wallets:
processRecovery
function, starting a timelock delay to ensure that the original wallet owner can notice and remove malicious gaurdians if they have not lost their wallet. Once the threshold of guardians is reached and the timelock has passed, anyone (usually the app does this automatically) can call the completeRecovery
function to securely rotate the owner of the account.Account recovery using ZK Email is a huge step for seamless web2 to web3 integrations, creating a trustless environment where users can recover their wallets without compromising security and autonomy. We want to integrate this feature into as many AA wallets as possible! If you're an AA wallet interested in incorporating email-based account recovery into your wallet application, please fill out this form to be amongst the first beta testers. Also, feel free to reach out to us via telegram if you have any questions!
Special thanks to Elo and Yush for crafting the post, Aditya, Sora, John, Rhinestone, and Yush for writing the module, and Tyler, John, Kurt, and Kichong for their reviews and feedback.