Skip to content

Commit d2d0911

Browse files
committed
Merge branch 'next' of github.com:aztecprotocol/aztec-packages into next
2 parents 0a9d6e0 + 3786dd3 commit d2d0911

File tree

1,685 files changed

+27753
-27285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,685 files changed

+27753
-27285
lines changed

.github/workflows/ensure-funded-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ jobs:
103103
run: |
104104
# Fetch the environment-specific secrets
105105
FUNDING_PRIVATE_KEY=$(gcloud secrets versions access latest --secret="sepolia-funding-private-key" --project="$GCP_PROJECT_ID")
106+
echo "::add-mask::$FUNDING_PRIVATE_KEY"
106107
107108
# Export to environment
108109
echo "FUNDING_PRIVATE_KEY=$FUNDING_PRIVATE_KEY" >> $GITHUB_ENV
109110
110111
- name: Ensure funded environment
111112
env:
112-
FUNDING_PRIVATE_KEY: ${{ env.FUNDING_PRIVATE_KEY }}
113113
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
114114
NAMESPACE: ${{ inputs.namespace }}
115115
run: |

CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/barretenberg/cpp/src/barretenberg/vm @jeanmon @IlyasRidhuan @fcarreiro
2121
/barretenberg/cpp/src/barretenberg/vm2 @jeanmon @IlyasRidhuan @fcarreiro
2222
# on changes to public context in aztec-nr
23-
/noir-projects/aztec-nr/aztec/src/context/public_context.nr @fcarreiro @dbanks12
23+
/noir-projects/aztec-nr/aztec/src/context/public_context.nr @fcarreiro @dbanks12 @nventuro
2424
# on changes to the AVM simulator and supporting modules
2525
/yarn-project/simulator/src/public @fcarreiro @dbanks12 @sirasistant
2626
# on changes to the AVM transpiler
@@ -36,5 +36,8 @@
3636
# Notify the circuit team of changes to the protocol circuits
3737
/noir-projects/noir-protocol-circuits @LeilaWang
3838

