zk: add debug tracer

This commit is contained in:
x
2023-08-19 12:51:07 +02:00
parent d60d72d088
commit f3a6672bfb
3 changed files with 53 additions and 2 deletions

View File

@@ -66,14 +66,24 @@ fn main() -> Result<()> {
// Create the circuit
let circuit = ZkCircuit::new(prover_witnesses, &zkbin.clone());
circuit.enable_trace();
let now = std::time::Instant::now();
let proving_key = ProvingKey::build(k, &circuit);
println!("ProvingKey built [{} s]", now.elapsed().as_secs_f64());
let now = std::time::Instant::now();
let proof = Proof::create(&proving_key, &[circuit], &public_inputs, &mut OsRng)?;
let circuits = [circuit];
let proof = Proof::create(&proving_key, &circuits, &public_inputs, &mut OsRng)?;
println!("Proof created [{} s]", now.elapsed().as_secs_f64());
println!("Debug trace:");
let opvalue_binding = circuits[0].tracer.opvalues.borrow();
let opvalues = opvalue_binding.as_ref().unwrap();
for (i, (opcode, opvalue)) in zkbin.opcodes.iter().zip(opvalues.iter()).enumerate() {
let opcode = opcode.0;
println!(" {}: {:?} {:?}", i, opcode, opvalue);
}
// ========
// Verifier
// ========