Skip to content

Commit

Permalink
chore: miscellaneous ACVM fixups (noir-lang#2864)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored and Sakapoi committed Oct 19, 2023
1 parent d584bc3 commit 239155a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
6 changes: 3 additions & 3 deletions acvm-repo/acvm/src/compiler/transformers/csat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ impl CSatTransformer {
opcode.mul_terms = remaining_mul_terms;

// Add the rest of the elements back into the new_opcode
new_opcode.mul_terms.extend(opcode.mul_terms.clone());
new_opcode.linear_combinations.extend(opcode.linear_combinations.clone());
new_opcode.mul_terms.extend(opcode.mul_terms);
new_opcode.linear_combinations.extend(opcode.linear_combinations);
new_opcode.q_c = opcode.q_c;
new_opcode.sort();
new_opcode
Expand Down Expand Up @@ -332,7 +332,7 @@ impl CSatTransformer {

// 2. Create Intermediate variables for the multiplication opcodes
let mut remaining_mul_terms = Vec::with_capacity(opcode.mul_terms.len());
for mul_term in opcode.mul_terms.clone().into_iter() {
for mul_term in opcode.mul_terms {
if self.solvable_witness.contains(&mul_term.1)
&& self.solvable_witness.contains(&mul_term.2)
{
Expand Down
38 changes: 11 additions & 27 deletions acvm-repo/acvm/src/compiler/transformers/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ impl FallbackTransformer {
}
#[cfg(feature = "unstable-fallbacks")]
BlackBoxFuncCall::SHA256 { inputs, outputs } => {
let mut sha256_inputs = Vec::new();
for input in inputs.iter() {
let witness_index = Expression::from(input.witness);
let num_bits = input.num_bits;
sha256_inputs.push((witness_index, num_bits));
}
let sha256_inputs =
inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect();
stdlib::blackbox_fallbacks::sha256(
sha256_inputs,
outputs.to_vec(),
Expand All @@ -120,42 +116,30 @@ impl FallbackTransformer {
}
#[cfg(feature = "unstable-fallbacks")]
BlackBoxFuncCall::Blake2s { inputs, outputs } => {
let mut blake2s_input = Vec::new();
for input in inputs.iter() {
let witness_index = Expression::from(input.witness);
let num_bits = input.num_bits;
blake2s_input.push((witness_index, num_bits));
}
let blake2s_inputs =
inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect();
stdlib::blackbox_fallbacks::blake2s(
blake2s_input,
blake2s_inputs,
outputs.to_vec(),
current_witness_idx,
)
}
#[cfg(feature = "unstable-fallbacks")]
BlackBoxFuncCall::HashToField128Security { inputs, output } => {
let mut blake2s_input = Vec::new();
for input in inputs.iter() {
let witness_index = Expression::from(input.witness);
let num_bits = input.num_bits;
blake2s_input.push((witness_index, num_bits));
}
let hash_to_field_inputs =
inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect();
stdlib::blackbox_fallbacks::hash_to_field(
blake2s_input,
hash_to_field_inputs,
*output,
current_witness_idx,
)
}
#[cfg(feature = "unstable-fallbacks")]
BlackBoxFuncCall::Keccak256 { inputs, outputs } => {
let mut keccak_input = Vec::new();
for input in inputs.iter() {
let witness_index = Expression::from(input.witness);
let num_bits = input.num_bits;
keccak_input.push((witness_index, num_bits));
}
let keccak_inputs =
inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect();
stdlib::blackbox_fallbacks::keccak256(
keccak_input,
keccak_inputs,
outputs.to_vec(),
current_witness_idx,
)
Expand Down

0 comments on commit 239155a

Please sign in to comment.