From a429a5422d6f001b6db0d0a0f30c79ec0f96de89 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 25 May 2023 17:52:34 +0100 Subject: [PATCH] chore!: Remove AES opcode (#302) * rename aes to aes128 to be more specific * remove aes128 * fix clippy --- acir/src/circuit/black_box_functions.rs | 4 ---- acir/src/circuit/opcodes/black_box_function_call.rs | 13 ++----------- acvm/src/lib.rs | 6 ------ acvm/src/pwg.rs | 13 ++----------- acvm/src/pwg/blackbox.rs | 1 - 5 files changed, 4 insertions(+), 33 deletions(-) diff --git a/acir/src/circuit/black_box_functions.rs b/acir/src/circuit/black_box_functions.rs index 0925ec509..88aa8a889 100644 --- a/acir/src/circuit/black_box_functions.rs +++ b/acir/src/circuit/black_box_functions.rs @@ -6,8 +6,6 @@ use strum_macros::EnumIter; #[derive(Clone, Debug, Hash, Copy, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(test, derive(EnumIter))] pub enum BlackBoxFunc { - #[allow(clippy::upper_case_acronyms)] - AES, AND, XOR, RANGE, @@ -32,7 +30,6 @@ impl std::fmt::Display for BlackBoxFunc { impl BlackBoxFunc { pub fn name(&self) -> &'static str { match self { - BlackBoxFunc::AES => "aes", BlackBoxFunc::SHA256 => "sha256", BlackBoxFunc::SchnorrVerify => "schnorr_verify", BlackBoxFunc::Blake2s => "blake2s", @@ -48,7 +45,6 @@ impl BlackBoxFunc { } pub fn lookup(op_name: &str) -> Option { match op_name { - "aes" => Some(BlackBoxFunc::AES), "sha256" => Some(BlackBoxFunc::SHA256), "schnorr_verify" => Some(BlackBoxFunc::SchnorrVerify), "blake2s" => Some(BlackBoxFunc::Blake2s), diff --git a/acir/src/circuit/opcodes/black_box_function_call.rs b/acir/src/circuit/opcodes/black_box_function_call.rs index 137ba6e0f..24268f6a2 100644 --- a/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/acir/src/circuit/opcodes/black_box_function_call.rs @@ -18,11 +18,6 @@ impl FunctionInput { #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum BlackBoxFuncCall { - #[allow(clippy::upper_case_acronyms)] - AES { - inputs: Vec, - outputs: Vec, - }, AND { lhs: FunctionInput, rhs: FunctionInput, @@ -81,7 +76,6 @@ pub enum BlackBoxFuncCall { impl BlackBoxFuncCall { pub fn dummy(bb_func: BlackBoxFunc) -> Self { match bb_func { - BlackBoxFunc::AES => BlackBoxFuncCall::AES { inputs: vec![], outputs: vec![] }, BlackBoxFunc::AND => BlackBoxFuncCall::AND { lhs: FunctionInput::dummy(), rhs: FunctionInput::dummy(), @@ -127,7 +121,6 @@ impl BlackBoxFuncCall { pub fn get_black_box_func(&self) -> BlackBoxFunc { match self { - BlackBoxFuncCall::AES { .. } => BlackBoxFunc::AES, BlackBoxFuncCall::AND { .. } => BlackBoxFunc::AND, BlackBoxFuncCall::XOR { .. } => BlackBoxFunc::XOR, BlackBoxFuncCall::RANGE { .. } => BlackBoxFunc::RANGE, @@ -148,8 +141,7 @@ impl BlackBoxFuncCall { pub fn get_inputs_vec(&self) -> Vec { match self { - BlackBoxFuncCall::AES { inputs, .. } - | BlackBoxFuncCall::SHA256 { inputs, .. } + BlackBoxFuncCall::SHA256 { inputs, .. } | BlackBoxFuncCall::Blake2s { inputs, .. } | BlackBoxFuncCall::Keccak256 { inputs, .. } | BlackBoxFuncCall::Pedersen { inputs, .. } @@ -197,8 +189,7 @@ impl BlackBoxFuncCall { pub fn get_outputs_vec(&self) -> Vec { match self { - BlackBoxFuncCall::AES { outputs, .. } - | BlackBoxFuncCall::SHA256 { outputs, .. } + BlackBoxFuncCall::SHA256 { outputs, .. } | BlackBoxFuncCall::Blake2s { outputs, .. } | BlackBoxFuncCall::FixedBaseScalarMul { outputs, .. } | BlackBoxFuncCall::Pedersen { outputs, .. } diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 19101b250..e204e5801 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -74,12 +74,6 @@ pub trait CommonReferenceString { /// /// Returns an [`OpcodeResolutionError`] if the backend does not support the given [`Opcode::BlackBoxFuncCall`]. pub trait PartialWitnessGenerator { - fn aes( - &self, - initial_witness: &mut WitnessMap, - inputs: &[FunctionInput], - outputs: &[Witness], - ) -> Result; fn schnorr_verify( &self, initial_witness: &mut WitnessMap, diff --git a/acvm/src/pwg.rs b/acvm/src/pwg.rs index 765dfe413..1f132f200 100644 --- a/acvm/src/pwg.rs +++ b/acvm/src/pwg.rs @@ -3,7 +3,7 @@ use crate::{Language, PartialWitnessGenerator}; use acir::{ circuit::brillig::Brillig, - circuit::opcodes::{BlackBoxFuncCall, Opcode, OracleData}, + circuit::opcodes::{Opcode, OracleData}, native_types::{Expression, Witness, WitnessMap}, BlackBoxFunc, FieldElement, }; @@ -272,7 +272,7 @@ pub fn default_is_opcode_supported(language: Language) -> fn(&Opcode) -> bool { // attempt to transform into supported gates. If these are also not available // then a compiler error will be emitted. fn plonk_is_supported(opcode: &Opcode) -> bool { - !matches!(opcode, Opcode::BlackBoxFuncCall(BlackBoxFuncCall::AES { .. }) | Opcode::Block(_)) + !matches!(opcode, Opcode::Block(_)) } match language { @@ -311,15 +311,6 @@ mod test { struct StubbedPwg; impl PartialWitnessGenerator for StubbedPwg { - fn aes( - &self, - _initial_witness: &mut WitnessMap, - _inputs: &[FunctionInput], - _outputs: &[Witness], - ) -> Result { - panic!("Path not trodden by this test") - } - fn schnorr_verify( &self, _initial_witness: &mut WitnessMap, diff --git a/acvm/src/pwg/blackbox.rs b/acvm/src/pwg/blackbox.rs index e6f73450a..68ade81be 100644 --- a/acvm/src/pwg/blackbox.rs +++ b/acvm/src/pwg/blackbox.rs @@ -49,7 +49,6 @@ pub(crate) fn solve( } match bb_func { - BlackBoxFuncCall::AES { inputs, outputs } => backend.aes(initial_witness, inputs, outputs), acir::circuit::opcodes::BlackBoxFuncCall::AND { lhs, rhs, output } => { and(initial_witness, lhs, rhs, output) }