Skip to content

Commit

Permalink
refactor: gnark folder (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas authored May 9, 2024
1 parent c27b97d commit 227bbdd
Show file tree
Hide file tree
Showing 25 changed files with 517 additions and 1,423 deletions.
4 changes: 0 additions & 4 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ path = "scripts/tendermint_sweep.rs"
name = "fibonacci_groth16"
path = "scripts/fibonacci_groth16.rs"

[[bin]]
name = "test_groth16_verification"
path = "scripts/test_groth16_verification.rs"

[[bin]]
name = "build_groth16"
path = "scripts/build_groth16.rs"
Expand Down
46 changes: 0 additions & 46 deletions prover/scripts/test_groth16_verification.rs

This file was deleted.

27 changes: 19 additions & 8 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use sp1_core::{
};
use sp1_primitives::hash_deferred_proof;
use sp1_recursion_circuit::witness::Witnessable;
use sp1_recursion_compiler::config::OuterConfig;
use sp1_recursion_compiler::ir::Witness;
use sp1_recursion_core::runtime::RecursionProgram;
use sp1_recursion_core::stark::RecursionAirSkinnyDeg7;
Expand Down Expand Up @@ -685,9 +686,17 @@ impl SP1Prover {
witness.write_commited_values_digest(commited_values_digest);
witness.write_vkey_hash(vkey_digest);

let mut prover = Groth16Prover::new(build_dir);
let proof = prover.prove(witness);
prover.shutdown();
let prover = Groth16Prover::new();
let proof = prover.prove(witness, build_dir.clone());

// Verify the proof.
prover.verify::<OuterConfig>(
proof.clone(),
vkey_digest,
commited_values_digest,
build_dir,
);

proof
}

Expand Down Expand Up @@ -726,6 +735,8 @@ mod tests {
use std::fs::File;
use std::io::{Read, Write};

use crate::build::{build_groth16_artifacts, get_groth16_artifacts_dir};

use super::*;
use p3_field::PrimeField32;
use serial_test::serial;
Expand Down Expand Up @@ -809,11 +820,11 @@ mod tests {
let vk_digest_bn254 = wrapped_bn254_proof.sp1_vkey_digest_bn254();
assert_eq!(vk_digest_bn254, vk.hash_bn254());

// tracing::info!("generate groth16 proof");
// let artifacts_dir = get_groth16_artifacts_dir();
// build_groth16_artifacts(&prover.wrap_vk, &wrapped_bn254_proof.proof, &artifacts_dir);
// let groth16_proof = prover.wrap_groth16(wrapped_bn254_proof, artifacts_dir);
// println!("{:?}", groth16_proof);
tracing::info!("generate groth16 proof");
let artifacts_dir = get_groth16_artifacts_dir();
build_groth16_artifacts(&prover.wrap_vk, &wrapped_bn254_proof.proof, &artifacts_dir);
let groth16_proof = prover.wrap_groth16(wrapped_bn254_proof, artifacts_dir);
println!("{:?}", groth16_proof);
}

/// Tests an end-to-end workflow of proving a program across the entire proof generation
Expand Down
Loading

0 comments on commit 227bbdd

Please sign in to comment.