Skip to content

Conversation

@notnotraju
Copy link
Contributor

@notnotraju notnotraju commented Nov 27, 2025

🧾 Audit Context

Part of the (generalized) permutation audit.

🛠️ Changes Made

  • Moved around/improved testing
  • Added documentation

✅ Checklist

  • Audited all methods of the relevant module/class
  • Audited the interface of the module/class with other (relevant) components
  • Documented existing functionality and any changes made (as per Doxygen requirements)
  • Resolved and/or closed all issues/TODOs pertaining to the audited files
  • Confirmed and documented any security or other issues found (if applicable)
  • Verified that tests cover all critical paths (and added tests if necessary)
  • Updated audit tracking for the files audited (check the start of each file you audited)

📌 Notes for Reviewers

The diff misleadingly large because some tests were migrated and some boilerplate changed.

@notnotraju notnotraju added ci-full Run all master checks. bberg-int-audit All things related to barretenberg internal audit ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure labels Nov 27, 2025
void set_tau_at_index(const uint32_t tag_index, const uint32_t tau_index)
{
this->_tau.insert({ tag_index, tau_index });
this->current_tag++; // Why exactly?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary, as long as we only access tags by the get_new_tag() method.

* @param tag_index_2
* @return uint32_t
*/
void set_tau_transposition(const uint32_t tag_index_1, const uint32_t tag_index_2)
Copy link
Contributor Author

@notnotraju notnotraju Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our $\tau$ is the product of disjoint transpositions (i.e., has order 1 or 2), hence this is universally what is used.

* circuit fails.
*
*/
TEST_F(ComposerLibTests, TagCollisionFailure)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test might not belong here, the "composer" directory seems deprecated, we might want to refactor and move stuff elsewhere for clarity. still, for the time being, worth testing the code in the directory in the same directory.

* @param tau_index
* @return uint32_t
*/
void set_tau_at_index(const uint32_t tag_index, const uint32_t tau_index)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_tag is a bit misleading, what this does is set the $\tau(i)=j$.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is about half old tests, slightly rewritten.

* @note There are no tags/multiset-equality checks in this test.
* @note We exclude ZK flavors because we manually tamper with precomputed polynomials.
*/
TYPED_TEST(PermutationNonZKTests, SigmaCorruptionFailure)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new in this PR

*
* @note We exclude ZK flavors because we manually tamper with relation parameters.
*/
TYPED_TEST(PermutationNonZKTests, PublicInputDeltaMismatch)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new in this PR


namespace bb {

// TODO(luke): This contains utilities for grand product computation and is not specific to the permutation grand
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

* @brief The permutation on variable tags
* @details See https://github.com/AztecProtocol/plonk-with-lookups-private/blob/new-stuff/GenPermuations.pdf
* @brief The permutation on variable tags, as a constituent of the generalized permutation argument.
* @details See S6 of https://github.com/AztecProtocol/plonk-with-lookups-private/blob/new-stuff/GenPermuations.pdf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link doesn't exist, not sure where we should permalink this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(plookup paper doesn't have the relevant S6)

@notnotraju notnotraju marked this pull request as ready for review December 3, 2025 11:41
* the multiset of values with second_tag (after applying tau). Here both multisets are {x, y},
* so the check passes.
*/
TYPED_TEST(PermutationTests, NonTrivialTagPermutation)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old test

* The test verifies that both mechanisms can coexist: the grand product argument must account for
* both the wire permutation cycles AND the tag-based multiset equality check.
*/
TYPED_TEST(PermutationTests, NonTrivialGeneralizedPerm)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old test

* The second sub-test creates the same circuit WITHOUT tags to confirm that the circuit's
* arithmetic constraints are satisfied, proving the failure above is due to multiset-equality mismatch.
*/
TYPED_TEST(PermutationTests, BadTagPermutation)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old test

* @note This test does not use `prove_and_verify`. Indeed, there is no straightforward way to tamper with z_perm,
* created after finalization, using `prove_and_verify`.
*/
TYPED_TEST(PermutationNonZKTests, ZPermZeroedOutFailure)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old test (earlier part of this audit)

* @note This test excludes ZK flavors because we manually tamper with z_perm, which would
* conflict with the ZK masking applied to witness polynomials.
*/
TYPED_TEST(PermutationNonZKTests, ZPermShiftNotZeroAtLagrangeLastFailure)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old test (earlier part of this audit)

Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

* real_variable_index[index] == index, i.e. it is the identity map
* real_variable_index[index] == index, i.e., it is the identity map.
*
* @note If there is a copy constraint between witness indices idx_a and idx_b, then their they will both point to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @note If there is a copy constraint between witness indices idx_a and idx_b, then their they will both point to
* @note If there is a copy constraint between witness indices idx_a and idx_b, then they will both point to

* of space within the wire polynomials, regardless of how many actual constraints of each type exist. This is
* useful primarily for folding since it guarantees that the set of relations that must be executed at each row is
* consistent across all folding steps.
* @note By default, this method constructs an exectution trace that is sorted by gate type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @note By default, this method constructs an exectution trace that is sorted by gate type.
* @note By default, this method constructs an execution trace that is sorted by gate type.

* where ∏ := ∏_{j=0:i-1}
*
* The specific algebraic relation used by Z_perm is defined by Flavor::GrandProductRelations
* (Note that Z_perm[1] may be thought of as the quotient of the empty product by the empty product, and hence setting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfinished thought?

* optimization having to do with public inputs.)
*
* For example, in Flavor::Standard the relation describes:
* The following is the classic, no-public-inputs PLONK permutation argument on 4 wires. This bears witness to the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little bit misleading since this indeed the method we use to compute z_perm for the fully general case (public inputs + generalized perms), not just trad copy constraints. Maybe with this comment you're interpreting \simga and id as the unadulterated entities that only account for copy constraints rather than the sigma and id polynomials which account for everything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bberg-int-audit All things related to barretenberg internal audit ci-full Run all master checks. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants