|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
Test class for ACIR constraints that contain a predicate. More...
#include <test_class_predicate.hpp>
Public Types | |
| using | Builder = Base::Builder |
| using | InvalidWitness = Base::InvalidWitness |
| using | InvalidWitnessTarget = InvalidWitness::Target |
| using | AcirConstraint = Base::AcirConstraint |
Static Public Member Functions | |
| static void | update_witness_based_on_predicate (AcirConstraint &constraint, WitnessVector &witness_values, const Predicate< InvalidWitnessTarget > &mode) |
| Update the constraint and the witness based on the predicate. | |
| static std::pair< AcirConstraint, WitnessVector > | generate_constraints (const Predicate< InvalidWitnessTarget > &mode) |
| Generate constraints and witness values based on the predicate and the invalidation target. | |
| static std::tuple< bool, bool, std::string > | test_constraints (const PredicateTestCase &test_case, const InvalidWitnessTarget &invalid_witness_target) |
| General purpose testing function. It generates the test based on the predicate and invalidation target. | |
| template<typename Flavor > | |
| static std::vector< size_t > | test_vk_independence () |
| Test vk generation is independent of the witness values supplied. | |
| static void | test_constant_true (InvalidWitnessTarget default_invalid_witness_target) |
| Test all cases in which the predicate is a constant holding the value true. | |
| static void | test_witness_true (InvalidWitnessTarget default_invalid_witness_target) |
| Test all cases in which the predicate is a witness holding the value true. | |
| static void | test_witness_false () |
| Test all invalid witness cases for the witness false predicate case. | |
| static void | test_witness_false_slow () |
| Test all invalid witness cases for the witness false predicate case (slow comprehensive version). | |
| static std::vector< std::string > | test_invalid_witnesses () |
| Test all invalid witness targets across all predicate cases (comprehensive matrix test). | |
Test class for ACIR constraints that contain a predicate.
Definition at line 95 of file test_class_predicate.hpp.
| using acir_format::TestClassWithPredicate< Base >::AcirConstraint = Base::AcirConstraint |
Definition at line 100 of file test_class_predicate.hpp.
| using acir_format::TestClassWithPredicate< Base >::Builder = Base::Builder |
Definition at line 97 of file test_class_predicate.hpp.
| using acir_format::TestClassWithPredicate< Base >::InvalidWitness = Base::InvalidWitness |
Definition at line 98 of file test_class_predicate.hpp.
| using acir_format::TestClassWithPredicate< Base >::InvalidWitnessTarget = InvalidWitness::Target |
Definition at line 99 of file test_class_predicate.hpp.
|
inlinestatic |
Generate constraints and witness values based on the predicate and the invalidation target.
Definition at line 134 of file test_class_predicate.hpp.
|
inlinestatic |
Test all cases in which the predicate is a constant holding the value true.
When the predicate is a constant true, the constraint is always active and must be satisfied. This test verifies two scenarios:
| default_invalid_witness_target | Invalidation target to be used to check that the circuit fails when witnesses are invalid. |
Definition at line 243 of file test_class_predicate.hpp.
|
inlinestatic |
General purpose testing function. It generates the test based on the predicate and invalidation target.
In a real flow, we have: Noir --> ACIR --> Bytes --> AcirFormat (via circuit_buf_to_acir_format) --> Builder We simulate the above flow by generating an AcirConstraint (one of the constraints stored in an AcirFormat struct), rewinding it into its Acir::Opcode form (which is the output of the byte deserialization step in the diagram above), and then feeding it into circuit_serde_to_acir_format as an Acir::Circuit with a single opcode. The function circuit_buf_to_acir_format internally calls circuit_serde_to_acir_format after having deserialized the byte buffer to an Acir::Circuit, so the flow in this test is the same as the real flow, minus the byte serialization/deserialization. The rationale for doing the rewinding is ensuring that barretenberg internally tests circuit_serde_to_acir_format, which would otherwise only be tested via the tests in acir_tests.
Definition at line 158 of file test_class_predicate.hpp.
|
inlinestatic |
Test all invalid witness targets across all predicate cases (comprehensive matrix test).
This is a comprehensive test that creates a matrix of all combinations:
Expected behavior:
Definition at line 382 of file test_class_predicate.hpp.
|
inlinestatic |
Test vk generation is independent of the witness values supplied.
This function tests that the verification key is deterministic and independent of the witness values by going through the full ACIR flow.
| Flavor |
Definition at line 183 of file test_class_predicate.hpp.
|
inlinestatic |
Test all invalid witness cases for the witness false predicate case.
When the predicate is a witness set to false, the constraint is disabled and should not fail regardless of witness validity. This test iterates through ALL invalid witness targets (None, and all specific invalidation cases) and verifies that the circuit succeeds in every case when predicate = false.
Definition at line 309 of file test_class_predicate.hpp.
|
inlinestatic |
Test all invalid witness cases for the witness false predicate case (slow comprehensive version).
This is an extended version of test_witness_false that performs double verification:
For each invalid witness target:
The second pass validates that our invalidation logic is actually creating invalid inputs. Useful for debugging.
Definition at line 336 of file test_class_predicate.hpp.
|
inlinestatic |
Test all cases in which the predicate is a witness holding the value true.
When the predicate is a witness set to true, the constraint is active and must be satisfied. This test verifies two scenarios:
| default_invalid_witness_target | Invalidation target to be used to check that the circuit fails when witnesses are invalid. |
Definition at line 278 of file test_class_predicate.hpp.
|
inlinestatic |
Update the constraint and the witness based on the predicate.
| constraint | |
| witness_values | |
| mode | |
| forced_invalidation | If true, forces the witness to be invalidated even if the predicate is not witness false. Used to check that the circuit fails if the predicate is witness true and witnesses are invalid. |
Definition at line 111 of file test_class_predicate.hpp.