Skip to content

Commit

Permalink
fix: add public/public solidity tests (zkonduit#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-crypto authored Jun 1, 2023
1 parent 4bcc24e commit e695d84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ pub async fn verify_proof_via_solidity(
let contract = Verifier::new(addr, client.clone());

let mut public_inputs = vec![];
for val in &proof.instances[0] {
let flattened_instances = proof.instances.into_iter().flatten();

for val in flattened_instances {
let bytes = val.to_repr();
let u = U256::from_little_endian(bytes.as_slice());
public_inputs.push(u);
Expand Down Expand Up @@ -306,7 +308,9 @@ pub async fn send_proof<M: 'static + Middleware>(
let contract = Verifier::new(addr, client.clone());

let mut public_inputs = vec![];
for val in &snark.instances[0] {
let flattened_instances = snark.instances.into_iter().flatten();

for val in flattened_instances {
let bytes = val.to_repr();
let u = U256::from_little_endian(bytes.as_slice());
public_inputs.push(u);
Expand Down
16 changes: 12 additions & 4 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ mod native_tests {
fn kzg_evm_prove_and_verify_(test: &str) {
crate::native_tests::init_binary();
crate::native_tests::init_params_17();
kzg_evm_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test));
kzg_evm_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), false, true);
kzg_evm_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), true, true);
kzg_evm_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), true, false);
}

#(#[test_case(TESTS_EVM[N])])*
Expand All @@ -397,7 +399,9 @@ mod native_tests {
fn kzg_evm_aggr_prove_and_verify_(test: &str) {
crate::native_tests::init_binary();
crate::native_tests::init_params_23();
kzg_evm_aggr_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test));
kzg_evm_aggr_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), false, true);
kzg_evm_aggr_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), true, true);
kzg_evm_aggr_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test), true, false);
}

});
Expand Down Expand Up @@ -791,7 +795,7 @@ mod native_tests {
}

// prove-serialize-verify, the usual full path
fn kzg_evm_aggr_prove_and_verify(example_name: String, with_solidity: bool) {
fn kzg_evm_aggr_prove_and_verify(example_name: String, with_solidity: bool, public_inputs: bool, public_outputs: bool) {
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"setup",
Expand Down Expand Up @@ -822,6 +826,8 @@ mod native_tests {
),
"--bits=16",
"-K=17",
&format!("--public-inputs={}", public_inputs),
&format!("--public-outputs={}", public_outputs)
])
.status()
.expect("failed to execute process");
Expand Down Expand Up @@ -1079,7 +1085,7 @@ mod native_tests {
}

// prove-serialize-verify, the usual full path
fn kzg_evm_prove_and_verify(example_name: String, with_solidity: bool) {
fn kzg_evm_prove_and_verify(example_name: String, with_solidity: bool, public_inputs: bool, public_outputs: bool) {
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"setup",
Expand All @@ -1102,6 +1108,8 @@ mod native_tests {
),
"--bits=16",
"-K=17",
&format!("--public-inputs={}", public_inputs),
&format!("--public-outputs={}", public_outputs)
])
.status()
.expect("failed to execute process");
Expand Down

0 comments on commit e695d84

Please sign in to comment.