refactor(stm): Ensuring type consistency for SNARK circuit - #3071
Merged
Conversation
damrobi
force-pushed
the
damrobi/msnark/3036-stm-type-consistency
branch
from
March 6, 2026 10:42
a0abf46 to
bf651f8
Compare
jpraynaud
reviewed
Mar 6, 2026
jpraynaud
requested review from
Copilot
and removed request for
curiecrypt and
hjeljeli32
March 6, 2026 12:10
There was a problem hiding this comment.
Pull request overview
This PR updates the Halo2 STM circuit boundary to better align with STM protocol types by introducing a checked constructor that safely narrows STM u64 parameters into the circuit’s u32 internal representation, and updates golden tests accordingly.
Changes:
- Removed the Halo2-local
LotteryIndexalias and standardized on the crate-levelLotteryIndex(u64). - Added
StmCircuit::try_new(Parameters, merkle_tree_depth)to validateu64 -> u32narrowing at circuit creation time. - Updated golden witness builders and cases to use
LotteryIndex-compatible indices and updated circuit setup to usetry_new.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/circuits/halo2/types.rs | Removes Halo2-local LotteryIndex alias to avoid type divergence from STM domain types. |
| mithril-stm/src/circuits/halo2/circuit.rs | Adds try_new for checked narrowing of STM parameters and updates witness index assignment to use LotteryIndex directly. |
| mithril-stm/src/circuits/halo2/golden/helpers.rs | Updates golden helpers to use LotteryIndex in witness entries and constructs StmCircuit via try_new. |
| mithril-stm/src/circuits/halo2/golden/cases/positive.rs | Adjusts test indices to remain compatible with LotteryIndex/u64-based APIs. |
| mithril-stm/src/circuits/halo2/golden/cases/negative.rs | Adjusts negative test indices to remain compatible with LotteryIndex/u64-based APIs. |
added 7 commits
March 9, 2026 16:51
added 5 commits
March 9, 2026 16:51
damrobi
force-pushed
the
damrobi/msnark/3036-stm-type-consistency
branch
from
March 9, 2026 15:56
af1e102 to
021a73d
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.
Content
This PR includes modifications to the creation function of
StmCircuitto ensure that the types received from the STM protocol fit in the types of the circuit.It also includes tests and results on the impact of changing the types within the circuit on the numbers of constraints of the circuit. Those results are added to the SNARK MVP Book.
Pre-submit checklist
Comments
Issue(s)
Closes to #3036