Skip to content

Commit

Permalink
wip: prep to serialize pk/vk
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Nov 21, 2024
1 parent b9e15ab commit 9c11e8d
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 32 deletions.
104 changes: 73 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
proofs = { git = "https://github.com/pluto/web-prover" }
proofs = { git = "https://github.com/pluto/web-prover", rev = "1df0818" }
client-side-prover = { git = "https://github.com/pluto/client-side-prover" }
halo2curves = "0.6.1"
bincode = "1.3"
anyhow = "1.0"
43 changes: 43 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use anyhow::{Context, Result};
use client_side_prover::{
provider::{hyperkzg::EvaluationEngine, Bn256EngineKZG, GrumpkinEngine},
spartan::batched::BatchedRelaxedR1CSSNARK,
supernova::snark::CompressedSNARK,
};
use proofs::program::{
self,
data::{ProgramData, SetupData},
Expand All @@ -8,6 +13,13 @@ use std::fs::{self, File};
use std::io::Write;
use std::path::{Path, PathBuf};

pub type E1 = Bn256EngineKZG;
pub type E2 = GrumpkinEngine;
pub type EE1 = EvaluationEngine<halo2curves::bn256::Bn256, E1>;
pub type EE2 = client_side_prover::provider::ipa_pc::EvaluationEngine<E2>;
pub type S1 = BatchedRelaxedR1CSSNARK<E1, EE1>;
pub type S2 = BatchedRelaxedR1CSSNARK<E2, EE2>;

struct CircuitFiles {
r1cs_path: PathBuf,
graph_path: PathBuf,
Expand Down Expand Up @@ -92,6 +104,37 @@ fn main() -> Result<()> {

println!("Generating public parameters...");
let public_params = program::setup(&setup_data);

// TODO (autoparallel): Implement serde on the `ProverKey` and `VerifierKey` then uncomment this
// let (pk, vk) = CompressedSNARK::<E1, S1, S2>::setup(&public_params)?;

// Write out the `ProverKey`
// let serialized_pk =
// bincode::serialize(&pk).context("Failed to serialize auxiliary parameters")?;

// let output_file = artifacts_dir.join(format!("prover_key_{}.bin", target_size));
// println!("Writing output to: {}", output_file.display());

// let mut file = File::create(&output_file)
// .with_context(|| format!("Failed to create output file: {}", output_file.display()))?;

// file.write_all(&serialized_pk)
// .with_context(|| format!("Failed to write to output file: {}", output_file.display()))?;

// // Write out the `VerifierKey`
// let serialized_vk =
// bincode::serialize(&vk).context("Failed to serialize auxiliary parameters")?;

// let output_file = artifacts_dir.join(format!("prover_key_{}.bin", target_size));
// println!("Writing output to: {}", output_file.display());

// let mut file = File::create(&output_file)
// .with_context(|| format!("Failed to create output file: {}", output_file.display()))?;

// file.write_all(&serialized_vk)
// .with_context(|| format!("Failed to write to output file: {}", output_file.display()))?;

// Write out the `AuxParams`
let aux_params = public_params.aux_params();
let serialized_aux_params =
bincode::serialize(&aux_params).context("Failed to serialize auxiliary parameters")?;
Expand Down

0 comments on commit 9c11e8d

Please sign in to comment.