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

Automatic JSONs generation for e2e Pasta flow #38

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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
40 changes: 28 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,15 +1053,15 @@ mod tests {
test_ivc_nontrivial_with::<bn256::Point, grumpkin::Point>();
}

fn test_ivc_nontrivial_with_compression_with<G1, G2>()
where
G1: Group<Base = <G2 as Group>::Scalar>,
G2: Group<Base = <G1 as Group>::Scalar>,
fn test_ivc_nontrivial_with_compression_with<G1, G2>(generate_keys_to_json: bool)
where
G1: Group<Base = <G2 as Group>::Scalar>,
G2: Group<Base = <G1 as Group>::Scalar>,
// this is due to the reliance on CommitmentKeyExtTrait as a bound in ipa_pc
<G1::CE as CommitmentEngineTrait<G1>>::CommitmentKey:
CommitmentKeyExtTrait<G1, CE = <G1 as Group>::CE>,
<G2::CE as CommitmentEngineTrait<G2>>::CommitmentKey:
CommitmentKeyExtTrait<G2, CE = <G2 as Group>::CE>,
<G1::CE as CommitmentEngineTrait<G1>>::CommitmentKey:
CommitmentKeyExtTrait<G1, CE = <G1 as Group>::CE>,
<G2::CE as CommitmentEngineTrait<G2>>::CommitmentKey:
CommitmentKeyExtTrait<G2, CE = <G2 as Group>::CE>,
{
let circuit_primary = TrivialTestCircuit::default();
let circuit_secondary = CubicCircuit::default();
Expand Down Expand Up @@ -1122,13 +1122,19 @@ mod tests {
assert_eq!(zn_secondary, vec![<G2 as Group>::Scalar::from(2460515u64)]);

// produce the prover and verifier keys for compressed snark
let (pk, vk) = CompressedSNARK::<_, _, _, _, S1<G1>, S2<G2>>::setup(&pp).unwrap();
let (pk, vk) = CompressedSNARK::<_, _, _, _, S1Prime<G1>, S2Prime<G2>>::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<G1>, S2<G2>>::prove(&pp, &pk, &recursive_snark);
let res = CompressedSNARK::<_, _, _, _, S1Prime<G1>, S2Prime<G2>>::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,
Expand All @@ -1144,8 +1150,8 @@ mod tests {
type G1 = pasta_curves::pallas::Point;
type G2 = pasta_curves::vesta::Point;

test_ivc_nontrivial_with_compression_with::<G1, G2>();
test_ivc_nontrivial_with_compression_with::<bn256::Point, grumpkin::Point>();
test_ivc_nontrivial_with_compression_with::<G1, G2>(false);
test_ivc_nontrivial_with_compression_with::<bn256::Point, grumpkin::Point>(false);
}

fn test_ivc_nontrivial_with_spark_compression_with<G1, G2>()
Expand Down Expand Up @@ -1469,4 +1475,14 @@ mod tests {
test_ivc_base_with::<G1, G2>();
test_ivc_base_with::<bn256::Point, grumpkin::Point>();
}

// cargo +nightly test test_ivc_nontrivial_with_compression_pasta --release -- --nocapture --ignored
#[test]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add ignore, please:

#[test]
#[ignore]
fn solidity_compatibility_e2e_pasta() {
. . .

#[ignore]
fn solidity_compatibility_e2e_pasta() {
type G1 = pasta_curves::pallas::Point;
type G2 = pasta_curves::vesta::Point;

test_ivc_nontrivial_with_compression_with::<G1, G2>(true);
}
}