Skip to content

Commit c58969f

Browse files
authored
Merge pull request #3204 from input-output-hk/hjeljeli32/3125-add-golden-tests-ivc
Add golden tests for IVC
2 parents b28ea08 + f0276bc commit c58969f

20 files changed

Lines changed: 2710 additions & 6 deletions

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-stm/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.10.5 (04-23-2026)
9+
10+
### Added
11+
12+
- Added Layer D golden tests for the `halo2_ivc` prototype, covering committed asset readers, deterministic asset generators, and a positive golden suite validating stored recursive proofs, the genesis base case, same-epoch and next-epoch recursive steps, and a chained-flow replay check.
13+
814
## 0.10.4 (04-22-2026)
915

1016
### Changed

mithril-stm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-stm"
3-
version = "0.10.4"
3+
version = "0.10.5"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
homepage = { workspace = true }
@@ -75,6 +75,7 @@ num-traits = { version = "0.2.19", optional = true }
7575
rug = { version = "1.29.0", optional = true }
7676

7777
[dev-dependencies]
78+
blake2b_simd = "1.0.3"
7879
criterion = { version = "0.8.2", features = ["html_reports"] }
7980
num-bigint = "0.4.6"
8081
num-rational = "0.4.2"
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Golden Test Assets
2+
3+
## Purpose
4+
5+
`halo2_ivc` golden tests rely on a small committed asset set so normal test runs
6+
can validate recursive behavior without regenerating the full proving flow.
7+
8+
The expensive proofs are generated manually through ignored tests in
9+
`mithril-stm/src/circuits/halo2_ivc/tests/golden/generators/tests.rs`.
10+
The positive golden tests load those stored outputs at compile time via
11+
`include_bytes!`, while regeneration keeps using the file-based readers/writers.
12+
13+
## Asset Set
14+
15+
The committed asset files live under:
16+
17+
`mithril-stm/src/circuits/halo2_ivc/tests/golden/assets`
18+
19+
Reader helpers live in:
20+
21+
`mithril-stm/src/circuits/halo2_ivc/tests/golden/asset_readers.rs`
22+
23+
The positive golden tests assume these committed asset files are present in the
24+
worktree at compile time. If they were removed locally, restore them from git
25+
before rebuilding or regenerating:
26+
27+
```bash
28+
git restore mithril-stm/src/circuits/halo2_ivc/tests/golden/assets
29+
```
30+
31+
The current asset set is:
32+
33+
- `verification_context.bin`
34+
- static verifier-side context
35+
- contains the global public inputs, recursive verifying key, combined fixed
36+
bases, and shared verifier-side SRS data
37+
38+
- `recursive_chain_state.bin`
39+
- stored recursive chain checkpoint
40+
- contains the global public inputs, current recursive state, previous
41+
recursive proof, and current accumulator
42+
43+
- `recursive_step_output.bin`
44+
- output of extending the stored chain checkpoint by one more recursive step
45+
- contains the final recursive proof, next accumulator, next state, and the
46+
exact certificate proof artifact folded into that stored step
47+
48+
## Dependency Order
49+
50+
The assets have a simple dependency chain:
51+
52+
1. `verification_context.bin`
53+
2. `recursive_chain_state.bin`
54+
3. `recursive_step_output.bin`
55+
56+
The chained-flow golden test replays the stored recursive step exactly, and the
57+
stored `next_accumulator` depends on the exact certificate proof bytes embedded
58+
inside `recursive_step_output.bin`.
59+
60+
## Generation Model
61+
62+
Asset generation uses:
63+
64+
- deterministic shared setup
65+
- deterministic universal KZG parameters built with `ParamsKZG::unsafe_setup(...)`
66+
- OS randomness for signatures and proof generation, aligned with the current
67+
generator flow
68+
69+
The public-state evolution is reproducible at the semantic level. Proof-bearing
70+
assets are not expected to be byte-identical across regenerations.
71+
72+
In practice:
73+
74+
- `verification_context.bin` should stay stable unless verifier-side setup changes
75+
- `recursive_chain_state.bin` may change bytewise because it contains a proof
76+
- `recursive_step_output.bin` may change bytewise because it contains both the
77+
final recursive proof and the exact certificate proof used for that step
78+
79+
## How To Regenerate Everything
80+
81+
Run these commands from the repository root:
82+
83+
```bash
84+
cargo test -p mithril-stm --features future_snark --release generate_verification_context_only -- --ignored --nocapture
85+
cargo test -p mithril-stm --features future_snark --release generate_recursive_chain_state_only -- --ignored --nocapture
86+
cargo test -p mithril-stm --features future_snark --release generate_recursive_step_output_only -- --ignored --nocapture
87+
```
88+
89+
These commands intentionally use `--release` because asset generation is a
90+
manual workflow dominated by real proof generation.
91+
92+
These commands correspond to the ignored generator entrypoints in
93+
`mithril-stm/src/circuits/halo2_ivc/tests/golden/generators/tests.rs`:
94+
95+
- `generate_verification_context_only`
96+
- `generate_recursive_chain_state_only`
97+
- `generate_recursive_step_output_only`
98+
99+
Recommended order:
100+
101+
1. regenerate `verification_context.bin`
102+
2. regenerate `recursive_chain_state.bin`
103+
3. regenerate `recursive_step_output.bin`
104+
105+
## Partial Regeneration
106+
107+
If only the representative recursive step output changed, it is sufficient to rerun:
108+
109+
```bash
110+
cargo test -p mithril-stm --features future_snark --release generate_recursive_step_output_only -- --ignored --nocapture
111+
```
112+
113+
That command regenerates:
114+
115+
- `recursive_step_output.bin`
116+
117+
It does not require regenerating `verification_context.bin` or
118+
`recursive_chain_state.bin` unless their inputs changed.
119+
120+
## When Regeneration Is Needed
121+
122+
Regenerate the assets when one of these changes:
123+
124+
- recursive circuit logic
125+
- recursive public input or state layout
126+
- accumulator encoding
127+
- recursive or certificate verifying key inputs
128+
- verifier-side SRS data format
129+
- generation setup or proving randomness model
130+
- chained-flow replay contract for the recursive step assets
131+
132+
## Temporary Certificate Dependency
133+
134+
The current asset generation depends on the temporary local certificate relation
135+
in
136+
`mithril-stm/src/circuits/halo2_ivc/tests/test_certificate.rs`.
137+
138+
This is a temporary compatibility step. It keeps recursive asset generation
139+
close to the original prototype flow while the STM non-recursive Halo2
140+
certificate circuit continues to evolve.
141+
142+
The intended follow-up is to remove this temporary local relation and generate
143+
the assets directly from the current STM Halo2 certificate circuit.

0 commit comments

Comments
 (0)