https://github.com/ronanyeah/sui-zk-airdrop
Sui / Groth16 / Merkle Tree
https://github.com/ronanyeah/sui-zk-airdrop
Last synced: 11 months ago
JSON representation
Sui / Groth16 / Merkle Tree
- Host: GitHub
- URL: https://github.com/ronanyeah/sui-zk-airdrop
- Owner: ronanyeah
- Created: 2025-01-16T17:08:47.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-16T17:32:43.000Z (over 1 year ago)
- Last Synced: 2025-03-30T11:34:13.391Z (about 1 year ago)
- Language: Rust
- Size: 61.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - ronanyeah/sui-zk-airdrop - Sui / Groth16 / Merkle Tree (Rust)
README
# sui-zk-airdrop
This is a demonstration of using a Merkle Tree to contain a list of Sui wallet addresses. These wallets can verify their inclusion in this list onchain, by submitting offchain proofs.
Onchain verification is managed by [Groth16](https://docs.sui.io/guides/developer/cryptography/groth16).
This infrastructure could be useful for airdrops where the number of wallets makes the gas costs of wallet-to-wallet transfers unfeasible, or if it it preferred that claimants interact in order to participate.
The wallet lists and Merkle roots can be stored on [Walrus](https://www.walrus.xyz/), to enable a fully decentralized user journey.
---
- [Sui contract](./sources/bagdrop.move)
- [Circom circuit](./src/leanimt.circom)
---
### Build Instructions
#### Compile the Circom circuit
> Requires installing [Circom](https://docs.circom.io/getting-started/installation/)
`circom src/leanimt.circom -l ./path/to/circomlib/circuits --r1cs --wasm -o ./dist`
#### Display the Merkle root
> This root will be saved onchain (and can also be stored alongside the leaves on Walrus)
`cargo run --bin create_root`
#### Generate claim values
> Any wallet in `./wallets.json` can be used
`WALLET=0x5354085bc8a8d3f96383483a9ba42410476af916d42ff5dd4f05bad55608f2ce cargo run --bin generate_claim_proof`
These output values should be passed to the Sui contract and the claim can be validated.
### Further resources:
- [Lean Incremental Merkle Tree in Circom](https://github.com/privacy-scaling-explorations/zk-kit.circom/issues/17)
- [fastcrypto-zkp](https://docs.rs/fastcrypto-zkp/latest/fastcrypto_zkp/)
- [Sui Groth16](https://docs.sui.io/guides/developer/cryptography/groth16)