Skip to content

Commit 81f2e4c

Browse files
docs(readme): add circuit table, proof flow diagram, constraint counts
1 parent 4dbc7b5 commit 81f2e4c

1 file changed

Lines changed: 60 additions & 13 deletions

File tree

README.md

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,82 @@
11
# shielded-circuits
22

3-
> ZK circuits for the Shielded Protocol, built with Circom.
3+
> Circom ZK circuits for Shielded Protocol.
44
5-
Part of [shielded-protocol](https://github.com/Shielded-Protocol)
5+
Part of [Shielded Protocol](https://github.com/Shielded-Protocol)
66
private, compliant DeFi on Stellar.
77

8-
[![CI](https://github.com/Shielded-Protocol/shielded-circuits/actions/workflows/ci.yml/badge.svg)](https://github.com/Shielded-Protocol/shielded-circuits/actions)
8+
[![CI](https://github.com/Shielded-Protocol/shielded-circuits/actions/workflows/ci.yml/badge.svg)](https://github.com/Shielded-Protocol/shielded-circuits/actions/workflows/ci.yml)
99
[![Stellar Wave](https://img.shields.io/badge/Stellar-Wave-blue)](https://drips.network/wave/stellar)
10+
[![Issues](https://img.shields.io/github/issues/Shielded-Protocol/shielded-circuits)](https://github.com/Shielded-Protocol/shielded-circuits/issues)
1011

11-
## What this does
12+
---
1213

13-
These circuits implement the zero-knowledge proof system (Groth16 over BN254) that powers private transactions on Stellar Soroban. Users generate proofs off-chain using these circuits, which are then verified on-chain by the `groth16-verifier` contract.
14+
## Circuits
1415

15-
The repository includes circuits for deposits, withdrawals, Merkle inclusion proofs, and nullifier derivation.
16+
| Circuit | Inputs (private) | Inputs (public) | Purpose |
17+
|---|---|---|---|
18+
| `withdraw.circom` | secret, amount, tokenId, pathElements, pathIndices | root, nullifierHash, recipient, relayer, fee | Main withdrawal proof |
19+
| `deposit.circom` | secret, amount, tokenId || Commitment generation |
20+
| `merkle_proof.circom` | leaf, pathElements, pathIndices | root | Merkle inclusion proof |
21+
| `nullifier_hash.circom` | secret || Nullifier derivation |
1622

17-
## Quickstart
23+
**Proving system:** Groth16 · **Curve:** BN254 · **Hash:** Poseidon · **Depth:** 20
1824

19-
```bash
25+
---
26+
27+
## How the withdraw proof works
28+
29+
```
30+
Private: secret, amount, tokenId, Merkle path
31+
32+
33+
commitment = Poseidon(secret, amount, tokenId)
34+
35+
36+
Merkle proof: commitment ∈ tree with known root ──► Public: root
37+
38+
nullifier = Poseidon(secret, 1) ──────────────► Public: nullifierHash
39+
40+
recipient bound into proof ────────────────────────► Public: recipient
41+
```
42+
43+
The proof reveals nothing about the secret, amount, or which commitment is spent.
44+
45+
Quickstart
46+
# Prerequisites: Node 20+, circom 2.x, snarkjs
47+
48+
npm install -g circom snarkjs
2049
npm install
50+
51+
# Compile circuits (generates R1CS + WASM)
2152
npm run compile
53+
54+
# Run tests
2255
npm test
23-
```
2456

25-
## Architecture
57+
---
58+
59+
## Constraint counts (approximate)
60+
61+
| Circuit | Constraints | Notes |
62+
|---|---|---|
63+
| `withdraw` (depth 20) | ~26,000 | Dominated by Merkle path hashing |
64+
| `deposit` | ~200 | Simple Poseidon hash |
65+
| `merkle_proof` (depth 20) | ~24,000 | 20 × Poseidon2 |
66+
| `nullifier_hash` | ~100 | Single Poseidon2 |
2667

27-
[Link to shielded-docs](https://github.com/Shielded-Protocol/shielded-docs)
68+
See issue [#constraint-reduction](https://github.com/Shielded-Protocol/shielded-circuits/issues)
69+
for optimization work.
70+
71+
---
2872

2973
## Contributing
3074

31-
See [CONTRIBUTING.md](./CONTRIBUTING.md).
32-
Browse [Wave-ready issues](../../issues?q=label%3Astatus%3Awave-ready).
75+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
76+
77+
Browse [Wave-ready issues](https://github.com/Shielded-Protocol/shielded-circuits/issues?q=label%3Astatus%3Awave-ready+state%3Aopen).
78+
79+
---
3380

3481
## License
3582

0 commit comments

Comments
 (0)