pub fn generate_setup_data_common(
    keystore: &Keystore,
    circuit: ProverServiceDataKey,
) -> anyhow::Result<CircuitSetupData> {
    let mut data_source = keystore.load_keys_to_data_source()?;
    let circuit_setup_data =
        generate_circuit_setup_data(circuit.stage as u8, circuit.circuit_id, &mut data_source)
            .unwrap();

    let (finalization, vk) = match circuit.stage {
        ProvingStage::BasicCircuits => (
            Some(keystore.load_finalization_hints(circuit)?),
            data_source
                .get_base_layer_vk(circuit.circuit_id)
                .unwrap()
                .into_inner(),
        ),
        ProvingStage::Compression => {
            unreachable!("Compression stage setup data should be generated with a generate-compressor-data command")
        }
        ProvingStage::CompressionWrapper => {
            unreachable!("CompressionWrapper stage setup data should be generated with a generate-compressor-data command")
        }
        _ => (
            Some(keystore.load_finalization_hints(circuit)?),
            data_source
                .get_recursion_layer_vk(circuit.circuit_id)
                .unwrap()
                .into_inner(),
        ),
    };

    // Sanity check to make sure that generated setup data is matching.
    if let Some(finalization) = finalization {
        if finalization != circuit_setup_data.finalization_hint {
            anyhow::bail!(
                "finalization hint mismatch for circuit: {:?}",
                circuit.name()
            );
        }
    }
    if vk != circuit_setup_data.vk {
        anyhow::bail!("vk mismatch for circuit: {:?}", circuit.name());
    }
    Ok(circuit_setup_data)
}
Internal helper function, that calls the test harness to generate the setup data.
It also does a final sanity check to make sure that verification keys didn't change.
prover/crates/lib/keystore/src/setup_data_generator.rs