Skip to content

Commit a4db856

Browse files
committed
adding back stealthdrop
1 parent b21ce9c commit a4db856

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+11115
-0
lines changed

stealthdrop/.gitignore

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
.env
4+
.tmp
5+
6+
# dependencies
7+
node_modules
8+
/.pnp
9+
.pnp.js
10+
11+
# testing
12+
/coverage
13+
14+
# production
15+
/build
16+
17+
# misc
18+
.DS_Store
19+
*.pem
20+
21+
# debug
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
.pnpm-debug.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
36+
# hardhat
37+
cache
38+
39+
# artifacts
40+
typechain-types
41+
proofs
42+
43+
# noir
44+
crs
45+
46+
# other
47+
.vscode
48+
.DS_Store
49+
artifacts
50+
51+
.deps
52+
.yarn
53+
54+
.cursorrules

stealthdrop/.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage

stealthdrop/.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "avoid",
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"proseWrap": "always"
7+
}

stealthdrop/README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Noir Stealthdrop
2+
3+
A few months ago, we were challenged to copy the amazing [Stealthdrop project](https://github.com/stealthdrop/stealthdrop). We also committed to work hard on PLUME to avoid malleability of the ECDSA signature. You can read more about it on the link above.
4+
5+
Challenge accepted.
6+
7+
## What is this
8+
9+
TL;DR: This is a much faster version of Stealthdrop that uses PLUME nullifiers. Built with Noir.
10+
11+
Stealthdrop is a process to airdrop tokens to a list of eligible Ethereum addresses, allowing a [stealth address](https://vitalik.eth.limo/general/2023/01/20/stealth.html) to claim it. For example, Alice may be eligible for an airdrop but for privacy reasons may want to claim it with an address that isn't linked to her eligible account.
12+
13+
The way it works is a bit of ZK dark magic. First you connect your eligible address and generate a PLUME nullifier. The cool thing about PLUME is that it will generate a deterministic nullifier: **one** address can only generate **one** PLUME nullifier. This makes it perfect to be used as a "ticket": you will only get your tokens if you show your "ticket" to the contract, and you won't ever be able to generate a different one from your eligible account.
14+
15+
Then, with that PLUME signature, you execute a Noir program. This program proves some things:
16+
17+
- It proves that your PLUME signature was made with a specified public key **without revealing it**
18+
- It then proves that this public key, when converted into an address, is indeed eligible for the airdrop. It does so by proving that you know the path in the airdrop's merkle tree from the eligible address up to the root, **without revealing the path**.
19+
- Finally, it proves that the address that claims the address is authorized to claim the airdrop. The theory is that by providing the claimer address as a private input, the circuit will verify that it matches the claimer (which is public: `msg.sender`)
20+
21+
## Getting Started
22+
23+
1. [Install bun](https://bun.sh/). We use Bun because well, it's just unreasonably faster and just works. Feel free to try with other package managers.
24+
2. Install dependencies with `bun i`. You may need to run `bun pm trust plume-sig` since the Noir plume-sig PR is still open and we don't feel like pushing it to `npm` right away.
25+
3. Start a local network with `bun run node`. This will start a `hardhat` network inside the `packages/ethereum` package. Leave this new terminal running and open a new one.
26+
4. Get hold of an "eligible" address by either:
27+
1. Adding your claimer's private and public key to utils/mt/eligible.json, or
28+
2. Just importing the private key already there
29+
5. If you want fresh addresses, you can run `bun run gen`. This will create a fresh new merkle tree in `utils/mt/merkle.json` and should also add the eligible addresses above
30+
6. Run `bun run dev` - This runs the deployment script that compiles the noir program, generates a contract, compiles the contract, deploys it to your local network, and then starts the frontend app.
31+
32+
## Things you should know
33+
34+
1. This is very experimental software. It is unaudited, unsafe, and its usage is discouraged.
35+
2. One thing is to have a Noir program. That's cool. Another thing is to get PLUME nullifiers in browser wallets. You can track the ongoing work in the [plume repository](https://github.com/plume-sig/zk-nullifier-sig). In the meantime, we're just blatantly hardcoding the eligible address private key in the `eligible.json` file mentioned above.
36+
3. Goes without saying that until the project reaches maturity, you should not use this address by any means. Please be careful, any funds there WILL be lost.
37+
38+
## Next steps
39+
40+
### secp256r1
41+
42+
This project was made with `secp256k1` signatures, at a time where Account Abstraction wasn't really a popular thing. These days people use `secp256r1` signatures such as FaceID, NFC cards, or even passports, as signers to an abstracted wallet.
43+
44+
So the next steps would involve adding support for these schemes, which should be trivial.
45+
46+
### Wallets
47+
48+
As mentioned above, getting wallets to generate PLUME nullifiers isn't easy, even with open PRs ready to review and merge. Some even prevent basic features such as private key exponentiation (looking at you, Metamask).
49+
50+
Increasing awareness and working closely with these projects would be a smart next step.
51+
52+
## Testing
53+
54+
There are some useful hardhat tests you can run to check if things are still smooth. Just run `bun run test`.

0 commit comments

Comments
 (0)