Skip to content

Decryption PIR#18

Open
p0mvn wants to merge 11 commits into
mainfrom
decryption-pir
Open

Decryption PIR#18
p0mvn wants to merge 11 commits into
mainfrom
decryption-pir

Conversation

@p0mvn

@p0mvn p0mvn commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds decryption-db crate: flat, append-only store of DecryptionLeaf values with per-block rollback, sub-shard PIR database builder, and checksummed snapshot persistence. Shares shard/sub-shard geometry with witness PIR but requires no Merkle hashing.
  • Adds decryption-server crate: Axum HTTP server (/health, /metadata, /params, /query), rebuild_pir function, StubPirEngine for testing, real YPIR engine (feature-gated), and DecryptionDb snapshot I/O.

Builds on the decryption-types crate and commitment-ingest parser extensions already on main.

Remaining work (on this branch)

  • Integrate decryption into combined-server (follow loop, routes, health, snapshots)
  • Create decryption-client crate (YPIR client, connect/query/decode)
  • Integration test (e2e mainnet round-trip)
  • Wallet SDK / iOS integration
  • Review, cleanup, documentation

Test plan

  • decryption-db: 12 unit tests (append, rollback, sub-shard queries, PIR DB layout, snapshot round-trip)
  • decryption-server: 5 tests (stub engine, rebuild, full HTTP round-trip)
  • Clippy clean, workspace --lib check passes

Made with Cursor

p0mvn added 8 commits June 6, 2026 14:26
Position-indexed append-only store of DecryptionLeaf values with
per-block rollback, sub-shard queries, PIR database serialization
(8192 rows × 29696 bytes), and checksummed snapshot persistence.
Shares the same shard/sub-shard geometry as the witness PIR database
but requires no Merkle hashing.

Made-with: Cursor
Axum HTTP server for decryption PIR: /health, /metadata, /params,
/query routes. Includes StubPirEngine for testing, real YPIR engine
(feature-gated), snapshot I/O for DecryptionDb persistence, and a
full HTTP round-trip test against the stub engine.

Made-with: Cursor
New `decryption` feature flag (implies `witness`) that adds:
- Initial sync: loads DecryptionDb snapshot or creates one with the
  same window offset as the witness tree, catches up via block
  fetching with completing-block spillover handling
- Follow loop: single-pass extraction of both commitments and
  decryption leaves using extract_commitments_and_decryption,
  append/rollback in lockstep with the witness tree
- PIR rebuild after each block batch alongside witness and nullifier
- Routes nested under /decrypt, decryption health in /health
- Periodic snapshot persistence for DecryptionDb

Made-with: Cursor
Runs decryption-types, decryption-db, and decryption-server unit tests
on PRs that touch witness/ or the decryption crates. Adds a dedicated
path filter and includes decryption in Slack failure notifications.

Made-with: Cursor
- Validate tree_size >= leaf_offset in snapshot deserialization to
  prevent usize underflow on corrupted data (+ test)
- Enforce shard alignment in DecryptionDb::with_offset in all builds,
  not just debug (was debug_assert, now assert)
- Handle missing orchard_commitment_tree_size in catch_up_decryption
  windowed spillover path — log warning and skip instead of silently
  treating as zero
- Log the actual error when decryption snapshot load fails in the
  combined-server instead of swallowing it
- Add populated_shards to DecryptionMetadata and HealthResponse for
  parity with WitnessMetadata
- Remove unused deps: witness-types from decryption-db, serde_json
  from decryption-server
- Fix duplicate comment in combined-server follow loop
- Cleaner match pattern for dec_latest catch-up logic
- Document from_bytes trailing-byte behavior
- Update CLI help text to mention decryption/ subdirectory

Made-with: Cursor
- Expand round-trip test to exercise /health (verify populated_shards,
  phase, anchor_height) and /metadata (verify window geometry)
- Add 503 test: /query and /metadata return SERVICE_UNAVAILABLE when
  PIR state hasn't been built yet
- Verify populated_shards and window_start_shard in rebuild_pir test

Made-with: Cursor
@p0mvn
p0mvn force-pushed the decryption-pir branch from 380613b to c707703 Compare June 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant