Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
chore!: Remove AES opcode (#302)
Browse files Browse the repository at this point in the history
* rename aes to aes128 to be more specific

* remove aes128

* fix clippy
  • Loading branch information
kevaundray authored May 25, 2023
1 parent 3c6740a commit a429a54
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 33 deletions.
4 changes: 0 additions & 4 deletions acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -48,7 +45,6 @@ impl BlackBoxFunc {
}
pub fn lookup(op_name: &str) -> Option<BlackBoxFunc> {
match op_name {
"aes" => Some(BlackBoxFunc::AES),
"sha256" => Some(BlackBoxFunc::SHA256),
"schnorr_verify" => Some(BlackBoxFunc::SchnorrVerify),
"blake2s" => Some(BlackBoxFunc::Blake2s),
Expand Down
13 changes: 2 additions & 11 deletions acir/src/circuit/opcodes/black_box_function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ impl FunctionInput {

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum BlackBoxFuncCall {
#[allow(clippy::upper_case_acronyms)]
AES {
inputs: Vec<FunctionInput>,
outputs: Vec<Witness>,
},
AND {
lhs: FunctionInput,
rhs: FunctionInput,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand All @@ -148,8 +141,7 @@ impl BlackBoxFuncCall {

pub fn get_inputs_vec(&self) -> Vec<FunctionInput> {
match self {
BlackBoxFuncCall::AES { inputs, .. }
| BlackBoxFuncCall::SHA256 { inputs, .. }
BlackBoxFuncCall::SHA256 { inputs, .. }
| BlackBoxFuncCall::Blake2s { inputs, .. }
| BlackBoxFuncCall::Keccak256 { inputs, .. }
| BlackBoxFuncCall::Pedersen { inputs, .. }
Expand Down Expand Up @@ -197,8 +189,7 @@ impl BlackBoxFuncCall {

pub fn get_outputs_vec(&self) -> Vec<Witness> {
match self {
BlackBoxFuncCall::AES { outputs, .. }
| BlackBoxFuncCall::SHA256 { outputs, .. }
BlackBoxFuncCall::SHA256 { outputs, .. }
| BlackBoxFuncCall::Blake2s { outputs, .. }
| BlackBoxFuncCall::FixedBaseScalarMul { outputs, .. }
| BlackBoxFuncCall::Pedersen { outputs, .. }
Expand Down
6 changes: 0 additions & 6 deletions acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpcodeResolution, OpcodeResolutionError>;
fn schnorr_verify(
&self,
initial_witness: &mut WitnessMap,
Expand Down
13 changes: 2 additions & 11 deletions acvm/src/pwg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -311,15 +311,6 @@ mod test {
struct StubbedPwg;

impl PartialWitnessGenerator for StubbedPwg {
fn aes(
&self,
_initial_witness: &mut WitnessMap,
_inputs: &[FunctionInput],
_outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}

fn schnorr_verify(
&self,
_initial_witness: &mut WitnessMap,
Expand Down
1 change: 0 additions & 1 deletion acvm/src/pwg/blackbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit a429a54

Please sign in to comment.