mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 13:53:07 +00:00
serializing circuit data in the recursion example
This commit is contained in:
parent
790042102d
commit
4625d3a63c
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,3 +8,6 @@ pgo-data.profdata
|
||||
|
||||
# MacOS nuisances
|
||||
.DS_Store
|
||||
|
||||
# debugging
|
||||
debug_data
|
||||
2
plonky2/.gitignore
vendored
Normal file
2
plonky2/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
*.json
|
||||
@ -14,6 +14,9 @@ use core::str::FromStr;
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync::Arc;
|
||||
|
||||
use std::fs;
|
||||
use serde::Serialize;
|
||||
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use itertools::Itertools;
|
||||
use log::{info, Level, LevelFilter};
|
||||
@ -212,6 +215,7 @@ fn recursive_proof<
|
||||
) -> Result<ProofTuple<F, C, D>>
|
||||
where
|
||||
InnerC::Hasher: AlgebraicHasher<F>,
|
||||
C: Serialize,
|
||||
{
|
||||
let (inner_proof, inner_vd, inner_cd) = inner;
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config.clone());
|
||||
@ -247,6 +251,16 @@ where
|
||||
let proof = prove_with_options::<F, C, D>(&data.prover_only, &data.common, pw, &mut timing, &prover_opts)?;
|
||||
timing.print();
|
||||
|
||||
/*
|
||||
// serialize circuit data and proof
|
||||
let common_circuit_data_serialized = serde_json::to_string(&data.common).unwrap();
|
||||
let verifier_only_circuit_data_serialized = serde_json::to_string(&data.verifier_only).unwrap();
|
||||
let proof_serialized = serde_json::to_string(&proof).unwrap();
|
||||
fs::write(format!("recursion_{}_common.json", name), common_circuit_data_serialized ).expect("Unable to write file");
|
||||
fs::write(format!("recursion_{}_vkey.json" , name), verifier_only_circuit_data_serialized ).expect("Unable to write file");
|
||||
fs::write(format!("recursion_{}_proof.json" , name), proof_serialized ).expect("Unable to write file");
|
||||
*/
|
||||
|
||||
data.verify(proof.clone())?;
|
||||
|
||||
Ok((proof, data.verifier_only, data.common))
|
||||
|
||||
@ -42,21 +42,14 @@ fn main() -> Result<()> {
|
||||
|
||||
let data = builder.build::<C>();
|
||||
|
||||
let common_circuit_data_serialized = serde_json::to_string(&data.common).unwrap();
|
||||
fs::write("common_circuit_data.json", common_circuit_data_serialized)
|
||||
.expect("Unable to write file");
|
||||
|
||||
let verifier_only_circuit_data_serialized = serde_json::to_string(&data.verifier_only).unwrap();
|
||||
fs::write(
|
||||
"verifier_only_circuit_data.json",
|
||||
verifier_only_circuit_data_serialized,
|
||||
)
|
||||
.expect("Unable to write file");
|
||||
|
||||
let proof = data.prove(pw)?;
|
||||
|
||||
let proof_serialized = serde_json::to_string(&proof).unwrap();
|
||||
fs::write("proof_with_public_inputs.json", proof_serialized).expect("Unable to write file");
|
||||
let common_circuit_data_serialized = serde_json::to_string(&data.common).unwrap();
|
||||
let verifier_only_circuit_data_serialized = serde_json::to_string(&data.verifier_only).unwrap();
|
||||
let proof_serialized = serde_json::to_string(&proof).unwrap();
|
||||
fs::write("fibonacci_common.json", common_circuit_data_serialized ).expect("Unable to write file");
|
||||
fs::write("fibonacci_vkey.json" , verifier_only_circuit_data_serialized ).expect("Unable to write file");
|
||||
fs::write("fibonacci_proof.json" , proof_serialized ).expect("Unable to write file");
|
||||
|
||||
println!(
|
||||
"100th Fibonacci number mod |F| (starting with {}, {}) is: {}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user