Overview
Implement complete trustless withdrawal flow for the orderbook system, enabling users to withdraw funds from the off-chain orderbook back to on-chain with ZK-verified state proofs.
Goals
- Add burn proof API endpoint to generate merkle proofs for withdrawals
- Enable Groth16 proving in void-toolkit for on-chain verification
- Complete executeWithdrawal contract verification with ZK-verified state roots
Technical Notes
Full Withdrawal Flow
- User calls
requestWithdrawal(token, amount, nonce) on contract → emits Withdraw event
- Orderbook app processes event via oracle, calls
handle_withdraw() which burns funds in state
- User fetches burn proof from API:
GET /get-burn-proof/{owner}/{nonce} → gets merkle proof + height
- User requests ZK proof at that height from the app
- User calls
executeWithdrawal() with both the burn merkle proof and ZK proof
- Contract verifies ZK proof → extracts state root from journal (not stored on-chain)
- Contract verifies merkle proof against the state root from the ZK proof
- Tokens transferred to user
Note: State roots are never stored on-chain. The ZK proof and merkle proof are verified together in the same transaction.
Key Data Formats
- Address type: 33 bytes (1 byte type + 32 bytes data)
- Burned key: 42 bytes
[BURNED:1][owner:33][nonce:8]
- Burned value: 97 bytes
[amount:32][asset:33][chain_id:32]
- Merkle trie uses SHA3-256 (Keccak) for hashing
Dependencies
- Sub-issues 1 and 2 can be implemented in parallel
- Sub-issue 3 depends on understanding exact proof format from sub-issue 1
Out of Scope
- Frontend UI changes for withdrawal flow
- Cross-chain withdrawal support (Solana)
Overview
Implement complete trustless withdrawal flow for the orderbook system, enabling users to withdraw funds from the off-chain orderbook back to on-chain with ZK-verified state proofs.
Goals
Technical Notes
Full Withdrawal Flow
requestWithdrawal(token, amount, nonce)on contract → emitsWithdraweventhandle_withdraw()which burns funds in stateGET /get-burn-proof/{owner}/{nonce}→ gets merkle proof + heightexecuteWithdrawal()with both the burn merkle proof and ZK proofNote: State roots are never stored on-chain. The ZK proof and merkle proof are verified together in the same transaction.
Key Data Formats
[BURNED:1][owner:33][nonce:8][amount:32][asset:33][chain_id:32]Dependencies
Out of Scope