Skip to content

feat: wire chonk proof compression through bbjs API for network serialization#21065

Merged
AztecBot merged 1 commit into
nextfrom
claudebox/c270dd2b47c7c1c9-1
Mar 24, 2026
Merged

feat: wire chonk proof compression through bbjs API for network serialization#21065
AztecBot merged 1 commit into
nextfrom
claudebox/c270dd2b47c7c1c9-1

Conversation

@AztecBot

@AztecBot AztecBot commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

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

@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 3, 2026
@ludamad ludamad added ci-draft Run CI on draft PRs. ci-full Run all master checks. labels Mar 3, 2026
@johnathan79717 johnathan79717 force-pushed the claudebox/c270dd2b47c7c1c9-1 branch from 0c03f19 to 15f0ab0 Compare March 17, 2026 17:02
@johnathan79717 johnathan79717 changed the base branch from next to merge-train/barretenberg March 17, 2026 17:09
@johnathan79717 johnathan79717 force-pushed the claudebox/c270dd2b47c7c1c9-1 branch from 15f0ab0 to 30c7723 Compare March 17, 2026 17:12
@johnathan79717 johnathan79717 self-assigned this Mar 17, 2026
@johnathan79717 johnathan79717 marked this pull request as ready for review March 17, 2026 17:57
@johnathan79717 johnathan79717 requested a review from ludamad March 17, 2026 17:57
Base automatically changed from merge-train/barretenberg to next March 24, 2026 00:19
…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>
@AztecBot AztecBot force-pushed the claudebox/c270dd2b47c7c1c9-1 branch from bfd7991 to 60dba2a Compare March 24, 2026 16:29
@AztecBot AztecBot enabled auto-merge March 24, 2026 16:29
@AztecBot AztecBot added this pull request to the merge queue Mar 24, 2026
Merged via the queue into next with commit a651f12 Mar 24, 2026
19 checks passed
@AztecBot AztecBot deleted the claudebox/c270dd2b47c7c1c9-1 branch March 24, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. ci-full Run all master checks. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire chonk proof compression through bbjs API for network serialization

3 participants