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

Commit

Permalink
feat(acir)!: Add keccak256 Opcode (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray authored Feb 14, 2023
1 parent 9329307 commit b909146
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum BlackBoxFunc {
HashToField128Security,
EcdsaSecp256k1,
FixedBaseScalarMul,
Keccak256,
}

impl std::fmt::Display for BlackBoxFunc {
Expand All @@ -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<Self> {
Expand All @@ -60,6 +62,7 @@ impl BlackBoxFunc {
9 => BlackBoxFunc::AND,
10 => BlackBoxFunc::XOR,
11 => BlackBoxFunc::RANGE,
12 => BlackBoxFunc::Keccak256,
_ => return None,
};
Some(function)
Expand All @@ -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<BlackBoxFunc> {
Expand All @@ -94,6 +98,7 @@ impl BlackBoxFunc {
"and" => Some(BlackBoxFunc::AND),
"xor" => Some(BlackBoxFunc::XOR),
"range" => Some(BlackBoxFunc::RANGE),
"keccak256" => Some(BlackBoxFunc::Keccak256),
_ => None,
}
}
Expand Down Expand Up @@ -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),
},
}
}
}
Expand Down

0 comments on commit b909146

Please sign in to comment.