diff --git a/.gitignore b/.gitignore index 088ba6ba..0cbba5cf 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +.idea/jpa-buddy.xml +.idea/misc.xml +.idea/vcs.xml +.idea/workspace.xml diff --git a/Cargo.toml b/Cargo.toml index 7269a0ed..1c19deb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ bitvec = "1.0" byteorder = "1.4.3" thiserror = "1.0" halo2curves = { version="0.1.0", features = [ "derive_serde" ] } +serde_json = "1.0.111" [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] pasta-msm = { version = "0.1.4" } diff --git a/src/lib.rs b/src/lib.rs index bc48c932..3979dcea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1053,15 +1053,15 @@ mod tests { test_ivc_nontrivial_with::(); } - fn test_ivc_nontrivial_with_compression_with() - where - G1: Group::Scalar>, - G2: Group::Scalar>, + fn test_ivc_nontrivial_with_compression_with(generate_keys_to_json: bool) + where + G1: Group::Scalar>, + G2: Group::Scalar>, // this is due to the reliance on CommitmentKeyExtTrait as a bound in ipa_pc - >::CommitmentKey: - CommitmentKeyExtTrait::CE>, - >::CommitmentKey: - CommitmentKeyExtTrait::CE>, + >::CommitmentKey: + CommitmentKeyExtTrait::CE>, + >::CommitmentKey: + CommitmentKeyExtTrait::CE>, { let circuit_primary = TrivialTestCircuit::default(); let circuit_secondary = CubicCircuit::default(); @@ -1122,13 +1122,19 @@ mod tests { assert_eq!(zn_secondary, vec![::Scalar::from(2460515u64)]); // produce the prover and verifier keys for compressed snark - let (pk, vk) = CompressedSNARK::<_, _, _, _, S1, S2>::setup(&pp).unwrap(); + let (pk, vk) = CompressedSNARK::<_, _, _, _, S1Prime, S2Prime>::setup(&pp).unwrap(); + if generate_keys_to_json { + let serialized_vk = serde_json::to_string(&vk).unwrap();std::fs::write(std::path::Path::new("vk.json"), serialized_vk).expect("Unable to write file"); + } // produce a compressed SNARK - let res = CompressedSNARK::<_, _, _, _, S1, S2>::prove(&pp, &pk, &recursive_snark); + let res = CompressedSNARK::<_, _, _, _, S1Prime, S2Prime>::prove(&pp, &pk, &recursive_snark); assert!(res.is_ok()); let compressed_snark = res.unwrap(); + if generate_keys_to_json { + let serialized_compressed_snark = serde_json::to_string(&compressed_snark).unwrap();std::fs::write(std::path::Path::new("compressed-snark.json"), serialized_compressed_snark).expect("Unable to write file"); + } // verify the compressed SNARK let res = compressed_snark.verify( &vk, @@ -1144,8 +1150,8 @@ mod tests { type G1 = pasta_curves::pallas::Point; type G2 = pasta_curves::vesta::Point; - test_ivc_nontrivial_with_compression_with::(); - test_ivc_nontrivial_with_compression_with::(); + test_ivc_nontrivial_with_compression_with::(false); + test_ivc_nontrivial_with_compression_with::(false); } fn test_ivc_nontrivial_with_spark_compression_with() @@ -1469,4 +1475,14 @@ mod tests { test_ivc_base_with::(); test_ivc_base_with::(); } + + // cargo +nightly test test_ivc_nontrivial_with_compression_pasta --release -- --nocapture --ignored + #[test] + #[ignore] + fn solidity_compatibility_e2e_pasta() { + type G1 = pasta_curves::pallas::Point; + type G2 = pasta_curves::vesta::Point; + + test_ivc_nontrivial_with_compression_with::(true); + } }