Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: miscellaneous ACVM fixups #2864

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -9,7 +9,7 @@
/// A transformer which processes any [`Expression`]s to break them up such that they
/// fit within the [`ProofSystemCompiler`][crate::ProofSystemCompiler]'s width.
///
/// This transformer is only used when targetting the [`PLONKCSat`][crate::Language::PLONKCSat] language.

Check warning on line 12 in acvm-repo/acvm/src/compiler/transformers/csat.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (targetting)
///
/// This is done by creating intermediate variables to hold partial calculations and then combining them
/// to calculate the original expression.
Expand Down Expand Up @@ -235,8 +235,8 @@
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 @@

// 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