From bdc2110b865b6b615a5d220eb116eaccb83b9da9 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 9 May 2023 18:15:59 +0100 Subject: [PATCH 01/12] add Fn trait for IsSupported and replace IsBlackBoxSupported with IsOpcodeSupported --- acvm/src/compiler.rs | 6 +++--- acvm/src/compiler/optimizers/simplify.rs | 7 ++----- acvm/src/compiler/transformers/fallback.rs | 7 ++----- acvm/src/compiler/transformers/mod.rs | 1 - acvm/src/lib.rs | 8 +++----- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index bb4db27cc..a3bd3d541 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -11,7 +11,7 @@ use acir::{ use indexmap::IndexMap; use optimizers::GeneralOptimizer; use thiserror::Error; -use transformers::{CSatTransformer, FallbackTransformer, IsOpcodeSupported, R1CSTransformer}; +use transformers::{CSatTransformer, FallbackTransformer, R1CSTransformer}; use self::optimizers::RangeOptimizer; use self::optimizers::Simplifier; @@ -22,10 +22,10 @@ pub enum CompileError { UnsupportedBlackBox(BlackBoxFunc), } -pub fn compile( +pub fn compile bool>( acir: Circuit, np_language: Language, - is_opcode_supported: IsOpcodeSupported, + is_opcode_supported: F, simplifier: &Simplifier, ) -> Result { // Instantiate the optimizer. diff --git a/acvm/src/compiler/optimizers/simplify.rs b/acvm/src/compiler/optimizers/simplify.rs index 5373d128f..3737d1e0c 100644 --- a/acvm/src/compiler/optimizers/simplify.rs +++ b/acvm/src/compiler/optimizers/simplify.rs @@ -439,10 +439,7 @@ mod test { FieldElement, }; - use crate::compiler::{ - optimizers::Simplifier, - transformers::{FallbackTransformer, IsOpcodeSupported}, - }; + use crate::compiler::{optimizers::Simplifier, transformers::FallbackTransformer}; #[test] fn simplify_test() { @@ -479,7 +476,7 @@ mod test { simplifier.simplify(&mut circuit); assert_eq!(circuit.len(), 3); assert_eq!(simplifier.solved_gates.len(), 1); - let support_all: IsOpcodeSupported = |_| true; + let support_all = |_opcode: &Opcode| true; let mut acir = Circuit::default(); acir.opcodes = circuit; let acir = FallbackTransformer::transform(acir, support_all, &simplifier).unwrap(); diff --git a/acvm/src/compiler/transformers/fallback.rs b/acvm/src/compiler/transformers/fallback.rs index b9bc8834e..6736fb9b4 100644 --- a/acvm/src/compiler/transformers/fallback.rs +++ b/acvm/src/compiler/transformers/fallback.rs @@ -7,16 +7,13 @@ use acir::{ BlackBoxFunc, }; -// A predicate that returns true if the black box function is supported -pub type IsOpcodeSupported = fn(&Opcode) -> bool; - pub struct FallbackTransformer; impl FallbackTransformer { //ACIR pass which replace unsupported opcodes using arithmetic fallback - pub fn transform( + pub fn transform bool>( acir: Circuit, - is_supported: IsOpcodeSupported, + is_supported: F, simplifier: &Simplifier, ) -> Result { let mut acir_supported_opcodes = Vec::with_capacity(acir.opcodes.len()); diff --git a/acvm/src/compiler/transformers/mod.rs b/acvm/src/compiler/transformers/mod.rs index ddc0e3419..e0d690188 100644 --- a/acvm/src/compiler/transformers/mod.rs +++ b/acvm/src/compiler/transformers/mod.rs @@ -4,5 +4,4 @@ mod r1cs; pub use csat::CSatTransformer; pub use fallback::FallbackTransformer; -pub use fallback::IsOpcodeSupported; pub use r1cs::R1CSTransformer; diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 60609b1fd..8144634a1 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -159,8 +159,8 @@ pub trait ProofSystemCompiler { /// if the language and proof system does not line up. fn np_language(&self) -> Language; - // Returns true if the backend supports the selected black box function - fn black_box_function_supported(&self, opcode: &BlackBoxFunc) -> bool; + // Returns true if the backend supports the selected opcode + fn opcode_supported(&self, opcode: &Opcode) -> bool; /// Returns the number of gates in a circuit fn get_exact_circuit_size(&self, circuit: &Circuit) -> Result; @@ -227,9 +227,7 @@ pub fn checksum_constraint_system(cs: &Circuit) -> u32 { // This is set to match the previous functionality that we had // Where we could deduce what opcodes were supported // by knowing the np complete language -pub fn default_is_opcode_supported( - language: Language, -) -> compiler::transformers::IsOpcodeSupported { +pub fn default_is_opcode_supported(language: Language) -> impl Fn(&Opcode) -> bool { // R1CS does not support any of the opcode except Arithmetic by default. // The compiler will replace those that it can -- ie range, xor, and fn r1cs_is_supported(opcode: &Opcode) -> bool { From 2e4dbbefe30d1772b496b9ca6efd7cdde5319257 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 9 May 2023 18:54:29 +0100 Subject: [PATCH 02/12] add dummy compiler --- acvm/src/compiler.rs | 195 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index a3bd3d541..ba39fdba9 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -106,3 +106,198 @@ pub fn compile bool>( return_values: acir.return_values, }) } + +#[test] +fn foo() { + #[derive(Debug, Default)] + struct DummyBackend; + + impl crate::PartialWitnessGenerator for DummyBackend { + fn aes( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn and( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn xor( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn range( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + ) -> Result { + todo!() + } + + fn sha256( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn blake2s( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn compute_merkle_root( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn schnorr_verify( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn pedersen( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn hash_to_field128_security( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn ecdsa_secp256k1( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn fixed_base_scalar_mul( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + + fn keccak256( + &self, + _initial_witness: &mut std::collections::BTreeMap, + _inputs: &[acir::circuit::opcodes::FunctionInput], + _outputs: &[Witness], + ) -> Result { + todo!() + } + } + + #[derive(Debug, Default)] + struct DummyError; + + impl std::fmt::Display for DummyError { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + impl std::error::Error for DummyError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + None + } + + fn description(&self) -> &str { + "description() is deprecated; use Display" + } + + fn cause(&self) -> Option<&dyn std::error::Error> { + self.source() + } + } + impl crate::ProofSystemCompiler for DummyBackend { + type Error = DummyError; + + fn np_language(&self) -> Language { + todo!() + } + + fn opcode_supported(&self, _opcode: &Opcode) -> bool { + todo!() + } + + fn get_exact_circuit_size(&self, _circuit: &Circuit) -> Result { + todo!() + } + + fn preprocess(&self, _circuit: &Circuit) -> Result<(Vec, Vec), Self::Error> { + todo!() + } + + fn prove_with_pk( + &self, + _circuit: &Circuit, + _witness_values: std::collections::BTreeMap, + _proving_key: &[u8], + ) -> Result, Self::Error> { + todo!() + } + + fn verify_with_vk( + &self, + _proof: &[u8], + _public_inputs: std::collections::BTreeMap, + _circuit: &Circuit, + _verification_key: &[u8], + ) -> Result { + todo!() + } + } + + impl crate::SmartContract for DummyBackend { + type Error = DummyError; + + fn eth_contract_from_vk(&self, _verification_key: &[u8]) -> Result { + todo!() + } + } + + impl crate::Backend for DummyBackend {} +} From 80a53eb393dff739dacac701915f40f10f0beafd Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 9 May 2023 18:54:59 +0100 Subject: [PATCH 03/12] add call to compile method --- acvm/src/compiler.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index ba39fdba9..58b120204 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -109,6 +109,16 @@ pub fn compile bool>( #[test] fn foo() { + use crate::ProofSystemCompiler; + + compile( + Circuit::default(), + Language::R1CS, + |opcode| DummyBackend.opcode_supported(opcode), + &Simplifier::new(0), + ) + .unwrap(); + #[derive(Debug, Default)] struct DummyBackend; From 45bd727e9bfb989ed714b98fe098ac010e052713 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 9 May 2023 19:00:44 +0100 Subject: [PATCH 04/12] merge master --- acvm/src/compiler.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index 58b120204..20f640f0a 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -203,7 +203,7 @@ fn foo() { todo!() } - fn hash_to_field128_security( + fn ecdsa_secp256k1( &self, _initial_witness: &mut std::collections::BTreeMap, _inputs: &[acir::circuit::opcodes::FunctionInput], @@ -212,7 +212,7 @@ fn foo() { todo!() } - fn ecdsa_secp256k1( + fn fixed_base_scalar_mul( &self, _initial_witness: &mut std::collections::BTreeMap, _inputs: &[acir::circuit::opcodes::FunctionInput], @@ -221,7 +221,7 @@ fn foo() { todo!() } - fn fixed_base_scalar_mul( + fn keccak256( &self, _initial_witness: &mut std::collections::BTreeMap, _inputs: &[acir::circuit::opcodes::FunctionInput], @@ -230,7 +230,7 @@ fn foo() { todo!() } - fn keccak256( + fn hash_to_field_128_security( &self, _initial_witness: &mut std::collections::BTreeMap, _inputs: &[acir::circuit::opcodes::FunctionInput], From a2634754ca06f169ab2c60eef7475eb1ee63d9ca Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 9 May 2023 19:10:40 +0100 Subject: [PATCH 05/12] rename test method --- acvm/src/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index 20f640f0a..fecfb5b31 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -108,7 +108,7 @@ pub fn compile bool>( } #[test] -fn foo() { +fn compile_api_compiles_with_backend() { use crate::ProofSystemCompiler; compile( From 2411b61a2722ccdc82e414e45b3f59523e32bbc8 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 10 May 2023 01:39:14 +0100 Subject: [PATCH 06/12] chore: minimal test case --- acvm/src/compiler.rs | 157 ++----------------------------------------- 1 file changed, 5 insertions(+), 152 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index fecfb5b31..c29271855 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -114,155 +114,18 @@ fn compile_api_compiles_with_backend() { compile( Circuit::default(), Language::R1CS, - |opcode| DummyBackend.opcode_supported(opcode), + |opcode| DummyProofSystem.opcode_supported(opcode), &Simplifier::new(0), ) .unwrap(); #[derive(Debug, Default)] - struct DummyBackend; + struct DummyProofSystem; - impl crate::PartialWitnessGenerator for DummyBackend { - fn aes( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn and( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn xor( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn range( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - ) -> Result { - todo!() - } - - fn sha256( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn blake2s( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn compute_merkle_root( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } + #[derive(Error, Debug)] + enum DummyError {} - fn schnorr_verify( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn pedersen( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn ecdsa_secp256k1( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn fixed_base_scalar_mul( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn keccak256( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - - fn hash_to_field_128_security( - &self, - _initial_witness: &mut std::collections::BTreeMap, - _inputs: &[acir::circuit::opcodes::FunctionInput], - _outputs: &[Witness], - ) -> Result { - todo!() - } - } - - #[derive(Debug, Default)] - struct DummyError; - - impl std::fmt::Display for DummyError { - fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - todo!() - } - } - - impl std::error::Error for DummyError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - None - } - - fn description(&self) -> &str { - "description() is deprecated; use Display" - } - - fn cause(&self) -> Option<&dyn std::error::Error> { - self.source() - } - } - impl crate::ProofSystemCompiler for DummyBackend { + impl crate::ProofSystemCompiler for DummyProofSystem { type Error = DummyError; fn np_language(&self) -> Language { @@ -300,14 +163,4 @@ fn compile_api_compiles_with_backend() { todo!() } } - - impl crate::SmartContract for DummyBackend { - type Error = DummyError; - - fn eth_contract_from_vk(&self, _verification_key: &[u8]) -> Result { - todo!() - } - } - - impl crate::Backend for DummyBackend {} } From 2daad1b1b9ef4e6434fc0bcf7e62af49f6909715 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 10 May 2023 01:41:23 +0100 Subject: [PATCH 07/12] chore: tweaks to test --- acvm/src/compiler.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index c29271855..b194b155e 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -125,23 +125,23 @@ fn compile_api_compiles_with_backend() { #[derive(Error, Debug)] enum DummyError {} - impl crate::ProofSystemCompiler for DummyProofSystem { + impl ProofSystemCompiler for DummyProofSystem { type Error = DummyError; fn np_language(&self) -> Language { - todo!() + panic!("Path not trodden by this test") } fn opcode_supported(&self, _opcode: &Opcode) -> bool { - todo!() + panic!("Path not trodden by this test") } fn get_exact_circuit_size(&self, _circuit: &Circuit) -> Result { - todo!() + panic!("Path not trodden by this test") } fn preprocess(&self, _circuit: &Circuit) -> Result<(Vec, Vec), Self::Error> { - todo!() + panic!("Path not trodden by this test") } fn prove_with_pk( @@ -150,7 +150,7 @@ fn compile_api_compiles_with_backend() { _witness_values: std::collections::BTreeMap, _proving_key: &[u8], ) -> Result, Self::Error> { - todo!() + panic!("Path not trodden by this test") } fn verify_with_vk( @@ -160,7 +160,7 @@ fn compile_api_compiles_with_backend() { _circuit: &Circuit, _verification_key: &[u8], ) -> Result { - todo!() + panic!("Path not trodden by this test") } } } From 65090f2964b4147362c346051ea5f023c7e46d0a Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 10 May 2023 01:48:07 +0100 Subject: [PATCH 08/12] chore: nicer generic syntax --- acvm/src/compiler.rs | 4 ++-- acvm/src/compiler/transformers/fallback.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index b194b155e..206445819 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -22,10 +22,10 @@ pub enum CompileError { UnsupportedBlackBox(BlackBoxFunc), } -pub fn compile bool>( +pub fn compile( acir: Circuit, np_language: Language, - is_opcode_supported: F, + is_opcode_supported: impl Fn(&Opcode) -> bool, simplifier: &Simplifier, ) -> Result { // Instantiate the optimizer. diff --git a/acvm/src/compiler/transformers/fallback.rs b/acvm/src/compiler/transformers/fallback.rs index 6736fb9b4..ca68e9aed 100644 --- a/acvm/src/compiler/transformers/fallback.rs +++ b/acvm/src/compiler/transformers/fallback.rs @@ -11,9 +11,9 @@ pub struct FallbackTransformer; impl FallbackTransformer { //ACIR pass which replace unsupported opcodes using arithmetic fallback - pub fn transform bool>( + pub fn transform( acir: Circuit, - is_supported: F, + is_supported: impl Fn(&Opcode) -> bool, simplifier: &Simplifier, ) -> Result { let mut acir_supported_opcodes = Vec::with_capacity(acir.opcodes.len()); From c69ac5ed1cd234c278972d60ed2b70e4d5f0db88 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 16 May 2023 04:00:12 +0100 Subject: [PATCH 09/12] chore: remove `compile_api_compiles_with_backend` test --- acvm/src/compiler.rs | 58 -------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/acvm/src/compiler.rs b/acvm/src/compiler.rs index 206445819..07d103346 100644 --- a/acvm/src/compiler.rs +++ b/acvm/src/compiler.rs @@ -106,61 +106,3 @@ pub fn compile( return_values: acir.return_values, }) } - -#[test] -fn compile_api_compiles_with_backend() { - use crate::ProofSystemCompiler; - - compile( - Circuit::default(), - Language::R1CS, - |opcode| DummyProofSystem.opcode_supported(opcode), - &Simplifier::new(0), - ) - .unwrap(); - - #[derive(Debug, Default)] - struct DummyProofSystem; - - #[derive(Error, Debug)] - enum DummyError {} - - impl ProofSystemCompiler for DummyProofSystem { - type Error = DummyError; - - fn np_language(&self) -> Language { - panic!("Path not trodden by this test") - } - - fn opcode_supported(&self, _opcode: &Opcode) -> bool { - panic!("Path not trodden by this test") - } - - fn get_exact_circuit_size(&self, _circuit: &Circuit) -> Result { - panic!("Path not trodden by this test") - } - - fn preprocess(&self, _circuit: &Circuit) -> Result<(Vec, Vec), Self::Error> { - panic!("Path not trodden by this test") - } - - fn prove_with_pk( - &self, - _circuit: &Circuit, - _witness_values: std::collections::BTreeMap, - _proving_key: &[u8], - ) -> Result, Self::Error> { - panic!("Path not trodden by this test") - } - - fn verify_with_vk( - &self, - _proof: &[u8], - _public_inputs: std::collections::BTreeMap, - _circuit: &Circuit, - _verification_key: &[u8], - ) -> Result { - panic!("Path not trodden by this test") - } - } -} From 8265d40fd22ec5465cd7883905c224f866b0ea6d Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 16 May 2023 04:01:45 +0100 Subject: [PATCH 10/12] chore: rename `opcode_supported` to `supports_opcode` --- acvm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 4ed0da805..c158b05ae 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -160,7 +160,7 @@ pub trait ProofSystemCompiler { fn np_language(&self) -> Language; // Returns true if the backend supports the selected opcode - fn opcode_supported(&self, opcode: &Opcode) -> bool; + fn supports_opcode(&self, opcode: &Opcode) -> bool; /// Returns the number of gates in a circuit fn get_exact_circuit_size(&self, circuit: &Circuit) -> Result; From 0b08630a502cc4acb29905b332fa42341b812c2a Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 16 May 2023 04:03:07 +0100 Subject: [PATCH 11/12] chore: return function pointer from `default_is_opcode_supported` --- acvm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index c158b05ae..c4c4e6254 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -227,7 +227,7 @@ pub fn checksum_constraint_system(cs: &Circuit) -> u32 { // This is set to match the previous functionality that we had // Where we could deduce what opcodes were supported // by knowing the np complete language -pub fn default_is_opcode_supported(language: Language) -> impl Fn(&Opcode) -> bool { +pub fn default_is_opcode_supported(language: Language) -> fn(&Opcode) -> bool { // R1CS does not support any of the opcode except Arithmetic by default. // The compiler will replace those that it can -- ie range, xor, and fn r1cs_is_supported(opcode: &Opcode) -> bool { From aafb5d031d779bbaa263e50fee67c0706a41a2c1 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 16 May 2023 04:07:02 +0100 Subject: [PATCH 12/12] chore: update deprecation message for `default_is_opcode_supported` --- acvm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index c4c4e6254..4e8b0485e 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -222,7 +222,7 @@ pub fn checksum_constraint_system(cs: &Circuit) -> u32 { } #[deprecated( - note = "For backwards compatibility, this method allows you to derive _sensible_ defaults for black box function support based on the np language. \n Backends should simply specify what they support." + note = "For backwards compatibility, this method allows you to derive _sensible_ defaults for opcode support based on the np language. \n Backends should simply specify what they support." )] // This is set to match the previous functionality that we had // Where we could deduce what opcodes were supported