Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/bitvm-gc/src/babe_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub fn expand_compact_soldering_proof_payload(
Ok((payload.opened, finalized, expand_compact_soldering_data(payload.soldering)?))
}

/// Derives finalized circuit indices using the real BABE/CAC Fiat-Shamir selection.
/// Randomly selects `m_cc` distinct finalized circuit indices for the cut-and-choose.
pub fn derive_finalized_indices(package: &CACSetupPackage, m_cc: usize) -> Result<Vec<usize>> {
let n_cc = package.commits.len();
if m_cc == 0 || m_cc > n_cc {
Expand Down Expand Up @@ -595,6 +595,12 @@ fn recover_a_valid_finalized_messages(
bail!("BABE prover state has no finalized instances");
}

if challenge_witness.witness.input_labels.len() != GC_INPUT_WIRES {
bail!(
"challenge witness has {} input labels; expected {GC_INPUT_WIRES}",
challenge_witness.witness.input_labels.len()
);
}
let base_input_labels: Vec<S> =
challenge_witness.witness.input_labels.iter().map(|&b| S(b)).collect();
let pi1_full_labels = base_input_labels[..2 * N_PADDED].to_vec();
Expand Down
12 changes: 12 additions & 0 deletions node/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,18 @@ async fn handle_cut_circuits_verifier(
);
return Ok(());
}
// Reject a malformed cut before the expensive opening persists it: graph endorsement and
// challenge-assert both require exactly BABE_M_CC finalized instances.
if selected_circuit_indexes.len() != BABE_M_CC {
tracing::warn!(
instance_id = %instance_id,
graph_id = %graph_id,
selected = selected_circuit_indexes.len(),
expected = BABE_M_CC,
"Ignore CutCircuits with an invalid number of selected circuits"
);
return Ok(());
}

if let Some(soldering_proof_ready) = verifier_state.soldering_proof_ready.clone() {
if soldering_proof_ready.candidate_index != candidate_index {
Expand Down
Loading