Skip to content

Commit 83c4c38

Browse files
author
tilo-14
committed
Update READMEs and fix paths
- Root README: better basic ops formatting, fix zk-id path - zk-merkle-proof README: reformatted with proper structure - zk-nullifier README: clearer intro explaining nullifier properties - zk-id: update program ID, dependencies
1 parent 58821a5 commit 83c4c38

8 files changed

Lines changed: 2169 additions & 155 deletions

File tree

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
For simple client side distribution visit [this example](https://github.com/Lightprotocol/example-token-distribution).
1313

1414
### Basic Operations
15-
- **[create-nullifier](./basic-operations/anchor/create-nullifier)** - Basic Anchor example to create nullifiers.
16-
- **[basic-operations/anchor](./basic-operations/anchor/)** - Anchor program with Rust and TypeScript tests
17-
- **[basic-operations/native-rust](./basic-operations/native-rust/)** - Native Solana program with light-sdk and Rust tests.
1815

19-
Basic Operations include:
20-
- **create** - Initialize a new compressed account.
21-
- **update** - Modify data in an existing compressed account.
22-
- **close** - Clear account data and preserve its address.
23-
- **reinit** - Reinitialize a closed account with the same address.
24-
- **burn** - Permanently delete a compressed account.
16+
- **[create-nullifier](./basic-operations/anchor/create-nullifier)** - Basic Anchor example to create nullifiers for payments.
17+
- **create** - Initialize a new compressed account
18+
- [Anchor](./basic-operations/anchor/create) | [Native](./basic-operations/native/programs/create)
19+
- **update** - Modify data in an existing compressed account
20+
- [Anchor](./basic-operations/anchor/update) | [Native](./basic-operations/native/programs/update)
21+
- **close** - Clear account data and preserve its address
22+
- [Anchor](./basic-operations/anchor/close) | [Native](./basic-operations/native/programs/close)
23+
- **reinit** - Reinitialize a closed account with the same address
24+
- [Anchor](./basic-operations/anchor/reinit) | [Native](./basic-operations/native/programs/reinit)
25+
- **burn** - Permanently delete a compressed account
26+
- [Anchor](./basic-operations/anchor/burn) | [Native](./basic-operations/native/programs/burn)
2527

2628
### Counter Program
2729

@@ -47,7 +49,7 @@ Full compressed account lifecycle (create, increment, decrement, reset, close):
4749

4850
### zk-id Program
4951

50-
- **[zk-id](./zk-id)** - A minimal zk id Solana program that uses zero-knowledge proofs for identity verification with compressed accounts.
52+
- **[zk-id](./zk/zk-id)** - A minimal zk id Solana program that uses zero-knowledge proofs for identity verification with compressed accounts.
5153

5254

5355
## Light Protocol dependencies

zk/zk-id/package-lock.json

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zk/zk-id/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"test": "ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
1414
},
1515
"dependencies": {
16+
"@coral-xyz/borsh": "^0.30.1",
17+
"@noble/hashes": "^1.3.2",
1618
"circomlib": "2.0.5",
1719
"circomlibjs": "0.1.7",
1820
"@coral-xyz/anchor": "0.31.1",

zk/zk-id/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use light_sdk::{
2020
};
2121
use light_sdk_types::CpiSigner;
2222

23-
declare_id!("HNqStLMpNuNJqhBF1FbGTKHEFbBLJmq8RdJJmZKWz6jH");
23+
declare_id!("8HYAuAkoLp2UG4mgkqUcJBXo2bzaaKy8nBL62L4S3SSB");
2424

2525
pub const LIGHT_CPI_SIGNER: CpiSigner =
26-
derive_light_cpi_signer!("HNqStLMpNuNJqhBF1FbGTKHEFbBLJmq8RdJJmZKWz6jH");
26+
derive_light_cpi_signer!("8HYAuAkoLp2UG4mgkqUcJBXo2bzaaKy8nBL62L4S3SSB");
2727

2828
pub const ISSUER: &[u8] = b"issuer";
2929
pub const CREDENTIAL: &[u8] = b"credential";

zk/zk-merkle-proof/README.md

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,82 @@
1-
# Merkle Proof for ZK Applications
1+
# Minimal Merkle Proof Example
22

3-
A simple example program that verifies ZK proofs of compressed account existence in a Merkle tree.
3+
Proves compressed account existence without revealing the Merkle path or leaf position.
44

5-
## Instructions
5+
The prover knows which account exists in the state tree. The verifier only learns that some account with the given data hash exists - not where it is or how to find it.
66

7-
| Instruction | Description |
8-
|-------------|-------------|
9-
| `create_account` | Creates compressed account with address and data hash |
10-
| `verify_account` | Verifies ZK proof of account existence in state tree |
7+
## Program Instructions
8+
9+
### 1. `create_account`
10+
11+
Creates a compressed account with a data hash. The account is stored in Light Protocol's state Merkle tree.
12+
13+
### 2. `verify_account`
14+
15+
Verifies a Groth16 proof that the account exists in the state tree. Does not modify state - only checks the proof against the current Merkle root.
16+
17+
**Properties:**
18+
19+
- The Merkle path (26 siblings) stays private
20+
- The leaf position stays private
21+
- The account address stays private
22+
- Only the data hash, discriminator, and Merkle root are public
1123

1224
## Circuit
1325

14-
5 public inputs: `owner_hashed`, `merkle_tree_hashed`, `discriminator`, `data_hash`, `expectedRoot`
26+
5 public inputs:
27+
28+
- `owner_hashed` - program ID
29+
- `merkle_tree_hashed` - state tree pubkey
30+
- `discriminator` - account type
31+
- `data_hash` - account data
32+
- `expectedRoot` - current Merkle root
33+
34+
Account hash:
1535

16-
Account hash computation:
1736
```
18-
hash = Poseidon(owner_hashed, leaf_index, merkle_tree_hashed, address, discriminator + DOMAIN, data_hash)
37+
Poseidon(owner_hashed, leaf_index, merkle_tree_hashed, address, discriminator + DOMAIN, data_hash)
1938
```
2039

21-
## Project Structure
40+
## Setup
2241

42+
```bash
43+
./scripts/setup.sh
2344
```
24-
zk-merkle-proof/
25-
├── circuits/
26-
│ ├── account_merkle_proof.circom
27-
│ ├── compressed_account.circom
28-
│ └── merkle_proof.circom
29-
├── src/lib.rs
30-
├── tests/test.rs
31-
└── scripts/setup.sh
45+
46+
This script will:
47+
48+
1. Install npm dependencies
49+
2. Download the Powers of Tau ceremony file
50+
3. Compile the circom circuit
51+
4. Generate the proving key (zkey)
52+
5. Export the verification key
53+
54+
## Build and Test
55+
56+
**Build:**
57+
58+
```bash
59+
cargo build-sbf
3260
```
3361

34-
## Build & Test
62+
**Rust tests:**
3563

3664
```bash
37-
./scripts/setup.sh
38-
cargo build-sbf && cargo test-sbf
65+
cargo test-sbf -- --nocapture
3966
```
4067

41-
## See Also
68+
## Structure
4269

43-
- [zk-id](../zk-id) - Credential verification with nullifiers
44-
- [zk-nullifier](../zk-nullifier) - Nullifier example with batch support
70+
```
71+
zk-merkle-proof/
72+
├── circuits/
73+
│ ├── account_merkle_proof.circom # Main circuit
74+
│ ├── compressed_account.circom # Account hash computation
75+
│ └── merkle_proof.circom # 26-level tree traversal
76+
├── src/
77+
│ └── lib.rs # Solana program with Groth16 verification
78+
├── tests/
79+
│ └── test.rs # Rust integration tests
80+
└── scripts/
81+
└── setup.sh # Circuit compilation and setup
82+
```

0 commit comments

Comments
 (0)