Documentation Index
Fetch the complete documentation index at: https://mintlify.com/collinsville22/Sable/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Garaga is a high-performance ZK proof verification library for StarkNet that enables on-chain verification of Groth16 BN254 proofs. Sable uses Garaga to verify zero-knowledge proofs for all shielded pool withdrawals, ensuring full privacy without trusted relayers.Garaga powers all Sable shielded pools, verifying Groth16 proofs on-chain for every private withdrawal.
What is Garaga?
Garaga is a Cairo library for verifying cryptographic proofs on StarkNet:- Groth16 BN254 verification: Industry-standard ZK proof system
- On-chain verification: No trusted parties required
- Optimized for Cairo: Native StarkNet implementation
- Gas-efficient: Compressed proof verification
Key Features
- Groth16 Support: Verify proofs generated by snarkjs, circom, or other Groth16 tools
- BN254 Curve: Compatible with Ethereum’s zkSNARK infrastructure
- Poseidon Hashing: StarkNet-native hash function for efficient in-circuit operations
- Proof Compression: Minimize on-chain verification costs
How Sable Integrates with Garaga
Sable uses Garaga to verify withdrawal proofs in all shielded pool contracts, enabling zero-knowledge privacy for deposits and withdrawals.Shielded Pool Architecture
Groth16 BN254 Proof System
Garaga verifies Groth16 proofs, one of the most efficient zkSNARK schemes.Proof Components
A Groth16 proof consists of 3 elliptic curve points:Public Inputs (V4 Circuit)
Sable’s V4 shielded pools use 7 public inputs:Contract Addresses
Garaga Groth16 Verifier V4 (Current)
The active verifier contract for all V4 shielded pools.Garaga Groth16 Verifier V3 (Legacy)
Previous version for V3 shielded pools (6 public inputs).Shielded Pool Integration
Sable’s shielded pools verify withdrawal proofs via Garaga.Deposit Flow (No Proof Required)
Withdrawal Flow (Proof Verification)
Poseidon Hashing
Garaga includes support for Poseidon, a ZK-friendly hash function optimized for StarkNet.Why Poseidon?
- Efficient in circuits: Requires fewer constraints than SHA-256 or Keccak
- Native to StarkNet: StarkNet VM has Poseidon built-in
- Fast verification: Significantly reduces proof generation time
Poseidon in Sable
Sable uses Poseidon for two critical operations:-
Commitment Generation:
-
Nullifier Hash:
Example: Generating a Commitment
Proof Generation (Client-Side)
Users generate Groth16 proofs in the browser using snarkjs.Proof Generation Flow
Circuit Files
Sable ships with precompiled circuit WASM and proving keys:Which Sable Features Use Garaga?
Sentinel Lending Pool
Private WBTC Deposits4 denominations: 0.0002, 0.0004, 0.0006, 0.0008 BTCVerified by Garaga V4 verifier.
Delta Neutral Yield Pool
Private WBTC Deposits4 denominations: 0.00036, 0.00072, 0.00108, 0.00144 BTCVerified by Garaga V4 verifier.
Stablecoin Vault
Private USDC Deposits4 denominations: 10, 25, 50, 100 USDCVerified by Garaga V4 verifier.
Swap Pool
Private Token Swaps4 input denominations: 0.0002, 0.0004, 0.0006, 0.0008 BTCSwap WBTC → ETH/USDC/STRK privately.Verified by Garaga V4 verifier.
Circuit Versions
Sable has evolved through multiple ZK circuit versions.| Version | Proof System | Public Inputs | Verifier | Status |
|---|---|---|---|---|
| V1 | UltraHonk (Noir) | Variable | @aztec/bb.js | Legacy |
| V2 | Groth16 BN254 | Variable | snarkjs + Garaga | Legacy |
| V3 | Groth16 BN254 | 6 | Garaga 0x0410... | Legacy |
| V4 | Groth16 BN254 | 7 | Garaga 0x0332... | Current |
V4 Improvements
- Batch info: Added
batchStartandbatchSizeas public inputs - Auto-deployment: Batches of 3 deposits auto-deploy to Merkle tree
- Better UX: No manual batch deployment step required
- Gas-efficient: Optimized proof verification
Security Properties
Zero-Knowledge Privacy
Garaga verification ensures:- Commitment Validity: Proof proves the commitment exists in the Merkle tree
- Nullifier Uniqueness: Each nullifier can only be spent once
- No Linking: On-chain observer cannot link deposit to withdrawal
- No Trusted Parties: Verification is purely cryptographic (no relayer trust)
Attack Resistance
- Double-spend prevention: Nullifier hashes stored on-chain
- Invalid proof rejection: Garaga verifier rejects malformed proofs
- Root validation: Only proofs against known Merkle roots accepted
- Commitment privacy: Poseidon preimage resistance protects secret/nullifier
Frontend Integration
Sable’s privacy page generates and verifies proofs entirely in the browser.External Resources
Garaga Documentation
Official Garaga library documentation
Garaga GitHub
Garaga source code and examples
Groth16 Paper
Original Groth16 zkSNARK paper
Poseidon Hash
Poseidon hash function specification
Integration Source Code:
- Proof generation:
~/workspace/source/src/lib/privacy/prover.ts - Poseidon hashing:
~/workspace/source/src/lib/privacy/note.ts - Shielded pool contract:
~/workspace/source/contracts/src/shielded_pool_v4.cairo