Skip to content

chore: universal handling for coord constancy in cycle_group#18253

Merged
ledwards2225 merged 3 commits intomerge-train/barretenbergfrom
lde/coord-constancy
Nov 7, 2025
Merged

chore: universal handling for coord constancy in cycle_group#18253
ledwards2225 merged 3 commits intomerge-train/barretenbergfrom
lde/coord-constancy

Conversation

@ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented Nov 6, 2025

Its been noted in a few locations that use of field_t::conditional_assign with a non-constant predicate on the individual coordinates of a cycle_group element prior to construction can result in mixed constancy. E.g. if trying to conditionally assign between two points whose coordinates are constant but agree in only one or the other coordinate. In this case the coordinate that agrees will produce a constant, while the two that disagree will produce a witness. To avoid the need to handle this in disparate locations, we opt to handle it once and for all at the single interface for cycle_group. In particular, if we encounter mixed constancy, we convert the constant coordinate to a fixed witness.

Closes #17514

_is_standard_res = predicate.get_value() ? lhs._is_standard : rhs._is_standard;
}

// AUDITTODO: Talk to Sasha. Comment seems to be unrelated and its not clear why the logic is needed.
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 AUDITTODO was outdated - this is exactly handling the case in question that is now solved by the constructor updates

@ledwards2225 ledwards2225 marked this pull request as ready for review November 6, 2025 18:55
Copy link
Contributor

@federicobarbacovi federicobarbacovi left a comment

Choose a reason for hiding this comment

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

LG!

// For the simplicity of methods in this class, we ensure that the coordinates of a point always have the same
// constancy. If they don't, we convert the non-constant coordinate to a fixed witness.
if (_x.is_constant() != _y.is_constant()) {
info("Warning: cycle_group constructed with inconsistent coordinate constancy - converting to fixed witness");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this warning. If cycle_group does not handle mixed 'constancy', then it's his problem and it should not warn about it because it has a workaround.
This makes the blackbox interface in Noir cleaner and removes complexity by not having to take care of constant/witness inputs to the blackbox. Furthermore, 'DSL' can introduce this inconsistency by itself and getting such warning depending on the inputs looks strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair! removed

Removed warning message for inconsistent coordinate constancy in cycle_group.
@ledwards2225 ledwards2225 added the ci-full Run all master checks. label Nov 7, 2025
@ledwards2225 ledwards2225 merged commit 666f170 into merge-train/barretenberg Nov 7, 2025
12 of 13 checks passed
@ledwards2225 ledwards2225 deleted the lde/coord-constancy branch November 7, 2025 18:48
github-merge-queue bot pushed a commit that referenced this pull request Nov 7, 2025
BEGIN_COMMIT_OVERRIDE
chore: remove more pg references and leftovers (#18260)
refactor: Migrate --update_inputs flag to --vk_policy option (#18237)
chore: stdlib byte_array and bool external audit fixes (#17838)
chore: update naming in bb_proof_verification lib (#18269)
chore: cycle group 13 (#18200)
chore: universal handling for coord constancy in cycle_group (#18253)
END_COMMIT_OVERRIDE
ludamad pushed a commit that referenced this pull request Dec 16, 2025
Its been noted in a few locations that use of
field_t::conditional_assign with a non-constant predicate on the
individual coordinates of a cycle_group element prior to construction
can result in mixed constancy. E.g. if trying to conditionally assign
between two points whose coordinates are constant but agree in only one
or the other coordinate. In this case the coordinate that agrees will
produce a constant, while the two that disagree will produce a witness.
To avoid the need to handle this in disparate locations, we opt to
handle it once and for all at the single interface for cycle_group. In
particular, if we encounter mixed constancy, we convert the constant
coordinate to a fixed witness.

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

Labels

ci-full Run all master checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants