From 85ea174969e1275e4dbcdb25b71f1a7a84e461f0 Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Thu, 28 Sep 2023 20:26:14 +0200 Subject: [PATCH] Store proof as JSON --- kzg_prover/.gitignore | 1 + kzg_prover/src/main.rs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/kzg_prover/.gitignore b/kzg_prover/.gitignore index eb5a316c..00257692 100644 --- a/kzg_prover/.gitignore +++ b/kzg_prover/.gitignore @@ -1 +1,2 @@ target +test_data diff --git a/kzg_prover/src/main.rs b/kzg_prover/src/main.rs index d7c122c9..d186455e 100644 --- a/kzg_prover/src/main.rs +++ b/kzg_prover/src/main.rs @@ -1,8 +1,8 @@ pub mod constraint_system; -use std::array; use std::str::FromStr; use std::sync::Arc; +use std::{array, fs}; use ark_ec::short_weierstrass_jacobian::GroupAffine; use kimchi::circuits::constraints::ConstraintSystem as KimchiConstraintSystem; @@ -27,7 +27,8 @@ type BaseSponge = DefaultFqSponge; type ScalarSponge = DefaultFrSponge; fn main() { - let gates = create_gates(); + let cs_json = fs::read_to_string("./test_data/constraint_system.json").unwrap(); + let gates = create_gates(&cs_json); let constraint_system = KimchiConstraintSystem::::create(gates) .public(3) @@ -41,15 +42,18 @@ fn main() { let witness = create_witness(); let prover_index: ProverIndex<_> = ProverIndex::create(constraint_system, endo_r, srs_arc); - ProverProof::create::(&group_map, witness, &[], &prover_index) - .expect("failed to generate proof"); + let proof = + ProverProof::create::(&group_map, witness, &[], &prover_index) + .expect("failed to generate proof"); + + let proof_json = serde_json::to_string(&proof).unwrap(); + fs::write("./test_data/proof.json", proof_json).unwrap(); println!("Done!"); } -fn create_gates() -> Vec> { - let cs_json = std::fs::read_to_string("./test_data/constraint_system.json").unwrap(); - let cs = constraint_system::ConstraintSystem::from(cs_json.as_str()); +fn create_gates(cs_json: &str) -> Vec> { + let cs = constraint_system::ConstraintSystem::from(cs_json); let elem_list = cs.0; elem_list