2024-11-08 12:23:55 +01:00
|
|
|
use anyhow::Result;
|
|
|
|
|
use std::time::Instant;
|
2025-04-09 16:34:15 +02:00
|
|
|
use codex_plonky2_circuits::circuit_helper::Plonky2Circuit;
|
2025-01-10 11:30:34 +01:00
|
|
|
use proof_input::serialization::circuit_input::import_circ_input_from_json;
|
2025-04-09 16:34:15 +02:00
|
|
|
use codex_plonky2_circuits::circuits::sample_cells::{SampleCircuit, SampleCircuitInput, SampleTargets};
|
2024-11-08 12:23:55 +01:00
|
|
|
use codex_plonky2_circuits::circuits::params::CircuitParams;
|
2025-01-10 11:56:06 +01:00
|
|
|
use proof_input::params::{D, C, F, HF};
|
2025-04-10 10:54:56 +02:00
|
|
|
use proof_input::serialization::file_paths::{CIRC_INPUT_JSON, PROVER_CIRC_DATA_JSON, TARGETS_JSON, TREE_PROOF_JSON};
|
2025-04-09 16:34:15 +02:00
|
|
|
use proof_input::serialization::json::{export_proof_with_pi, import_prover_circuit_data, import_targets};
|
2024-11-08 12:23:55 +01:00
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
|
// Load the parameters from environment variables
|
2024-11-14 10:31:32 +01:00
|
|
|
let circuit_params = CircuitParams::from_env()?;
|
2024-11-08 12:23:55 +01:00
|
|
|
|
|
|
|
|
// Read the witness from input.json
|
2025-04-09 16:34:15 +02:00
|
|
|
let circ_input: SampleCircuitInput<F, D> = import_circ_input_from_json()?;
|
|
|
|
|
println!("Witness imported from: {}", CIRC_INPUT_JSON);
|
2024-11-08 12:23:55 +01:00
|
|
|
|
2025-04-09 16:34:15 +02:00
|
|
|
// read the targets
|
|
|
|
|
let circ_targets: SampleTargets = import_targets()?;
|
|
|
|
|
println!("circuit targets imported from: {}", TARGETS_JSON);
|
2024-11-08 12:23:55 +01:00
|
|
|
|
2025-04-09 16:34:15 +02:00
|
|
|
// read the circuit data
|
|
|
|
|
let prover_data = import_prover_circuit_data::<F,C,D>()?;
|
|
|
|
|
println!("Prover circuit data imported from: {}", PROVER_CIRC_DATA_JSON);
|
|
|
|
|
println!("Circuit size (degree bits): {:?}", prover_data.common.degree_bits());
|
2024-11-08 12:23:55 +01:00
|
|
|
|
|
|
|
|
// Prove the circuit with the assigned witness
|
2025-04-09 16:34:15 +02:00
|
|
|
let circ = SampleCircuit::<F,D,HF>::new(circuit_params);
|
2024-11-08 12:23:55 +01:00
|
|
|
let start_time = Instant::now();
|
2025-04-09 16:34:15 +02:00
|
|
|
let proof_with_pis = circ.prove(&circ_targets, &circ_input, &prover_data)?;
|
2024-11-08 12:23:55 +01:00
|
|
|
println!("Proving time: {:?}", start_time.elapsed());
|
|
|
|
|
|
2025-04-09 16:34:15 +02:00
|
|
|
//export the proof to json file
|
|
|
|
|
export_proof_with_pi(&proof_with_pis)?;
|
2025-04-10 10:54:56 +02:00
|
|
|
println!("Tree proof written to: {}", TREE_PROOF_JSON);
|
2024-11-08 12:23:55 +01:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|