Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable derive serde for "halo2-pse" #61

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions Cargo.lock

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

14 changes: 0 additions & 14 deletions snark-verifier-sdk/src/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ where
MSMAccumulator = DualMSM<'params, Bn256>,
>,
{
#[cfg(feature = "halo2-axiom")]
if let Some(path) = &path {
if let Ok(snark) = read_snark(path) {
return snark;
Expand All @@ -213,21 +212,9 @@ where
);

let instances = circuit.instances();
#[cfg(feature = "halo2-axiom")]
let proof = gen_proof::<ConcreteCircuit, P, V>(params, pk, circuit, instances.clone(), None);
// If we can't serialize the entire snark, at least serialize the proof
#[cfg(not(feature = "halo2-axiom"))]
let proof = {
let path = path.map(|path| {
let path = path.as_ref().to_str().unwrap();
(format!("{path}.instances"), format!("{path}.proof"))
});
let paths = path.as_ref().map(|path| (Path::new(&path.0), Path::new(&path.1)));
gen_proof::<ConcreteCircuit, P, V>(params, pk, circuit, instances.clone(), paths)
};

let snark = Snark::new(protocol, instances, proof);
#[cfg(feature = "halo2-axiom")]
if let Some(path) = &path {
let f = File::create(path).unwrap();
#[cfg(feature = "display")]
Expand Down Expand Up @@ -269,7 +256,6 @@ pub fn gen_snark_shplonk<ConcreteCircuit: CircuitExt<Fr>>(
/// Tries to deserialize a SNARK from the specified `path` using `bincode`.
///
/// WARNING: The user must keep track of whether the SNARK was generated using the GWC or SHPLONK multi-open scheme.
#[cfg(feature = "halo2-axiom")]
pub fn read_snark(path: impl AsRef<Path>) -> Result<Snark, bincode::Error> {
let f = File::open(path).map_err(Box::<bincode::ErrorKind>::from)?;
bincode::deserialize_from(f)
Expand Down
3 changes: 1 addition & 2 deletions snark-verifier-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pub type PlonkSuccinctVerifier<AS> =
pub type SHPLONK = KzgAs<Bn256, Bdfg21>;
pub type GWC = KzgAs<Bn256, Gwc19>;

#[derive(Clone, Debug)]
#[cfg_attr(feature = "halo2-axiom", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Snark {
pub protocol: PlonkProtocol<G1Affine>,
pub instances: Vec<Vec<Fr>>,
Expand Down
Loading