Commit 632095c
authored
fix(port): validate AVM MSM points on zero scalar (forward-port onto next) (#24729)
Forward-port of the AVM MSM zero-scalar invalid-point fix onto `next`.
## Why this is needed
The fix landed on the **`v5`/`v5-next`** line (commit `7dc54f4c0cb`,
*"fix: validate msm points on 0 scalar, tests"*, MirandaWood) but was
**never forward-ported onto `next`**. Public `next`/`v6-next` still
carry the vulnerable code — `avm-transpiler/src/procedures/msm.rs` jumps
straight to `OUTER_INC` on a zero scalar, skipping point validation.
This is the public analogue of the same missed forward-port that
stranded the private-repo fix (see
AztecProtocol/aztec-packages-private#622).
## The change (cherry-pick of `7dc54f4c0cb`)
`avm-transpiler/src/procedures/msm.rs`: a zero-scalar MSM term used to
skip the ECADD loop where on-curve point validation happens, so an
off-curve point paired with a zero scalar was silently accepted
(returned infinity) instead of reverting. The fix adds a
`VALIDATE_ZERO_SCALAR_POINT` branch performing a dummy `P + O` ECADD,
forcing the on-curve check — matching native/Brillig `multi_scalar_mul`
semantics. Includes the `variable_base_msm_with_point` helper in
`avm_test_contract` and the `avm_msm_zero_scalar_invalid_point`
bb-prover proving test.
## Port adjustments
- **API drift fixed:** the ported test used
`AztecAddress.fromNumber(42)`, which does not exist on `next`; changed
to `fromNumberUnsafe(42)` to match every sibling `avm_proving_tests`
file (this is exactly what broke private #622's CI).
- **Dropped file:**
`yarn-project/simulator/src/public/avm/avm_simulator.test.ts` was
deleted on `next` (AVM simulator tests relocated). Its two *"reverts
off-curve points"* assertions are **not carried**; the bb-prover proving
test covers the zero-scalar off-curve case end-to-end. Re-homing those
assertions into next's relocated suite is a follow-up.
- **Possible snapshot regen:** adding `variable_base_msm_with_point` to
`avm_test_contract` may require regenerating its expanded snapshot on
`next`. The upstream `v5` commit didn't touch a snapshot; if next's
toolchain expands it differently the snapshot test will flag it and I'll
regenerate/babysit.
Draft until CI is green. `ci-no-fail-fast` applied so the full matrix
reports.
Refs AztecProtocol/aztec-packages-private#622
---
*Created by
[claudebox](https://claudebox.work/v2/sessions/3b80f12215e0c82d) ·
group: `slackbot`*3 files changed
Lines changed: 84 additions & 1 deletion
File tree
- avm-transpiler/src/procedures
- noir-projects/noir-contracts/contracts/test/avm_test_contract/src
- yarn-project/bb-prover/src/avm_proving_tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
227 | 244 | | |
228 | 245 | | |
229 | 246 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments