Skip to content

Commit

Permalink
chore: enable derive serde for "halo2-pse" (#61)
Browse files Browse the repository at this point in the history
* chore: enable derive serde for "halo2-pse"

Now that halo2-pse has the "derive_serde" feature

* chore: update Cargo.lock
  • Loading branch information
jonathanpwang authored Jan 22, 2024
1 parent 95ee9c6 commit 4b733e0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
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

0 comments on commit 4b733e0

Please sign in to comment.