diff --git a/acir/src/circuit/black_box_functions.rs b/acir/src/circuit/black_box_functions.rs index b59ed95d2..5834dc556 100644 --- a/acir/src/circuit/black_box_functions.rs +++ b/acir/src/circuit/black_box_functions.rs @@ -21,6 +21,7 @@ pub enum BlackBoxFunc { HashToField128Security, EcdsaSecp256k1, FixedBaseScalarMul, + Keccak256, } impl std::fmt::Display for BlackBoxFunc { @@ -44,6 +45,7 @@ impl BlackBoxFunc { BlackBoxFunc::AND => 9, BlackBoxFunc::XOR => 10, BlackBoxFunc::RANGE => 11, + BlackBoxFunc::Keccak256 => 12, } } pub fn from_u16(index: u16) -> Option { @@ -60,6 +62,7 @@ impl BlackBoxFunc { 9 => BlackBoxFunc::AND, 10 => BlackBoxFunc::XOR, 11 => BlackBoxFunc::RANGE, + 12 => BlackBoxFunc::Keccak256, _ => return None, }; Some(function) @@ -78,6 +81,7 @@ impl BlackBoxFunc { BlackBoxFunc::AND => "and", BlackBoxFunc::XOR => "xor", BlackBoxFunc::RANGE => "range", + BlackBoxFunc::Keccak256 => "keccak256", } } pub fn lookup(op_name: &str) -> Option { @@ -94,6 +98,7 @@ impl BlackBoxFunc { "and" => Some(BlackBoxFunc::AND), "xor" => Some(BlackBoxFunc::XOR), "range" => Some(BlackBoxFunc::RANGE), + "keccak256" => Some(BlackBoxFunc::Keccak256), _ => None, } } @@ -162,6 +167,11 @@ impl BlackBoxFunc { input_size: InputSize::Fixed(1), output_size: OutputSize(0), }, + BlackBoxFunc::Keccak256 => FuncDefinition { + name, + input_size: InputSize::Variable, + output_size: OutputSize(32), + }, } } }