39+
# Notify nventuro of changes to aztec-nr
40+
/noir-projects/aztec-nr @nventuro
41+
3942
# Notify devrel of changes to docs examples
4043
/docs/examples @AztecProtocol/devrel
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
name: stdlib-point-at-infinity
3+
description: Guidelines for handling point-at-infinity in stdlib circuit types. Use when working on serialization, public inputs, or cycle_group/biggroup code.
4+
---
5+
6+
# Stdlib Point-at-Infinity Handling
7+
8+
## Two stdlib element types for bn254
9+
10+
- **`element_default::element`** (Ultra arithmetization): Separate `_is_infinity` bool_ct flag. Coordinates can be arbitrary when infinity is set. Has `is_point_at_infinity()` returning `bool_ct`.
11+
- **`goblin_element`** (Mega arithmetization): Represents infinity as `(0,0)` by construction. No separate infinity flag. No `is_point_at_infinity()` method on the circuit type. ECCVM enforces the `(0,0)` convention.
12+
- The alias `element<Builder, Fq, Fr, G>` resolves to one or the other via `IsGoblinBigGroup`.
13+
- Both types have `get_value()` returning a native `affine_element` with `is_point_at_infinity()`.
14+
15+
## cycle_group (Grumpkin) infinity handling
16+
17+
`cycle_group` has `_is_infinity` bool computed from `x^2 + 5*y^2 == 0` (which has no non-trivial solutions in the field, since `p == 2 mod 5`). For `(0,0)` this gives `0 == 0`, so infinity is auto-detected.
18+
19+
**Non-canonical infinity**: `cycle_group` operations (`operator+`, `operator-`, `dbl`, `batch_mul`) can produce points at infinity with non-canonical coordinates (`_is_infinity=true` but `x,y != 0,0`). This happens because the arithmetic uses `conditional_assign` to avoid division by zero -- the "real" coordinates are garbage when the infinity flag is set.
20+
21+
**Observation boundaries**: Canonicalization to `(0,0)` is deferred to these boundaries:
22+
- `StdlibCodec::serialize_to_fields` -- canonicalizes `grumpkin_commitment` via `conditional_assign`
23+
- `cycle_group::set_public` -- canonicalizes before exposing as public inputs
24+
- `cycle_group::operator==` and `assert_equal` -- handles infinity comparison
25+
26+
## StdlibCodec::serialize_to_fields (field_conversion.hpp)
27+
28+
- **grumpkin_commitment**: Canonicalizes infinity to `(0,0)` via `conditional_assign`. This IS needed because the `IPA::accumulate` -> `full_verify_recursive` path computes `G_zero_1 + G_zero_2 * alpha` using `cycle_group` arithmetic, which can produce non-canonical infinity when a malicious prover sends both `G_zero` values as `(0,0)`.
29+
- **bn254_commitment**: Allows canonical `(0,0)` infinity; asserts (`BB_ASSERT`) that infinity points have zero coordinates. All existing code paths (public inputs, transcript) produce canonical `(0,0)` infinity, so the assert is a safety guard against misuse. No canonicalization is performed (unlike `grumpkin_commitment`), since there are no available code paths that produce non-canonical bn254 infinity.
30+
31+
## Analyzing whether canonicalization is needed
32+
33+
Trace whether the value comes from:
34+
35+
1. **Deserialization** (from public inputs via `reconstruct_from_public`, or from transcript via `receive_from_prover`): Coordinates are already canonical `(0,0)` for infinity. Canonicalization is a no-op.
36+
2. **cycle_group arithmetic** (`operator+`, `operator-`, `dbl`, `batch_mul`): Coordinates may be non-canonical when `_is_infinity` is true. Canonicalization IS needed.
37+
38+
Key production paths for grumpkin commitments through `serialize_to_fields`:
39+
- **IPA `add_claim_to_hash_buffer`** (verifier side): Commitment is deserialized from public inputs -> already canonical.
40+
- **IPA `accumulate` hashing of `G_zero`**: `G_zero` is deserialized from transcript -> already canonical.
41+
- **IPA `full_verify_recursive`**: Accumulated commitment is the result of cycle_group arithmetic (`G_zero_1 + G_zero_2 * alpha`) -> may be non-canonical if infinity -> canonicalization needed.
42+
- **VK hashing** (`flavor.hpp` `to_field_elements`/`hash_with_origin_tagging`): Commitments are deserialized from fields -> already canonical.
43+
44+
## Recursive verification and malicious provers
45+
46+
For recursive verifier circuits, the circuit must be **constructible** even with malicious witness values (it just won't be satisfiable). This means:
47+
- Do NOT use `BB_ASSERT` on values a malicious prover can control -- it would crash circuit construction.
48+
- Use `conditional_assign` canonicalization instead, which produces correct circuit constraints regardless of witness values.
49+
- `BB_ASSERT` is appropriate for invariants that hold across all existing code paths (e.g., `bn254_commitment` in `serialize_to_fields` asserts canonical `(0,0)` form for infinity, since all paths that can reach it produce canonical infinity).
50+
51+
## Common bug patterns to watch for
52+
53+
These patterns have caused repeated bugs across biggroup, cycle_group, ECCVM, AVM, and ECDSA:
54+
55+
### 1. Representation mismatch: internal sentinel vs `(0,0)`
56+
BB's native `affine_element` uses an internal sentinel for infinity (MSB set on the x coordinate's raw representation, not a valid field element). Noir, AVM, and the transcript convention use `(0,0)`. Any code that reads raw coordinates without checking `is_point_at_infinity()` (or without calling `get_standard_form()` on stdlib types) will see sentinel values, not `(0,0)`. Always use the standard-form convention `(0,0)` at component boundaries.
57+
58+
### 2. Forgetting to propagate the infinity flag through conditional operations
59+
When doing `conditional_assign` or `conditional_select` on points, both the coordinates AND the `_is_infinity` flag must be selected. Multiple ECDSA and biggroup bugs came from selecting x/y but leaving `_is_infinity` unchanged.
60+
61+
### 3. Incomplete addition formulas crash on infinity
62+
Performance-optimized ECC (chain_add, Montgomery ladder) assumes inputs are never infinity and never equal. When infinity appears as an intermediate value, these formulas divide by zero or produce wrong results. If a code path can encounter infinity mid-computation, use complete addition (`operator+`) instead of `chain_add_start`/`chain_add`/`chain_add_end`. This costs ~2% more gates but is correct.
63+
64+
### 4. Constructor and validation bypasses
65+
Constructors that accept a direct `is_infinity` flag can bypass on-curve validation (a point with `is_infinity=true` but `x,y != 0` passes `validate_on_curve` because the check is skipped for infinity). The 4-argument biggroup constructor with explicit infinity flag is now private. Prefer the 2-argument `(x, y)` constructor which auto-detects infinity from `x == 0 && y == 0`.
66+
67+
### 5. Forgetting to canonicalize before comparison or hashing
68+
`cycle_group::operator==` and `assert_equal` handle infinity correctly, but raw coordinate comparison does not. Before comparing or hashing point coordinates, ensure infinity points have canonical `(0,0)` coordinates. The observation boundary pattern (serialize_to_fields, set_public, operator==) exists for this reason.

barretenberg/cpp/cmake/module.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ function(barretenberg_module_with_sources MODULE_NAME)
111111
endif()
112112
list(APPEND lib_targets ${MODULE_NAME})
113113

114+
set(MODULE_LINK_NAME ${MODULE_NAME})
115+
elseif(MODULE_DEPENDENCIES AND NOT BENCH_SOURCE_FILES AND NOT FUZZERS_SOURCE_FILES)
116+
# Header-only module with dependencies: create an INTERFACE library
117+
# so dependents can still reference this module by name.
118+
add_library(${MODULE_NAME} INTERFACE)
119+
target_link_libraries(${MODULE_NAME} INTERFACE ${MODULE_DEPENDENCIES})
114120
set(MODULE_LINK_NAME ${MODULE_NAME})
115121
endif()
116122

barretenberg/cpp/cmake/threading.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ if(ENABLE_PAR_ALGOS)
3030
find_package(TBB QUIET OPTIONAL_COMPONENTS tbb)
3131
if(${TBB_FOUND})
3232
message(STATUS "std::execution parallel algorithms are enabled.")
33+
link_libraries(TBB::tbb)
3334
else()
3435
message(STATUS "Could not locate Intel TBB, disabling std::execution parallel algorithms.")
3536
add_definitions(-DNO_PAR_ALGOS)

barretenberg/cpp/pil/vm2/bitwise.pil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ sel * (1 - sel) = 0;
8585

8686
// No relations will be checked if this identity is satisfied.
8787
#[skippable_if]
88-
sel = 0;
88+
sel + last = 0;
8989

9090
pol commit start; // @boolean Identifies when we want to capture the output to the main trace.
9191
// Must be constrained as a boolean as any selector used in a lookup/permutation.

0 commit comments

Comments
 (0)