Skip to content

Commit 1260861

Browse files
alinaT95claude
andauthored
Sync deposit ZKHALO2VERIFYWITHVK fixtures for chainId public input (#280)
* Sync deposit ZKHALO2VERIFYWITHVK fixtures for chainId public input The deposit circuit gained a chainId public input at index 4 (bridge branch pruvendo/pause-chainid-pi-multil2, commit c0da8a3), taking the PI count from 11 to 12. Because the ZKHALO2VERIFYWITHVK opcode is schema-agnostic (decode_instances_strict consumes any N × 32 B LE Fr payload, VK carries num_instance_columns), no executor code changes are needed — only test fixtures and PI-count metadata. - Resync tvm_vm/halo2_test_data/deposit_10proofs/ from deposit-prover/fixtures/deposit_10proofs (Hermez SRS, k=18, Sepolia chain-id 11155111; VkBlob sha256 006cca5ddd457065bef8469fc10dd231ad8fd13c895877c9deff5c51191dec05). - Update PI-layout comments, log strings, and README to reflect the 12-PI layout with chainId at index 4. - Add a length-assertion regression guard in test_zkhalo2_with_vk_deposit_10_real_proofs to catch future fixture desyncs (expected 384 B per public_inputs.bin). - Remove orphaned deposit_rlc_{vk_blob,proof,public_inputs,bundle}.bin singletons — the round_trip_deposit_rlc_* tests already load from deposit_10proofs/proof_00/*, so nothing referenced them. - Add a design-doc footnote (§4) recording that this 11 → 12 PI transition was absorbed with zero opcode changes, empirically validating the Q-WIRE-3 / Q-WIRE-4 schema-agnostic decisions. Verified: cargo test -r --lib -p tvm_vm -- halo2 → 41 passed, 0 failed (3 pre-existing #[ignore]s on fallback Circuit 1B unrelated to this change). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * tvm_vm: refresh deposit_10proofs fixtures against current bridge circuit_v2 Regenerated VkBlob + 10 proof triples against bridge/deposit-prover/src/circuit_v2.rs, keyed on Hermez SRS (s_g2 = 928fafb3…) at k=18. Sync driven by scripts/sync_deposit_opcode_fixtures_to_tvm_sdk.sh. Verified cryptographically: keygen-only regen from the current circuit yielded a byte-identical VkBlob to the checked-in fixture (sha256 9dacd998af5fd03af8097cb80a571df098c925bba235af61d920cc808360fae3), proving the VkBlob is in sync with circuit_v2 and Hermez-keyed. All 41 relevant halo2 tests pass, including test_zkhalo2_with_vk_deposit_10_real_proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7d52241 commit 1260861

30 files changed

Lines changed: 71 additions & 19 deletions

docs/zkhalo2verifywithvk_design.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ All length prefixes are `u32` LE. Producer-side cap: 16 MiB
8989
(`zk_halo2_with_vk_bundle::MAX_BUNDLE_BYTES`); the consumer fails
9090
structurally above that cap as a DoS guard.
9191

92+
> **Schema-agnosticism, validated empirically (2026-07-29).** The deposit
93+
> circuit added a `chainId` public input (11 → 12 PIs, bridge commit
94+
> `c0da8a3`). Adjusting to it required **zero** changes to
95+
> `zk_halo2_with_vk.rs` / `zk_halo2_with_vk_bundle.rs`; only the on-disk
96+
> fixtures under `tvm_vm/halo2_test_data/deposit_10proofs/` had to be
97+
> resynced. `decode_instances_strict` chunks `instances_bytes` into
98+
> 32-byte LE Fr elements without any hardcoded count, and the VK itself
99+
> carries `num_instance_columns` / per-column lengths — mismatches
100+
> surface as cryptographic `false` (see
101+
> `instance_count_mismatch_rejected_as_false`), not `FatalError`. This
102+
> is exactly the Q-WIRE-3 / Q-WIRE-4 outcome we designed for.
103+
92104
### Safety of VK deserialisation
93105

94106
The consumer deserialises the VK using

tvm_vm/doc/HERMEZ_KZG_MIGRATION_FOR_SERGEY.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ and need to be rebuilt against `kzg_bn254_20.srs` (Hermez):
8484

8585
**Deposit circuit fixtures (your circuit, your fixtures):**
8686
* `deposit_10proofs/*` — the 10-proof deposit-event fixture pack
87-
(`EthCircuitImpl<Fr, DepositEventCircuitV2>`, 11 public inputs).
88-
* `deposit_rlc_*.bin` — any `deposit_rlc_proof.bin`,
89-
`deposit_rlc_instances.bin`, `deposit_rlc_vk.bin`, and the packed
90-
`deposit_vk_blob.bin` (the `VkBlob`-format wrapper carrying the VK
91-
plus the RLC `EthCircuitParams` JSON).
87+
(`EthCircuitImpl<Fr, DepositEventCircuitV2>`, 12 public inputs since
88+
2026-07-22 bridge commit `c0da8a3``chainId` inserted at index 4).
89+
* ~~`deposit_rlc_*.bin`~~ — the singleton `deposit_rlc_proof.bin`,
90+
`deposit_rlc_public_inputs.bin`, `deposit_rlc_vk_blob.bin`,
91+
`deposit_rlc_bundle.bin` files were **removed on 2026-07-29**
92+
(branch `feature/deposit_circuit_chain_id_pi`). They were unreferenced
93+
by any test — the `round_trip_deposit_rlc_*` tests in
94+
`test_halo2_with_vk.rs` actually load from `deposit_10proofs/proof_00/*`,
95+
which supplies the same VK+proof+PI triple in the fresh 12-PI layout.
9296

9397
**Fallback (Circuit 1B) fixtures (my circuit, but *your* tvm-sdk
9498
fixtures + tests):**

tvm_vm/halo2_test_data/deposit_10proofs/README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,38 @@ These files exercise `ZKHALO2VERIFYWITHVK` in `tvm_vm` tests. They are the
44
**three-operand ABI** only:
55

66
```text
7-
vk_cell ← deposit_vk_blob.bin (VkBlob v2 RLC, 11 public inputs)
8-
public_inputs_cell ← proof_NN/public_inputs.bin (11 × 32 B LE Fr)
7+
vk_cell ← deposit_vk_blob.bin (VkBlob v2 RLC, 12 public inputs)
8+
public_inputs_cell ← proof_NN/public_inputs.bin (12 × 32 B LE Fr = 384 B)
99
proof_cell ← proof_NN/proof.bin (Blake2b SHPLONK)
1010
```
1111

1212
## KZG ceremony
1313

1414
Keyed on the **Hermez Perpetual Powers of Tau** SRS (`data/kzg_params_18.srs`,
1515
`s_g2 = 928fafb3…`), matching `KZG_S_G2_BYTES` on
16-
`feature/hermez-kzg-resurrection`. Regenerated 2026-07-13 via
17-
`deposit-prover` `export_deposit_proof_set` (VkBlob sha256
18-
`304c1c4ed1e4cf09a00fb1d83a0ae2ba42db2afead035ae089a4faa85346251a`).
16+
`feature/hermez-kzg-resurrection`. Regenerated 2026-08-07 via
17+
`deposit-prover` `export_deposit_proof_set` after the circuit gained a
18+
`chainId` public input at index 4 (bridge branch
19+
`pruvendo/pause-chainid-pi-multil2`, commit `c0da8a3`). VkBlob sha256
20+
`9dacd998af5fd03af8097cb80a571df098c925bba235af61d920cc808360fae3`
21+
update this line whenever the fixtures are resynced.
22+
23+
Public-input layout (12 × 32 B LE Fr, in order):
24+
25+
```
26+
0 depositId
27+
1 sender
28+
2 amount
29+
3 contractAddress
30+
4 chainId ← added 2026-07-22 (bound via EIP-1559 tx MPT proof)
31+
5 dappIdHigh
32+
6 dappIdLow
33+
7 anAccountHigh
34+
8 anAccountLow
35+
9 blockHashHigh
36+
10 blockHashLow
37+
11 promiseCommit (auto-appended by axiom-eth EthCircuitImpl)
38+
```
1939

2040
## What does **not** belong here
2141

@@ -36,7 +56,8 @@ From `acki-nacki-bridge` (sibling repo):
3656
cd deposit-prover
3757
cargo run --release --example export_deposit_proof_set -- \
3858
--set-dir fixtures/deposit_10proofs --count 10 \
39-
--degree 18 --max-data-byte-len 256 --max-log-num 20
59+
--degree 18 --max-data-byte-len 256 --max-log-num 20 \
60+
--chain-id 11155111 # Sepolia; select source chain for the fetch layer
4061
../scripts/sync_deposit_opcode_fixtures_to_tvm_sdk.sh
4162
```
4263

1 KB
Binary file not shown.
2.22 KB
Binary file not shown.
32 Bytes
Binary file not shown.
2.22 KB
Binary file not shown.
32 Bytes
Binary file not shown.
2.22 KB
Binary file not shown.
32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)