feat: wire chonk proof compression through bbjs API for network serialization#21065
Merged
Conversation
0c03f19 to
15f0ab0
Compare
15f0ab0 to
30c7723
Compare
ludamad
approved these changes
Mar 24, 2026
…lization Resolves #21306 ## Summary Wires the chonk proof compression/decompression APIs (from PR #20645) through the bbjs TypeScript layer and into the network serialization path. This enables ~1.7x smaller proof serialization for P2P gossip (~52KB to ~35KB per tx). ### How it saves bandwidth `ChonkProof` always has `fields` (1632 field elements) in memory for local use. It optionally carries `compressedProof` bytes. `toBuffer()` picks one or the other: - If `compressedProof` is set: serializes only the compressed bytes (~35KB) - Otherwise: serializes all 1632 field elements (~52KB) On the receiving side, `fromBuffer()` detects the format from the first uint32 and either reads fields directly or decompresses them. Compression is unconditional when proving. ### Size-based format detection - **Legacy (uncompressed)**: `[field_count=1632: uint32] [fields...]` — total ~52KB - **Compressed**: `[byte_count: uint32] [compressed_bytes]` — total ~35KB If first uint32 == `CHONK_PROOF_LENGTH` (1632), it's the field count for legacy format. Otherwise, it's the compressed byte count. ### Changes - **`barretenberg/ts`**: `compressProof()`/`decompressProof()` on `AztecClientBackend`, `prove()` returns `AztecClientProveResult` with optional `compressedProof` - **`yarn-project/stdlib` (ChonkProof)**: Size-based dual-format serialization, `fromCompressedBytes()` via `BarretenbergSync` - **`yarn-project/bb-prover`**: `createChonkProof()` uses `{ compress: true }` ### Tests - 9 original ChonkProof/ChonkProofWithPublicInputs tests - Integration test asserting compressed proof is smaller than uncompressed ## Test plan - Unit tests pass for ChonkProof serialization - Integration test verifies compression roundtrip and size reduction via real bb WASM API - E2E test with P2P propagation using compressed proofs Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com>
bfd7991 to
60dba2a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #21306
Summary
Wires the chonk proof compression/decompression APIs (from PR #20645) through the bbjs TypeScript layer and into the network serialization path. This enables ~1.7x smaller proof serialization for P2P gossip (~52KB to ~35KB per tx).
How it saves bandwidth
ChonkProofalways hasfields(1632 field elements) in memory for local use. It optionally carriescompressedProofbytes.toBuffer()picks one or the other:compressedProofis set: serializes only the compressed bytes (~35KB)On the receiving side,
fromBuffer()detects the format from the first uint32 and either reads fields directly or decompresses them. Compression is unconditional when proving.Size-based format detection
[field_count=1632: uint32] [fields...]— total ~52KB[byte_count: uint32] [compressed_bytes]— total ~35KBIf first uint32 ==
CHONK_PROOF_LENGTH(1632), it's the field count for legacy format. Otherwise, it's the compressed byte count.Changes
barretenberg/ts:compressProof()/decompressProof()onAztecClientBackend,prove()returnsAztecClientProveResultwith optionalcompressedProofyarn-project/stdlib(ChonkProof): Size-based dual-format serialization,fromCompressedBytes()viaBarretenbergSyncyarn-project/bb-prover:createChonkProof()uses{ compress: true }Tests
Test plan