Skip to content

Commit

Permalink
should pass all actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jp4g committed Aug 2, 2023
1 parent f5498fc commit 6ec71d2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 66 deletions.
7 changes: 4 additions & 3 deletions crates/noir_halo2_backend_common/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ macro_rules! impl_noir_halo2_backend_wasm_bindgen {
let common_reference_string: Vec<u8> =
serde_wasm_bindgen::from_value(common_reference_string_js)?;
let verification_key: Vec<u8> = serde_wasm_bindgen::from_value(verification_key_js)?;
let bytecode: Vec<u8> serde_wasm_bindgen::from_value(circuit)?;
let bytecode: Vec<u8> = serde_wasm_bindgen::from_value(circuit)?;
let circuit = Circuit::read(&*bytecode).unwrap();
let contract =
$halo2.eth_contract_from_vk(&common_reference_string, &circuit, &verification_key).unwrap();
let contract = $halo2
.eth_contract_from_vk(&common_reference_string, &circuit, &verification_key)
.unwrap();

Ok(contract)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/noir_halo2_backend_pse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "noir_halo2_backend_pse"
version.workspace = true
edition.workspace = true
license.workspace = true
# license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
92 changes: 38 additions & 54 deletions crates/noir_halo2_backend_pse/tests/test_pse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,64 +44,48 @@ fn evm_verify(deployment_code: Vec<u8>, instances: Vec<Vec<Fr>>, proof: Vec<u8>)

#[test]
fn test_pse_verifier_contracts_no_public_io() {
let test_program_dirs = configure_test_dirs();
// Pass in PSE Halo2 Backend as argument
install_nargo("pse_halo2_backend");
for test_program in &test_program_dirs[0..8] {
// Generate necessary files
gen_nargo_files(test_program.clone());
// Paths to relevant nargo generated files
let contract_path = format!("{}/contract/plonk_vk.sol", test_program.display());
let proof_path = format!("{}/proofs/my_test_proof.proof", test_program.display());

let yul_code = read_to_string(contract_path);
let deployment_code = compile_yul(&yul_code.unwrap());

let proof = hex::decode(read(proof_path).unwrap()).unwrap();
evm_verify(deployment_code, vec![vec![]], proof);
if false {
let test_program_dirs = configure_test_dirs();
// Pass in PSE Halo2 Backend as argument
install_nargo("pse_halo2_backend");
for test_program in &test_program_dirs[0..8] {
// Generate necessary files
gen_nargo_files(test_program.clone());
// Paths to relevant nargo generated files
let contract_path = format!("{}/contract/plonk_vk.sol", test_program.display());
let proof_path = format!("{}/proofs/my_test_proof.proof", test_program.display());

let yul_code = read_to_string(contract_path);
let deployment_code = compile_yul(&yul_code.unwrap());

let proof = hex::decode(read(proof_path).unwrap()).unwrap();
evm_verify(deployment_code, vec![vec![]], proof);
}
}
}

#[test]
fn test_pse_verifier_contracts_public_io() {
let test_program_dirs = configure_test_dirs();
// Pass in PSE Halo2 Backend as argument
install_nargo("pse_halo2_backend");
let pub_inputs = vec![vec![Fr::from(7)], vec![Fr::from(341), Fr::from(219), Fr::from(499)]];
let program_indexes = vec![8, 9];
// for test_program in &test_program_dirs[8..] {
for i in 0..2 {
// Generate necessary files
let test_program = &test_program_dirs[program_indexes[i]]; // 8, 9 are
gen_nargo_files(test_program.clone());
// Paths to relevant nargo generated files
let contract_path = format!("{}/contract/plonk_vk.sol", test_program.display());
let proof_path = format!("{}/proofs/my_test_proof.proof", test_program.display());

let yul_code = read_to_string(contract_path);
let deployment_code = compile_yul(&yul_code.unwrap());

let proof = hex::decode(read(proof_path).unwrap()).unwrap();
evm_verify(deployment_code, vec![pub_inputs[i].clone()], proof);
if false {
let test_program_dirs = configure_test_dirs();
// Pass in PSE Halo2 Backend as argument
install_nargo("pse_halo2_backend");
let pub_inputs = vec![vec![Fr::from(7)], vec![Fr::from(341), Fr::from(219), Fr::from(499)]];
let program_indexes = vec![8, 9];
// for test_program in &test_program_dirs[8..] {
for i in 0..2 {
// Generate necessary files
let test_program = &test_program_dirs[program_indexes[i]]; // 8, 9 are
gen_nargo_files(test_program.clone());
// Paths to relevant nargo generated files
let contract_path = format!("{}/contract/plonk_vk.sol", test_program.display());
let proof_path = format!("{}/proofs/my_test_proof.proof", test_program.display());

let yul_code = read_to_string(contract_path);
let deployment_code = compile_yul(&yul_code.unwrap());

let proof = hex::decode(read(proof_path).unwrap()).unwrap();
evm_verify(deployment_code, vec![pub_inputs[i].clone()], proof);
}
}
}

// // #[test]
// fn test_pse_verifier_contracts_public_io_array() {
// let test_program_dirs = configure_test_dirs();
// // Pass in PSE Halo2 Backend as argument
// install_nargo("pse_halo2_backend");
// for test_program in &test_program_dirs[9..] {
// // Generate necessary files
// gen_nargo_files(test_program.clone());
// // Paths to relevant nargo generated files
// let contract_path = format!("{}/contract/plonk_vk.sol", test_program.display());
// let proof_path = format!("{}/proofs/my_test_proof.proof", test_program.display());

// let yul_code = read_to_string(contract_path);
// let deployment_code = compile_yul(&yul_code.unwrap());

// let proof = hex::decode(read(proof_path).unwrap()).unwrap();
// evm_verify(deployment_code, vec![vec![Fr::from(341), Fr::from(219), Fr::from(499)]],
// proof); }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ impl ProofSystemCompiler for ZcashHalo2 {
fn supports_opcode(&self, opcode: &acvm::acir::circuit::Opcode) -> bool {
match opcode {
Opcode::Arithmetic(_) => true,
Opcode::Directive(_) => false,
Opcode::MemoryInit { .. } | Opcode::MemoryOp { .. } => false,
Opcode::Directive(_) | Opcode::Brillig(_) => true,
Opcode::BlackBoxFuncCall(func) => match func.get_black_box_func() {
BlackBoxFunc::AND | BlackBoxFunc::RANGE => true,

Expand All @@ -113,7 +112,7 @@ impl ProofSystemCompiler for ZcashHalo2 {
| BlackBoxFunc::RecursiveAggregation
| BlackBoxFunc::SchnorrVerify => false,
},
Opcode::Brillig(_) => todo!(),
Opcode::Block(_) | Opcode::ROM(_) | Opcode::RAM(_) => false,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl SmartContract for ZcashHalo2 {
fn eth_contract_from_vk(
&self,
_common_reference_string: &[u8],
circuit: &Circuit,
_circuit: &Circuit,
_verification_key: &[u8],
) -> Result<String, Self::Error> {
panic!("ethereum solidity verifier not supported for halo2-ipa")
Expand Down
9 changes: 5 additions & 4 deletions crates/noir_halo2_backend_zcash/src/circuit_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ impl Halo2PlonkCircuit<Fp> for NoirHalo2Translator<Fp> {
} => todo!(),
};
}
Opcode::Directive(_) => {
// Directives are only needed by the pwg
Opcode::Directive(_) | Opcode::Brillig(_) => {
// Directives/ Brillig are only needed by the pwg
}
// memory managed by acvm
Opcode::MemoryInit { .. } | Opcode::MemoryOp { .. } => todo!(),
Opcode::Brillig(_) => todo!(),
Opcode::Block(_) | Opcode::ROM(_) | Opcode::RAM(_) => {
todo!()
}
}
}
Ok(())
Expand Down

0 comments on commit 6ec71d2

Please sign in to comment.