Skip to content

Use circuit hash instead of pp_root to uniquely identify the circuit - #634

Merged
ilyalesokhin-starkware merged 1 commit into
mainfrom
ilya/circuit-hash
Jul 22, 2026
Merged

ilyalesokhin-starkware merged 1 commit into
mainfrom
ilya/circuit-hash

Conversation

@ilyalesokhin-starkware

@ilyalesokhin-starkware ilyalesokhin-starkware commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Monday task: Consider propagating sizes instead of hardcoding them (similar to what we did with ppt)

Summary

In the multiverifier, each verified inner circuit is now identified in the outer output preimage by a circuit hash — blake2s(config_words ‖ preprocessed_root) — instead of the bare preprocessed_root.

A preprocessed root does not, by itself, commit to the config it is interpreted under (per-component trace log sizes + the FRI log_blowup_factor). Emitting only the root in the multiverifier's output leaves it open to a reinterpretation attack: a valid preprocessed root can be paired with config_words other than the ones actually used, so a consumer of the output hash cannot tell which configuration the root was verified under. Hashing config_words together with the root binds the full (config, root) pair, so the output commits to the exact configuration the circuit was verified with.

🤖 Generated with Claude Code

@cursor

cursor Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes the multiverifier’s public output commitment semantics (breaking for anyone hashing the old preimage) in exchange for binding config to identity; scope is limited to circuit_multiverifier and test fixtures.

Overview
The multiverifier’s outer Blake2s output preimage now uses each inner circuit’s circuit_hash (config + preprocessed root) paired with that circuit’s reserved output words, instead of the bare preprocessed root plus outputs. That ties the emitted digest to the exact verifier configuration (component log sizes and FRI blowup), not just the Merkle root.

build_multiverifier_circuit pulls statement.circuit_hash into the hash payload; tests add leaf_circuit_hash / rename the host Blake helper to native_blake_u32s, and fixtures (including MULTIVERIFIER_PREPROCESSED_ROOT) are updated to match the new binding.

Reviewed by Cursor Bugbot for commit df80d01. Bugbot is set up for automated code reviews on this repo. Configure here.

@reviewable-StarkWare

Copy link
Copy Markdown
Collaborator

This change is Reviewable

@ilyalesokhin-starkware
ilyalesokhin-starkware marked this pull request as draft July 9, 2026 11:37
@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from main to graphite-base/634 July 13, 2026 07:13
@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from graphite-base/634 to ilya/mix-circuit-hash July 13, 2026 07:13

ilyalesokhin-starkware commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from ilya/mix-circuit-hash to graphite-base/634 July 13, 2026 08:18
@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from graphite-base/634 to ilya/mix-circuit-hash July 15, 2026 10:12
@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from ilya/mix-circuit-hash to graphite-base/634 July 15, 2026 10:16
@ilyalesokhin-starkware
ilyalesokhin-starkware changed the base branch from graphite-base/634 to main July 21, 2026 15:48
@ilyalesokhin-starkware
ilyalesokhin-starkware marked this pull request as ready for review July 21, 2026 15:48

@leo-starkware leo-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leo-starkware reviewed 6 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on Gali-StarkWare and ilyalesokhin-starkware).


crates/circuit_multiverifier/src/test_utils.rs line 72 at r2 (raw file):

/// Computes the circuit hash for a given preprocessed root with the multiverifier's shared config.
pub fn multiverifier_leaf_circuit_hash(preprocessed_root: [u32; 8]) -> [u32; 8] {

Suggestion:

leaf_circuit_hash(preprocessed_root: [u32; 8], preprocessed_column_log_sizes: OrderedHashMap<PreProcessedColumnId, u32>)

crates/circuit_multiverifier/src/verify_test.rs line 367 at r2 (raw file):

    // followed by the eight raw output words.
    let cairo_input_preimage_words: Vec<u32> =
        multiverifier_leaf_circuit_hash(PRIVACY_CAIRO_VERIFIER_PREPROCESSED_ROOT)

Suggestion:

leaf_circuit_hash(PRIVACY_CAIRO_VERIFIER_PREPROCESSED_ROOT, shared_config.preprocessed_column_log_sizes)

@leo-starkware leo-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leo-starkware made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Gali-StarkWare and ilyalesokhin-starkware).


crates/circuit_multiverifier/src/verify.rs line 90 at r2 (raw file):

        verify(&mut context, &proof_vars, &shared_config.proof_config, &statement);
        // Reuse the statement's `circuit_hash` (the same hash mixed into the sub-proof's channel)
        // so the outer hash commits to it.

This comment is a bit confusing. Maybe claude can improve it

Code quote:

        // Reuse the statement's `circuit_hash` (the same hash mixed into the sub-proof's channel)
        // so the outer hash commits to it.

@ilyalesokhin-starkware

Copy link
Copy Markdown
Contributor Author

crates/circuit_multiverifier/src/test_utils.rs line 72 at r2 (raw file):

/// Computes the circuit hash for a given preprocessed root with the multiverifier's shared config.
pub fn multiverifier_leaf_circuit_hash(preprocessed_root: [u32; 8]) -> [u32; 8] {

I passed the shared config.

Note, however, that it is a test_utils function.
So I think it should be optimized for the call-sites.

for example it return u32s and not Blake2sHash like compute_circuit_hash(

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyalesokhin-starkware made 2 comments.
Reviewable status: 0 of 6 files reviewed, 3 unresolved discussions (waiting on Gali-StarkWare and leo-starkware).


crates/circuit_multiverifier/src/verify.rs line 90 at r2 (raw file):

Previously, leo-starkware wrote…

This comment is a bit confusing. Maybe claude can improve it

Done.


crates/circuit_multiverifier/src/verify_test.rs line 367 at r2 (raw file):

    // followed by the eight raw output words.
    let cairo_input_preimage_words: Vec<u32> =
        multiverifier_leaf_circuit_hash(PRIVACY_CAIRO_VERIFIER_PREPROCESSED_ROOT)

Done.

@leo-starkware leo-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@leo-starkware reviewed 6 files and all commit messages, made 2 comments, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Gali-StarkWare).


crates/circuit_multiverifier/src/test_utils.rs line 72 at r2 (raw file):

Previously, ilyalesokhin-starkware wrote…

I passed the shared config.

Note, however, that it is a test_utils function.
So I think it should be optimized for the call-sites.

for example it return u32s and not Blake2sHash like compute_circuit_hash(

makes sense, but i think that taking the argument explicitly is more readable here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyalesokhin-starkware reviewed 6 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Gali-StarkWare).

@ilyalesokhin-starkware
ilyalesokhin-starkware merged commit 3ba71ae into main Jul 22, 2026
13 checks passed
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.

3 participants