Skip to content

fix: minor bigfield fixes - take 2#22415

Merged
suyash67 merged 6 commits intomerge-train/barretenbergfrom
sb/bigfield-fixes-2
Apr 8, 2026
Merged

fix: minor bigfield fixes - take 2#22415
suyash67 merged 6 commits intomerge-train/barretenbergfrom
sb/bigfield-fixes-2

Conversation

@suyash67
Copy link
Copy Markdown
Contributor

@suyash67 suyash67 commented Apr 8, 2026

List of fixes (none of them should change circuits):

  • Adds a missing reconstruction constraint in decompose_non_native_field_double_width_limb to ensure the reconstructed value matches the original input.
  • Asserts r_lo is nonzero in validate_split_in_field_unsafe, closing a soundness gap where a zero low limb could pass unchecked.
  • Removes unreachable dead code in the carry bit computation path.
  • Changes batch_mul default to with_edgecases=true to avoid incorrect results on edge-case inputs.
  • Adds boundary tests for the byte array constructor.

resolves https://github.com/AztecProtocol/barretenberg-claude/issues/2433

suyash67 added 6 commits April 8, 2026 12:10
batch_mul's default with_edgecases=false caused an unsatisfiable circuit
(DoS) when input points are linearly dependent. Callers that previously
relied on the safe default were unintentionally unsafe.

Change the default to true so the public API is safe by default. Callers
with provably non-colliding points (single-point scalar_mul, KZG verifier,
ECDSA with generator-equality guard) are updated to pass with_edgecases=false
explicitly.

AztecProtocol/barretenberg-claude#2238
If the low lo_bits of field_modulus are all zero, the borrow logic has
two bugs: `r_lo - 1` underflows in uint256_t arithmetic (wrong prover
hint, completeness), and `r_lo - fr(1)` wraps to a large field element
(lo_diff constraint checks the wrong thing, soundness). All standard
moduli (bn254 Fr/Fq, secp256k1 Fq) satisfy r_lo != 0, so the assertion
has no impact in practice.

Fixes AztecProtocol/barretenberg-claude#714
…ield_double_width_limb

Move the `low + hi * 2^NUM_LIMB_BITS == original` circuit constraint
into the function itself rather than relying on each caller to add it.
Remove the now-redundant evaluate_linear_identity calls at the two
callsites in the bigfield constructor.

Fixes AztecProtocol/barretenberg-claude#2222
@suyash67 suyash67 requested a review from iakovenkos April 8, 2026 14:51
Copy link
Copy Markdown
Contributor

@iakovenkos iakovenkos left a comment

Choose a reason for hiding this comment

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

thanks for these fixes!

@suyash67 suyash67 merged commit 564da2b into merge-train/barretenberg Apr 8, 2026
14 checks passed
@suyash67 suyash67 deleted the sb/bigfield-fixes-2 branch April 8, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants