Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eugenioclrc/mercadobarrani
Tornado cash meets private token with homomorphic encription
https://github.com/eugenioclrc/mercadobarrani
Last synced: 1 day ago
JSON representation
Tornado cash meets private token with homomorphic encription
- Host: GitHub
- URL: https://github.com/eugenioclrc/mercadobarrani
- Owner: eugenioclrc
- Created: 2024-08-03T15:25:36.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-04T15:29:41.000Z (5 months ago)
- Last Synced: 2024-11-11T18:45:00.999Z (about 1 month ago)
- Language: Solidity
- Size: 3.31 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MERCADO BARRANI A ZK-USDC Privacy Token
## Table of Contents
- [Introduction](#Introduction)
- [Workflow](#Workflow)
- [Contracts](#Contracts-and-transactions)
- [Circuits](#Circuits)
- [Citations and References](#Citations-and-References)## Introduction
An ambitious idea with ultra-complex components.
1) A user can deposit USDC on Ethereum, which will then be deposited into AAVE. The interest earned is considered protocol revenue.
2) From Scroll, using the precompile to read Ethereum's state, we read the user's deposited balance, and with that, we mint a wrapped version of USDC, the ZK-USDC. This token has private amounts, meaning that after minting, every time it's transferred, no one knows the amount being transferred.
3) When someone wants to unwrap it, the ZK-USDC is burned, revealing the total amount to be unwrapped. A message is sent via Scroll's messaging service, and a commitment is given to the user.
4) Eventually (if we claim immediately, it will reveal our identity), using ZK again, a proof is provided to make the withdrawal from any wallet. This behavior is similar to withdrawals on Tornado Cash.## Workflow
## Contracts and transactions
### Layer 1
- Vault: [0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003](https://sepolia.etherscan.io/address/0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003#code)
- Deposit contract: [0xc04e68Ba3c8094097976EA542c708a2a671318A7](https://sepolia.etherscan.io/address/0xc04e68Ba3c8094097976EA542c708a2a671318A7#code)
- Tx of deposit in L1: [0x305f0495f32c.....1a135b16da](https://sepolia.etherscan.io/tx/0x305f0495f32c6321ff98898c5d52738370b5764f77aab521537a261a135b16da)Layer 1 vault and deposit contract 0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003
Deployed with command:
```sh
forge script script/Layer1.s.sol --rpc-url=https://eth-sepolia.public.blastapi.io --verify --private-key=0x... --etherscan-api-key=...
[⠊] Compiling...
No files changed, compilation skipped
Script ran successfully.== Return ==
vault: contract Vault 0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003## Setting up 1 EVM.
==========================
Chain 11155111
Estimated gas price: 7.003102858 gwei
Estimated total gas used for script: 777896
Estimated amount required: 0.005447685700826768 ETH
==========================
##### sepolia
✅ [Success]Hash: 0xf4c0e86dc5483fa0fbaa09b46c4708e11d86e03be2c7b1ccb9c026bb88f8353d
Contract Address: 0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003
Block: 6431154
Paid: 0.00244380533625144 ETH (598640 gas * 4.082262021 gwei)✅ Sequence #1 on sepolia | Total Paid: 0.00244380533625144 ETH (598640 gas * avg 4.082262021 gwei)
...
Submitting verification for [src/Layer1/Vault.sol:Vault] 0x4DFB5C0F45AE4e0C4cA57E0238FcCcfAb9b36003.
Submitted contract for verification:
Response: `OK`
```### ZK-Scroll
- PublicKeyInfrastructure: [0xc54ae1172a7e671002c3bf73c8d75e54c9d2effe](https://sepolia.scrollscan.com/address/0xc54ae1172a7e671002c3bf73c8d75e54c9d2effe)
- UltraVerifier Mint: [0x3ec5c0a31d779cded116741bc3e0f2713e39ca14](https://sepolia.scrollscan.com/address/0x3ec5c0a31d779cded116741bc3e0f2713e39ca14)
- UltraVerifier Transfer: [0x4c743c69e88f146d4dd434cb662024c86c2f0997](https://sepolia.scrollscan.com/address/0x4c743c69e88f146d4dd434cb662024c86c2f0997)
- UltraVerifier TransferToNew: [0xad43abaed15e41176f666df2935f1249560e4456](https://sepolia.scrollscan.com/address/0xad43abaed15e41176f666df2935f1249560e4456)
- PrivateToken: [0x55ee3c0e8ae6c8634be3c3ff90852d838898089a](https://sepolia.scrollscan.com/address/0x55ee3c0e8ae6c8634be3c3ff90852d838898089a)- Tx mint: [0x20e3e282e5f81394856b9249085aebfb056e2ed6dc9eac96b1a211d39280b7b3](https://sepolia.scrollscan.com/tx/0x20e3e282e5f81394856b9249085aebfb056e2ed6dc9eac96b1a211d39280b7b3)
## Circuits
- Mint: [`./circuits/mint/src/main.nr`](https://github.com/eugenioclrc/MercadoBarrani/blob/main/circuits/mint/src/main.nr)
- Transfer: [`./circuits/transfer/src/main.nr`](https://github.com/eugenioclrc/MercadoBarrani/blob/main/circuits/transfer/src/main.nr)
- Transfer to new: [`./circuits/transfer_to_new/src/main.nr`](https://github.com/eugenioclrc/MercadoBarrani/blob/main/circuits/transfer_to_new/src/main.nr)## Citations and References
It would be impossible to me do this with out the awesome work of other researchers that have done all the hard work for me :D
- [ZeeStar: Private Smart Contracts by Homomorphic Encryption and Zero-knowledge Proofs](https://files.sri.inf.ethz.ch/website/papers/sp22-zeestar.pdf)
- [Cifrado ElGamal](https://es.wikipedia.org/wiki/Cifrado_ElGamal)
- **Most or circuit are based on this post:** [@jat9292: zkSNARKs & Homomorphic Encryption : Ethereum’s Privacy New Frontier](https://medium.com/@jat9292/zksnarks-homomorphic-encryption-ethereums-privacy-new-frontier-b30357236a7a)
- [colinnielsen: ECRecover Noir](https://github.com/colinnielsen/ecrecover-noir/tree/main)
- [Foulks-Plb: noir-lang-zkp-homomorphic](https://github.com/Foulks-Plb/noir-lang-zkp-homomorphic/tree/main)