Project ZKP2P
ZKP2P is privacy-preserving trustless P2P fiat onramp interoperable with all popular web2 payment rails (e.g. Venmo). The network is powered by ZK proofs of DKIM signatures in payment confirmation emails, which allows for permissionless integration with any web2 payment network. We build upon the 0xParc / PSE ZK-Email libraries to prove the contents of the email without revealing sensitive information. Upon successful off-chain payment and corresponding proof generation, a user can trustlessly unlock escrowed assets on-chain.
We envision the final state of ZKP2P to be a trustless protocol or primitive deployed on Ethereum / L2s where new payment use cases can be permissionlessly built on top and composable with DeFi, NFTs or other systems. We believe that ZK is the next 0-1 in crypto, and there are so many applications that can be built on this tech that we haven’t imagined yet. With this grant we hope to productionize ZKP2P by optimizing for the onramper UX (imagine the Uniswap UX), reach feature parity with centralized onramps and become the first application built on ZK-Email in prod. P2P on-ramps are a gray area depending on jurisdiction and traditionally a walled garden so it is important to be decentralized, permissionless and a public good.
For our project, the tech stack consists of an end to end protocol including circuits, smart contracts and UI
Assumptions
High Level Flow - Happy Path
High Level Flow - Malicious or Lazy Offramper
High Level Flow - Account Registration (Malicious Onramper)
Smart Contract - Ramp.sol
Ramp is a singleton contract that provides endpoints for different actors in the system to trustlessly coordinate with each other. There will be a single contract for every new payment use case we build.
We draw inspiration from the Binance P2P flow. The key functionality includes:
Smart Contract - Verifier.sol
The verifier contract is for verifying zk-SNARK proofs using the Groth16 proving system. This will be upgraded to halo2 when we transition over to use the halo2-zk-email template. It is extended by the main Ramp contract.
Circuit - Offramper Receive Payment Circuit
Main circuit that offramper generates a proof of Venmo payment received email
Regex Config | Description |
---|---|
Onramper Regex | Extracts the Venmo payer ID from the payment received email body |
Timestamp Regex | Extracts timestamp from venmo payment received email header |
Circuit - Onramper Send Payment Circuit
Main circuit that onramper generates a proof of payment if offramper fails to generate proof above
Regex Config | Description |
---|---|
Offramper ID Regex | Extracts the Venmo payee ID from the payment sent email body |
Amount Regex | Extracts $ amount sent from from venmo payment sent email header |
Circuit - Registration Circuit
Main circuit that both on and off rampers use to tie a specific Venmo ID hash to their public address
Regex Config | Description |
---|---|
ID Regex | Extracts the Venmo payer/payee ID from the payment sent/received email body |
Application - S3 Instance
Host proving keys in a server and accompanying script to download to local storage. Will use a modified zk-email script
Application - Onramper flow
UI flow for an onramper who wants to trade Venmo USD to crypto
Application - Offramper flow
UI flow for an offramper who wants to trade crypto for USD
We have already built a working end to end Venmo flow as a PoC for ZKHack in April which ended up one of the winners in the hackathon. We’re currently making a few updates to the PoC that address some of the prior limitations and deploy an alpha version to an L2. This grant proposal will be for an updated version following the specification above where we plan to address most of the limitations and problems and deploy a secure protocol to production. For more details on prior research and work, check out the additional information section at the bottom.
Team | Telegram | |
---|---|---|
Richard | richardliang2015@gmail.com | @richard2015 |
Sachin | 0xsachink@gmail.com | @Sachin0x |
Alex | alexsoong91@gmail.com | @asoong |
Brian | brian.weickmann@gmail.com | @bmwball56 |
We’re all current or ex-colleagues of Set Labs, where we historically built on-chain DeFi asset management products. We’ve launched some popular on-chain indices such as DeFiPulse Index and ETH 2x Leverage Token which reached over $750M in assets. Most of our prior experience is in implementing production-grade smart contracts and applications, where we haven’t suffered a hack since we started building Set 4 years ago. Recently, we’re spending most of our time individually building in ZK.
Total Estimated Duration: 10 weeks (tentative)
Full-time equivalent (FTE): 2-3 FTE depending on milestone
Total Costs: $55,000
Estimated Duration: 2 weeks
FTE: 2
Costs: $10,000
Estimated delivery date: 6/30/2023
No. | Deliverable | Specification |
---|---|---|
1 | Documentation | We will provide both inline documentation of the circuit and smart contract code. Include in write-up discussion about design decisions, detailed mechanism, and unmitigated potential attacks in the happy path. We’ll also include write ups with benchmarks and learnings from ramping up on halo2 and zk-email |
2 | Testing | The code will have proper unit-test coverage (e.g. 90%) for both circuits and smart contracts to ensure functionality and robustness. In the guide we will describe how to run these tests |
3 | Functionality - Ramp.sol happy path functionality | Smart contract implements on-ramping flow: Optimistic registration (no proofs involved) Deposit liquidity Withdraw liquidity Signal intent Settle order (offramper flow) |
4 | Functionality - Offramper Receive Payment Circuit | Main circuit built in circom that enables the offramper to generate a proof of Venmo payment received email Verifies the DKIM signature (RSA, SHA256) Extracts Venmo onramper ID from email Houses nullifier to prevent replay attacks Contains other order information to tie a proof to an order ID to prevent frontrunning. |
5 | Functionality - Venmo Onramper ID Regex support | Chips config generated using zk email that extracts the Venmo ID of the payer (onramper who paid) from a venmo payment email's subject body. |
6 | Functionality - Venmo Extract Email Timestamp Regex Support | Chips config generated using zk email that extracts the timestamp from a venmo payment received email from the header. |
7 | UI Setup and designs | Basic UI react app setup. Creating designs for various pages including non happy path flows. |
Example Design:
Estimated Duration: 2 weeks
FTE: 3
Costs: $15,000
Estimated delivery date: 7/15/2023
No. | Deliverable | Specification |
---|---|---|
1 | Documentation | We will provide both inline documentation of the UI code and a basic tutorial that explains how a user can (for example) spin up the application. Application is up, it will be possible to send test transactions that will show how the new functionality works. |
2 | Testing | The code will have proper unit-test coverage (e.g. 90%) for both circuits and smart contracts to ensure functionality and robustness. In the guide we will describe how to run these tests. |
3 | Functionality - Ramp.sol offramper isn’t honest | Smart contract that accounts for dishonest offramper. Deposit liquidity includes a fee bounty where if offramper does not submit proof within x min, then onramper is given this rebate. Settle order (onramper fallback flow). |
4 | Functionality - Onramper Send Payment Circuit | Main circuit that onramper uses to generate a proof of payment if offramper fails to generate proof above. Verifies the DKIM signature (RSA, SHA256). Extracts payee ID and amount for the Venmo transaction. Houses nullifier to prevent replay attacks. Contains other order information to tie a proof to an order ID to prevent frontrunning. |
5 | Functionality - Venmo Amount Regex support | Regex config generated using zk email that extracts $ amount sent from the email's header in a payment sent email. |
6 | Venmo Extract Offramper ID Regex support | Regex config generated using zk email that extracts the Venmo ID of the payee (user who was paid) from a venmo payment sent email's subject body. |
7 | Application - Onramper UI core path | On ramping UI. Implement initial Uniswap trade UI component, best rate is automatically shown for an input amount. Implement component for an order intent transaction. |
Estimated Duration: 2 weeks
FTE: 2
Costs: $10,000
Estimated delivery date: 7/31/2023
No. | Deliverable | Specification |
---|---|---|
1 | Documentation | We will provide both inline documentation of the circuit and smart contract code. Include in write-up discussion about the problems this fallback flow is meant to incentivize. |
2 | Testing | The code will have proper unit-test coverage (e.g. 90%) for both circuits and smart contracts to ensure functionality and robustness. In the guide we will describe how to run these tests. |
3 | Functionality - Ramp.sol onramper isn’t honest | Registration and allow / deny lists: smart contract adds functionality to offramper for when onramper doesn’t send payment despite signaling intent for the order. Registration: on and offramper both need to submit proof of payment email to tie a Venmo ID hash to public address. Allow / deny lists: offramper can choose which Venmo ID hash to block or which subset of addresses they are willing to allowlist. |
4 | Functionality - Registration circuit | Circuit that both on and off rampers use to tie a specific Venmo ID hash to their public address. This mitigates griefing from the onramper signaling intent but never sends the Venmo payment. Therefore, the off-ramper’s order is canceled. Extracts the Venmo ID of the user registering and hashes the packed ID to be used as identifier. Packs ID and outputs into a signal for smart contract to verify. |
5 | Functionality - Extract Venmo ID of payee for registration | Regex config so that both on and off rampers use to tie a specific Venmo ID hash to their public address. Extracts the Venmo ID of the user registering and hashes the packed ID to be used as identifier. Packs ID and outputs into a signal for smart contract to verify. |
6 | Application - Offramper UI core path | Offramping UI. Implement component for offramper to post orders. Implement component for oframper to view open and previous orders. Implement component for offramper to add / remove entries to onchain allow / deny list Venmo ID hashes. Implement component for proof generation with email. |
Estimated Duration: 2 weeks
FTE: 2
Costs: $10,000
Estimated delivery date: 8/15/2023
No. | Deliverable | Specification |
---|---|---|
1 | Documentation | We will provide a basic tutorial that explains how a user can (for example) spin up the application. Application is up, it will be possible to send test transactions that will show how the new functionality works. |
2 | Testing | The code will have proper integration test coverage (e.g. 90%) for both circuits and smart contracts to ensure functionality and robustness. In the guide we will describe how to run these tests. |
3 | Functionality - Enable client side proof generation | Host proving keys in a public S3 bucket and accompanying script to download to local storage to enable client side proof generation. Will use a modified zk-email script. |
4 | Functionality - Admin upgradeability to safeguard good onrampers | Add admin controls for: Email templates or DKIM signatures change over time. This is needed in case orders are in progress when these changes happen, so funds do not get locked in the smart contract. Upgrades will initially be managed by a multisig to start. Onramp asset caps that is subject to multisig control. |
5 | Functionality - SC deployment scripts | Write deployment scripts for deploying the smart contract protocol on any chain. |
6 | Application - Registration UI | UI flow for both on-ramper and off-rampers to register themselves before using the protocol. On/off ramper generates a proof and submits to contract to register. |
7 | Application - Enable client side proving in UI | Download hosted proving keys from S3 bucket and use wasm to generate proofs in the browser. |
Estimated Duration: 2 weeks
FTE: 2
Costs: $10,000
Estimated delivery date: 8/31/2023
No. | Deliverable | Specification |
---|---|---|
1 | Blog post and documentation | Blog post and documentations on contributing, current limitations, future improvements and use cases to build on top of this protocol. |
2 | Testing - QA | Comprehensive end to end testing, including ancillary flows for cancelling and on-ramper proof generation. Coordination with PSE and zk-email teams regarding audits (see below). |
3 | Application - Server side proving | Hosting proving service and using RapidSnark. |
4 | Application - Send proofs to aggregator server | UI flow to forward the proof generated on client side to the hosted aggregation service. |
5 | Application - Ancillary UI actions for onramper and offramper | End to end flow is working in the UI. Additional UI paths: Offramper can cancel orders past the expiry. Offramper can opt to generate proofs using proving service. Onramping fallback flow. |
6 | System Deployment | Deployment of production environment including smart contracts and proving service. Client will be hosted on IPFS and configured to zkp2p dns. |
We will be collaborating with the PSE and zk-email teams on audits for the circuits, pending their availability. As of grant proposal submission, the external teams are focused on audits for the underlying zk-email circuits. Additional funding and coordination may be required to complete this step which will be required before releasing to production.
Goals
Requirements / Features
Limitations / Problems
Goals
Requirements / Features
Security
Limitations / Problems