Commit 4b99bbf
committed
feat(halo2): session 85 — multi-column lookup argument support
Adds multi-column lookup-argument support to the Halo2 circuit
evaluator. Real Halo2 lookups support arity > 1 — a single lookup
constraint can pair `k` input columns against `k` table columns,
all checked simultaneously. The verifier collapses the `k`-arity
tuple into a single Fr via the θ challenge before applying the
log-derivative identity:
input_combined(ξ) = Σ_{i=0}^{k-1} θ^i · input_cols[i]
table_combined(ξ) = Σ_{i=0}^{k-1} θ^i · table_cols[i]
lookup(ξ) = m · (table_combined + θ^k)⁻¹ - (input_combined + θ^k)⁻¹
The outer additive blinder uses `θ^k` (one degree past the
linear-combination weights) to keep input_combined / table_combined
distinguishable from the blinder. For arity 1 this collapses to
the basic `lookup_expr` form, pinned by
`prop_multi_column_lookup_arity_1_matches_basic`.
mosaic-halo2/src/circuit.rs additions:
- `MultiColumnLookupEvals` — input_cols + table_cols (matched
arity) + multiplicity m. Empty + arity-mismatched cases
surface as `ProofLengthMismatch`.
- `multi_column_lookup_expr` — the θ-combined log-derivative
evaluator. Uses the shared `mosaic_zk_primitives::field::powers_of`
(session 72) for θ-powers and `fr_inner_product` (session 77)
for both input_combined / table_combined sums. Joins
`compute_kzg_opening_lhs`, `verify_two_pair_pairing`,
`msm_g1_fr` etc as production consumers of the shared primitives.
5 new tests (2 unit + 3 proptest, mosaic-halo2 lib total 75 → 80):
- `multi_column_lookup_rejects_empty` — empty cols → error.
- `multi_column_lookup_rejects_arity_mismatch` — input/table
length mismatch → error.
- `prop_multi_column_lookup_arity_1_matches_basic` —
**backward-compatibility soundness pin**: arity-1 multi-column
lookup is byte-identical to the basic `lookup_expr` over Fr.
- `prop_multi_column_lookup_zero_on_matching_arity_2` —
audit-grade soundness pin: when input_combined == table_combined
(every column pair matches at ξ) and m = 1, the expression
vanishes, contributing nothing to the vanishing identity.
- `prop_multi_column_lookup_distinguishes_columns` — θ-combination
is faithful: tampering any single column on the input side
surfaces as a non-zero contribution (probability ≈ 1 - 1/r).
Phase-3 audit caveat (preserved in rustdoc)
This is the structural multi-column reduction. Real Halo2 also
runs a sumcheck over the m polynomial (`Σ_X m(X) = 0`) to ensure
the multiplicities are valid; that piece stays in
`vanishing.rs::vanishing_identity_holds` as a scaffold caveat for
session 4f's full lookup soundness pin.
The basic `lookup_expr` and the existing `combined_expr` API are
unchanged — backward-compatible. Future PRs can promote callers
to multi-column when their circuit shape demands arity > 1.1 parent b77a3f2 commit 4b99bbf
1 file changed
Lines changed: 212 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
186 | 275 | | |
187 | 276 | | |
188 | 277 | | |
| |||
477 | 566 | | |
478 | 567 | | |
479 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
480 | 692 | | |
0 commit comments