chore: bool_t from witness index functionality #16688
Conversation
| builder.fix_witness(input.result_infinite, infinite.get_value()); | ||
| } else { | ||
| builder.assert_equal(infinite.witness_index, input.result_infinite); | ||
| builder.assert_equal(infinite.get_normalized_witness_index(), input.result_infinite); |
There was a problem hiding this comment.
It's safer to always access the normalized index.
| bit.witness_bool = false; | ||
| ctx->create_new_range_constraint( | ||
| bit.witness_index, 1, "biggroup_nafs: compute_naf extracted too many bits in next_entry case"); | ||
| bool_ct bit(witness_t<C>(ctx, !next_entry)); |
There was a problem hiding this comment.
use the appropriate constructor to create a constrained bool witness
| * @warning The witness value **is not** constrained to be boolean. We simply perform an out-of-circuit sanity check. | ||
| */ | ||
| template <typename Builder> | ||
| bool_t<Builder> bool_t<Builder>::from_witness_index_unsafe(Builder* ctx, const uint32_t witness_index) |
There was a problem hiding this comment.
@guipublic here's the promissed functionality. It feels safer to me if all from_witness_index calls would be marked as unsafe, so that it's clear that such calls have to be justified + analyzed more carefully during the audit
for @suyash67 - Luke has spotted that in #16663, the witness index is set up directly to avoid creating an extra boolean gate which is redundant in this case (see the comments there). so I added this method + turned all class variables private
| bool get_value() const { return witness_bool ^ witness_inverted; } | ||
|
|
||
| bool is_constant() const { return witness_index == IS_CONSTANT; } | ||
| bool is_inverted() const |
There was a problem hiding this comment.
seems cleaner than adding a bunch of friend classes as friends
…/aztec-packages into si/bool-t-from-witness-idx
|
|
||
| if (use_range_constraint) { | ||
| // Create a range constraint gate | ||
| context->create_new_range_constraint(witness_index, 3, "bool_t: witness value is not 0 or 1"); |
There was a problem hiding this comment.
Should the range be [0, 1] and hence create_new_range_constraint(witness_index, 1, ...)?
…i/bool-t-from-witness-idx
BEGIN_COMMIT_OVERRIDE chore: compute beta products for max log dyadic size instead of 21 (#16772) chore: bool_t from witness index functionality (#16688) chore: audit the set relation of the ECCVM (#16706) chore: update readme in the eccvm to include description of multiset and lookups (#16765) END_COMMIT_OVERRIDE
Several `bool_t` improvements: * added a `from_witness_index_unsafe` constructor that implicitly appeared in #16663 * turned `witness_index` and other class members private * added a more efficient constructor that takes a `witness_t` and uses range constraints instead of `bool_gate`. see [related issue](AztecProtocol/barretenberg#1533) + the tests As a byproduct: * some simplifications in `compute_naf` method * using `get_normalized_witness_index` on `bool_t` outside of the friend `field_t` and `biggroup` classes * slightly improved `used_witnesses` handling in a couple of places. The vks and the number of gates have changed due to a tiny opt related to re-using a couple of `bool_t` results in `+` and `-` in `biggroup`
Several `bool_t` improvements: * added a `from_witness_index_unsafe` constructor that implicitly appeared in #16663 * turned `witness_index` and other class members private * added a more efficient constructor that takes a `witness_t` and uses range constraints instead of `bool_gate`. see [related issue](AztecProtocol/barretenberg#1533) + the tests As a byproduct: * some simplifications in `compute_naf` method * using `get_normalized_witness_index` on `bool_t` outside of the friend `field_t` and `biggroup` classes * slightly improved `used_witnesses` handling in a couple of places. The vks and the number of gates have changed due to a tiny opt related to re-using a couple of `bool_t` results in `+` and `-` in `biggroup`
Several `bool_t` improvements: * added a `from_witness_index_unsafe` constructor that implicitly appeared in #16663 * turned `witness_index` and other class members private * added a more efficient constructor that takes a `witness_t` and uses range constraints instead of `bool_gate`. see [related issue](AztecProtocol/barretenberg#1533) + the tests As a byproduct: * some simplifications in `compute_naf` method * using `get_normalized_witness_index` on `bool_t` outside of the friend `field_t` and `biggroup` classes * slightly improved `used_witnesses` handling in a couple of places. The vks and the number of gates have changed due to a tiny opt related to re-using a couple of `bool_t` results in `+` and `-` in `biggroup`
Several
bool_timprovements:from_witness_index_unsafeconstructor that implicitly appeared in chore: use the bb predicates when generating constraints #16663witness_indexand other class members privatewitness_tand uses range constraints instead ofbool_gate. see related issue + the testsAs a byproduct:
compute_nafmethodget_normalized_witness_indexonbool_toutside of the friendfield_tandbiggroupclassesused_witnesseshandling in a couple of places.The vks and the number of gates have changed due to a tiny opt related to re-using a couple of
bool_tresults in+and-inbiggroup