Skip to content

Commit

Permalink
chore: enable constant inputs for more blackbox (#5647)
Browse files Browse the repository at this point in the history
# 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
AztecProtocol/aztec-packages#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.
  • Loading branch information
guipublic authored Aug 21, 2024
1 parent eba5312 commit d995e06
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,8 +1428,20 @@ impl<F: AcirField> AcirContext<F> {
}
_ => (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`
Expand Down

0 comments on commit d995e06

Please sign in to comment.