-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from noir-lang/zpedro/stealthdrop_noirjs
Refactoring stealthdrop for NoirJS
- Loading branch information
Showing
43 changed files
with
28,240 additions
and
5,880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
# using hardhat default accounts, please update | ||
DEPLOYER_PRIVATE_KEY="0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e" | ||
USER1_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
CLAIMER1_PRIVATE_KEY="0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" | ||
CLAIMER2_PRIVATE_KEY="0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0" | ||
MUMBAI_DEPLOYER_PRIVATE_KEY=1973b806f3b34ba5279aef4e5a5bd8efce422602b3a692f1a1377898b405db74 | ||
SEPOLIA_DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
|
||
# hardhat acct #0 key, please update | ||
MUMBAI_DEPLOYER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
MUMBAI_ALCHEMY_KEY="" | ||
# hardhat acct #0 key, please update | ||
SEPOLIA_DEPLOYER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
SEPOLIA_ALCHEMY_KEY="" | ||
MERKLE_TREE_DEPTH=12 | ||
ELLIGIBLE_USER_ADDRESS=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 | ||
ELLIGIBLE_USER_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Add files here to ignore them from prettier formatting | ||
|
||
/dist | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"proseWrap": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-3.6.4.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
# Stealthdrop example | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
WARNING: THIS IS UNSAFE. ECDSA signature is malleable, which means this app has a vulnerability. Check out this [twitter thread](https://twitter.com/0xPARC/status/1493704577002049537?s=20&t=X-5Bs1oWNjmbTASp2T82DA) to understand why. | ||
## Getting Started | ||
|
||
This example mimics the great [Stealthdrop](https://github.com/stealthdrop/stealthdrop) example, while massively reducing the complexity of the circuit, proving time, resources, and improving readability. | ||
First, run the development server: | ||
|
||
## How to run | ||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
``` | ||
|
||
Just clone the repo, run `yarn` and `yarn test`. It currently has two tests: a happy path and a sad path. | ||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
## How does it work | ||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
||
In the `circuits` folder you'll find a circuit, roughtly divided in four steps: | ||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
- Step 1 - Recover the address: Verify ECDSA signature and recover the address. Initially I implemented this by myself, but then found the amazing `ecrecover` library by [Colin](https://github.com/colinnielsen/ecrecover-noir) already provided a module for this. In this step, we prove that the verification of the provided (private) signature was made with the private key that is elligible to claim the airdrop. We also recover the elligible address from it. | ||
- Step 2 - Prevent double-claims: We prove that the nullifier that will be stored in the contract is hash of the signature. | ||
- Step 3 - Prove elligibility: We prove that the address is part of the merkle tree of elligible accounts. | ||
- Step 4 - Allow claimer to claim the airdrop: We prove that the claimer address is the msg.sender | ||
## Learn More | ||
|
||
Each step is roughly two lines of code. | ||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[package] | ||
name = "stealthdrop" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.4.1" | ||
compiler_version = "0.16.0" | ||
|
||
[dependencies] | ||
ecrecover = {tag = "v0.2.1", git = "https://github.com/signorecello/ecrecover-noir.git"} | ||
ecrecover = {tag = "v0.16.1", git = "https://github.com/signorecello/ecrecover-noir.git"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
|
||
pub_key = [131,24,83,91,84,16,93,74,122,174,96,192,143,196,95,150,135,24,27,79,223,198,37,189,26,117,63,167,57,127,237,117,53,71,241,28,168,105,102,70,242,243,172,176,142,49,1,106,250,194,62,99,12,93,17,245,159,97,254,245,123,13,42,165] | ||
|
||
signature = [1,83,82,167,184,77,226,104,5,27,151,91,202,127,17,183,75,31,190,253,159,116,155,13,24,178,40,165,129,90,103,204,42,164,230,62,73,181,169,61,251,221,128,221,14,19,179,25,107,132,10,188,149,0,197,52,151,239,244,103,215,224,56,242] | ||
|
||
hashed_message = [3,57,199,96,145,58,183,241,206,140,36,34,165,163,17,210,97,254,154,79,91,223,149,18,3,210,111,56,246,219,19,104] | ||
|
||
nullifier = [142,197,227,35,35,142,255,176,38,63,247,168,33,178,55,202,46,76,167,202,130,208,59,14,151,19,144,228,58,37,10,101] | ||
|
||
merkle_path = ["0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8","0x03f943ec114f89d16dbcce5b92d643e24b34f239cb462932833b6ef4a666df10","0x10605994d9acb4d2c67befc19b650e255430faa378d010d4fdcf973f0697155e","0x25eb6b9946e31f411b7c607aa9b37cd29ca6db3ff395864bf9a30176c741bebe"] | ||
|
||
index = 0 | ||
|
||
merkle_root = "0x23bfa58e401ffe1f73d39703caa5376a8b5ee8a0673853321585208b86a451c0" | ||
|
||
claimer_pub = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" | ||
|
||
claimer_priv = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" | ||
|
||
pub_key = [ | ||
131, 24, 83, 91, 84, 16, 93, 74, 122, 174, 96, | ||
192, 143, 196, 95, 150, 135, 24, 27, 79, 223, 198, | ||
37, 189, 26, 117, 63, 167, 57, 127, 237, 117, 53, | ||
71, 241, 28, 168, 105, 102, 70, 242, 243, 172, 176, | ||
142, 49, 1, 106, 250, 194, 62, 99, 12, 93, 17, | ||
245, 159, 97, 254, 245, 123, 13, 42, 165 | ||
] | ||
signature = [ | ||
1, 83, 82, 167, 184, 77, 226, 104, 5, 27, 151, | ||
91, 202, 127, 17, 183, 75, 31, 190, 253, 159, 116, | ||
155, 13, 24, 178, 40, 165, 129, 90, 103, 204, 42, | ||
164, 230, 62, 73, 181, 169, 61, 251, 221, 128, 221, | ||
14, 19, 179, 25, 107, 132, 10, 188, 149, 0, 197, | ||
52, 151, 239, 244, 103, 215, 224, 56, 242 | ||
] | ||
hashed_message = [ | ||
3, 57, 199, 96, 145, 58, 183, 241, | ||
206, 140, 36, 34, 165, 163, 17, 210, | ||
97, 254, 154, 79, 91, 223, 149, 18, | ||
3, 210, 111, 56, 246, 219, 19, 104 | ||
] | ||
nullifier = "0x0e860d099661305414f1218fd4ba4ea3f71ef33123a6263cae21bf132ff8dac1" | ||
merkle_path = [ | ||
"0x00000000000000000000000015d34aaf54267db7d7c367839aaf71a00a2c6a65", | ||
"0x0b02bddc10f9c04e9ed3c80413155a08bb24499c8e8e80cd057f55cf4c4f63ca", | ||
"0x16dcf3f04206c2e99acd4c3e102c9c6d90acdf08bda78fe781e2e235f2d0133a", | ||
"0x1b1a23f70519d8f75b7a396312ac22bb012b9e28045d198688c1377fc73cb361" | ||
] | ||
index = 0 | ||
merkle_root = "0x2221f3030521b64639094d34f80dd35b64113e5846b8b26df0c881d272dbf96e" | ||
claimer_pub = "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" | ||
claimer_priv = "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
claimer_pub = "0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8" | ||
claimer_pub = "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc" | ||
hashed_message = ["0x0000000000000000000000000000000000000000000000000000000000000003", "0x0000000000000000000000000000000000000000000000000000000000000039", "0x00000000000000000000000000000000000000000000000000000000000000c7", "0x0000000000000000000000000000000000000000000000000000000000000060", "0x0000000000000000000000000000000000000000000000000000000000000091", "0x000000000000000000000000000000000000000000000000000000000000003a", "0x00000000000000000000000000000000000000000000000000000000000000b7", "0x00000000000000000000000000000000000000000000000000000000000000f1", "0x00000000000000000000000000000000000000000000000000000000000000ce", "0x000000000000000000000000000000000000000000000000000000000000008c", "0x0000000000000000000000000000000000000000000000000000000000000024", "0x0000000000000000000000000000000000000000000000000000000000000022", "0x00000000000000000000000000000000000000000000000000000000000000a5", "0x00000000000000000000000000000000000000000000000000000000000000a3", "0x0000000000000000000000000000000000000000000000000000000000000011", "0x00000000000000000000000000000000000000000000000000000000000000d2", "0x0000000000000000000000000000000000000000000000000000000000000061", "0x00000000000000000000000000000000000000000000000000000000000000fe", "0x000000000000000000000000000000000000000000000000000000000000009a", "0x000000000000000000000000000000000000000000000000000000000000004f", "0x000000000000000000000000000000000000000000000000000000000000005b", "0x00000000000000000000000000000000000000000000000000000000000000df", "0x0000000000000000000000000000000000000000000000000000000000000095", "0x0000000000000000000000000000000000000000000000000000000000000012", "0x0000000000000000000000000000000000000000000000000000000000000003", "0x00000000000000000000000000000000000000000000000000000000000000d2", "0x000000000000000000000000000000000000000000000000000000000000006f", "0x0000000000000000000000000000000000000000000000000000000000000038", "0x00000000000000000000000000000000000000000000000000000000000000f6", "0x00000000000000000000000000000000000000000000000000000000000000db", "0x0000000000000000000000000000000000000000000000000000000000000013", "0x0000000000000000000000000000000000000000000000000000000000000068"] | ||
merkle_root = "0x23bfa58e401ffe1f73d39703caa5376a8b5ee8a0673853321585208b86a451c0" | ||
nullifier = ["0x000000000000000000000000000000000000000000000000000000000000008e", "0x00000000000000000000000000000000000000000000000000000000000000c5", "0x00000000000000000000000000000000000000000000000000000000000000e3", "0x0000000000000000000000000000000000000000000000000000000000000023", "0x0000000000000000000000000000000000000000000000000000000000000023", "0x000000000000000000000000000000000000000000000000000000000000008e", "0x00000000000000000000000000000000000000000000000000000000000000ff", "0x00000000000000000000000000000000000000000000000000000000000000b0", "0x0000000000000000000000000000000000000000000000000000000000000026", "0x000000000000000000000000000000000000000000000000000000000000003f", "0x00000000000000000000000000000000000000000000000000000000000000f7", "0x00000000000000000000000000000000000000000000000000000000000000a8", "0x0000000000000000000000000000000000000000000000000000000000000021", "0x00000000000000000000000000000000000000000000000000000000000000b2", "0x0000000000000000000000000000000000000000000000000000000000000037", "0x00000000000000000000000000000000000000000000000000000000000000ca", "0x000000000000000000000000000000000000000000000000000000000000002e", "0x000000000000000000000000000000000000000000000000000000000000004c", "0x00000000000000000000000000000000000000000000000000000000000000a7", "0x00000000000000000000000000000000000000000000000000000000000000ca", "0x0000000000000000000000000000000000000000000000000000000000000082", "0x00000000000000000000000000000000000000000000000000000000000000d0", "0x000000000000000000000000000000000000000000000000000000000000003b", "0x000000000000000000000000000000000000000000000000000000000000000e", "0x0000000000000000000000000000000000000000000000000000000000000097", "0x0000000000000000000000000000000000000000000000000000000000000013", "0x0000000000000000000000000000000000000000000000000000000000000090", "0x00000000000000000000000000000000000000000000000000000000000000e4", "0x000000000000000000000000000000000000000000000000000000000000003a", "0x0000000000000000000000000000000000000000000000000000000000000025", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x0000000000000000000000000000000000000000000000000000000000000065"] | ||
merkle_root = "0x2221f3030521b64639094d34f80dd35b64113e5846b8b26df0c881d272dbf96e" | ||
nullifier = "0x0e860d099661305414f1218fd4ba4ea3f71ef33123a6263cae21bf132ff8dac1" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.