From d995e0648b53e5ca95c931bea8c121e8332a3618 Mon Sep 17 00:00:00 2001 From: guipublic <47281315+guipublic@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:07:34 +0200 Subject: [PATCH] chore: enable constant inputs for more blackbox (#5647) # Description ## Problem\* We create witness for blackbox inputs, even when the value is constant, which generates un-optimal circuit. ## Summary\* Some blackbox can now support constant inputs (cf. PR https://github.com/AztecProtocol/aztec-packages/pull/7613) so we enable the use of constant inputs for them. ## Additional Context ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [X] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- .../src/ssa/acir_gen/acir_ir/acir_variable.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs index a8324c11592..0cae7d77448 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs @@ -1428,8 +1428,20 @@ impl AcirContext { } _ => (vec![], vec![]), }; - // Allow constant inputs only for MSM for now - let allow_constant_inputs = name.eq(&BlackBoxFunc::MultiScalarMul); + // Allow constant inputs for most blackbox + // EmbeddedCurveAdd needs to be fixed first in bb + // Poseidon2Permutation requires witness input + let allow_constant_inputs = matches!( + name, + BlackBoxFunc::MultiScalarMul + | BlackBoxFunc::Keccakf1600 + | BlackBoxFunc::Sha256Compression + | BlackBoxFunc::Blake2s + | BlackBoxFunc::Blake3 + | BlackBoxFunc::AND + | BlackBoxFunc::XOR + | BlackBoxFunc::AES128Encrypt + ); // Convert `AcirVar` to `FunctionInput` let inputs = self.prepare_inputs_for_black_box_func_call(inputs, allow_constant_inputs)?; // Call Black box with `FunctionInput`