zorch.lnp.eval¶
Π_eval — statements over Z_q, as constant coefficients over R_q.
The LNP framework's two evaluation protocols (eprint 2022/284): Fig. 5,
which aggregates linear functions of the committed (s1, m), and
Fig. 8, which aggregates quadratic ones over the σ-lift and carries a
batch of ring-valued relations alongside. They share this file because
they share the step that defines them — GarbageMasking below — and
differ only in what is aggregated and which protocol proves the aggregate
well-formed: opening.py's Π_many for the first, quadratic.py's
Π_many^(2) for the second.
The bulk of what follows describes Fig. 5; AbdlopQuadraticEval at the
bottom describes where Fig. 8 departs from it.
The second protocol layer of the LNP framework (Fig. 5).
Π_many (opening.py) proves that a linear function of the committed
(s1, m) is zero as a ring element; this layer proves the strictly
weaker — and, for inner products, the interesting — statement that its
constant coefficient is zero. That is what turns a statement over
R_q into one over Z_q: §2.3's identity puts the inner product of two
integer vectors in the constant coefficient of a polynomial product, so
"this linear function over Z_q vanishes" is exactly "this constant
coefficient vanishes".
The obstacle is that revealing a linear function's constant coefficient must not reveal the rest of it, so the protocol masks:
- The prover draws garbage
g = (g_1..g_λ), uniform overR_qexcept for a zero constant coefficient, and commits it alongside the message under its own public matrixB_g:t_g = B_g·s2 + g. The BDLOP half's message becomesm‖g. - The verifier answers with
γ ∈ Z_q^{λ×M}— λ independent random aggregations of the M statements. - The prover sends
h_j = g_j + Σ_u γ_{j,u}·F_u(s1, m)in the clear.g_jhides every coefficient of the aggregate except the constant one, whichg_jleaves alone. - The verifier checks
h̃_j = 0for every j, and that theh_jreally were computed from the committed values — which is a linear relation over(s1, m‖g), so Π_many proves it (eq. 28):f_j(s1, m‖g) := g_j + Σ_u γ_{j,u}·F_u(s1, m) − h_j = 0.
Soundness is q1^{-λ} where q1 is the smallest prime factor of q:
g is committed before γ arrives, so if some F̃_u ≠ 0 then each h̃_j
is a fresh random aggregation and vanishes with probability at most
1/q1. The smallest factor, not q itself, is what bounds it — a
nonzero element of a composite Z_q can still be killed by a zero
divisor.
Commit-and-prove, not zero-knowledge over a reusable commitment. §3.2
is explicit that appending g means (t_A, t_B) cannot be reused: each
run leaks more about s2. The seam reflects that — the caller passes the
commitment in per proof and must not run two proofs against one.
Statement shape. The M linear functions arrive the way Π_many's do, as
matrix rows plus a target: F_u(s1, m) = Fs1_u·s1 + Fm_u·m − target_u.
The claim proved is F̃_u(s1, m) = 0 for every u — not F_u = 0, which
is what the layer below is for.
GarbageMasking ¶
The ENS20 garbage-and-aggregate step, and the transcript labels it hashes under — what Fig. 5 and Fig. 8 share.
Both protocols prove that functions of the committed witness have a
vanishing constant coefficient, and both do it the same way: commit
λ garbage polynomials that are themselves constant-coefficient-free,
take Γ ∈ Z_q^{λ×M} from the verifier, and reveal the λ aggregates in
the clear for the h̃_j = 0 check. What differs is only what is
aggregated — linear functions of (s1, m) in Fig. 5, quadratic ones
over the σ-lift in Fig. 8 — and that half stays with the caller.
Extracted for the reason masking.py was: the two protocols do not
merely resemble each other here, they must agree, and a second spelling
of one derivation is a fork no single-protocol suite can see.
domain separates the two transcripts, so it is a constructor argument
rather than a module constant: deriving Γ from the same absorbed
bytes under the same label in two protocols is what would let a proof
of one be replayed against the other.
Source code in zorch/lnp/eval.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 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 | |
commit ¶
commit(
bg: np.ndarray,
s2_ring: np.ndarray,
rng: np.random.Generator,
) -> tuple[np.ndarray, np.ndarray]
Draw the λ garbage terms and commit them: (g, t_g = B_g·s2 + g).
The line that actually defines the extension, and therefore the
one that had least business being spelled once per protocol. bg
is gated here for the same reason — it was the only public matrix
in this package with no shape gate, so a wrong row count surfaced
from a ring matvec instead of naming itself.
Source code in zorch/lnp/eval.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
blocks ¶
blocks(b: np.ndarray, bg: np.ndarray) -> np.ndarray
The BDLOP matrix the inner protocol opens m‖g against.
Source code in zorch/lnp/eval.py
148 149 150 | |
commitment ¶
commitment(t_b: np.ndarray, t_g: np.ndarray) -> np.ndarray
The commitment to m‖g, in the order blocks is stacked in.
Named beside blocks because the two are one ordering contract, and
a round-trip cannot see them disagree — both sides build them the
same way.
Source code in zorch/lnp/eval.py
152 153 154 155 156 157 158 | |
aggregate ¶
aggregate(gamma: np.ndarray, *blocks: np.ndarray) -> tuple
Σ_u γ_{j,u}·block_u for each row j of Γ, per block.
Γ's own contraction, so it belongs on the seam that owns Γ. Both
protocols aggregate — Fig. 5 over (Fs1, Fm, target), Fig. 8 over
(e2, e1, e0) — and each block keeps whatever it holds past the
contracted axis, so one call serves a stack of elements and a stack
of whole matrices alike.
Returns block-major stacks, the shape both callers ultimately index against; the per-row form one of them used to return had to be transposed back before it could be used.
Source code in zorch/lnp/eval.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
sample ¶
sample(rng: np.random.Generator) -> np.ndarray
g ← {x ∈ R_q : x̃ = 0}^λ — the ring's uniform stack with the
constant coefficient forced to zero. Private coins: this is masking,
like the Gaussian y of the layer below, so it comes off the
caller's generator and never off the transcript.
The zeroing is the protocol's own — uniform_stack is the module
convention's uniform constructor, and x̃ = 0 is the condition on
the garbage, not a ring-level shape.
Source code in zorch/lnp/eval.py
177 178 179 180 181 182 183 184 185 186 187 188 | |
gamma ¶
gamma(
transcript: ByteTranscript,
t_g: np.ndarray,
relations: int,
) -> tuple[ByteTranscript, np.ndarray]
Absorb the garbage commitment and squeeze Γ ∈ Z_q^{λ×M} — the
one derivation both sides replay.
Source code in zorch/lnp/eval.py
190 191 192 193 194 195 196 197 198 199 | |
observe ¶
observe(
transcript: ByteTranscript, h: np.ndarray
) -> ByteTranscript
Bind the revealed aggregates, which every later challenge in the proof is drawn after.
Source code in zorch/lnp/eval.py
201 202 203 204 | |
vanishes ¶
vanishes(h: np.ndarray) -> bool
The h̃_j = 0 check, over every limb at once.
Zero mod each q_i is zero mod q by CRT, so the ring's own
constant-coefficient reading answers it directly.
Source code in zorch/lnp/eval.py
206 207 208 209 210 211 | |
EvalProof
dataclass
¶
The Π_eval wire: the garbage commitment, the masked aggregates, and
the Π_many proof underneath. γ is absent — it is Fiat-Shamir output,
and the verifier re-derives it from t_g.
Source code in zorch/lnp/eval.py
214 215 216 217 218 219 220 221 222 | |
AbdlopEval ¶
Π_eval prove/verify over an AbdlopOpening (Fig. 5).
The opening it wraps must already be built over the extended
scheme: its BDLOP half carries ℓ + λ messages, because m‖g is what
the inner Π_many opens. ell is derived from that rather than taken,
so the two counts cannot disagree.
lam (λ) is the soundness parameter — the proof costs λ garbage
commitments and λ masked aggregates, and buys soundness q1^{-λ}.
Choosing it against the target security level is the consumer's
parameter work, like every other number this package's seams take.
Source code in zorch/lnp/eval.py
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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
prove ¶
prove(
a1: np.ndarray,
a2: np.ndarray,
b: np.ndarray,
bg: np.ndarray,
fs1: np.ndarray,
fm: np.ndarray,
target: np.ndarray,
s1: np.ndarray,
s2: np.ndarray,
message: np.ndarray,
rng: np.random.Generator,
transcript: ByteTranscript,
) -> tuple[EvalProof, ByteTranscript]
One non-interactive proof that every F̃_u(s1, m) is zero.
s1/s2 are signed integer (m_i, d) arrays as in opening.py;
message is the ring stack m that commit was called with. The
commitment is absent for the same reason it is absent there — the
transcript arrived bound to it.
Source code in zorch/lnp/eval.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
verify ¶
verify(
a1: np.ndarray,
a2: np.ndarray,
b: np.ndarray,
bg: np.ndarray,
fs1: np.ndarray,
fm: np.ndarray,
target: np.ndarray,
t_a: np.ndarray,
t_b: np.ndarray,
proof: EvalProof,
transcript: ByteTranscript,
) -> tuple[bool, ByteTranscript]
Fig. 5's two checks: every h_j has a zero constant coefficient,
and the Π_many proof of the aggregation relation verifies.
Source code in zorch/lnp/eval.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
QuadraticEvalProof
dataclass
¶
The Π_eval^(2) wire: the garbage commitment, the revealed
aggregates, and the Π_many^(2) proof underneath. Γ is absent for the
reason γ is absent above — it is Fiat-Shamir output, and the verifier
re-derives it from t_g.
Source code in zorch/lnp/eval.py
419 420 421 422 423 424 425 426 427 428 | |
AbdlopQuadraticEval ¶
Π_eval^(2) prove/verify over an AbdlopQuadraticMany (Fig. 8).
AbdlopEval above proves that linear functions of (s1, m) have a
vanishing constant coefficient. This proves the same of quadratic
functions of the σ-lift — which is the form every norm statement takes,
since ⟨s, s⟩ = ‖s‖² lives in the constant coefficient of
σ₋₁(s)ᵀ·s (§2.3) and is quadratic in the lift, not linear in m.
Two families arrive, both written against self.width, the lift of
(s1, m):
(r2, r1, r0)—Nrelations claimed zero as ring elements. They are carried through untouched (eq. 39);AbdlopQuadraticManyis what proves them, andN = 0is legal.(e2, e1, e0)—Mevaluations claimed to have a zero constant coefficient, the paper'sF_j. These are the reason to be here, soM ≥ 1.
The two are proved in one shot, against one commitment, because a consumer that ran Fig. 7 and Fig. 5 side by side would hold two parameter points for one witness and could not see them drift.
Why this is not AbdlopEval with a quadratic backend. The λ garbage
terms are appended to the message, so the inner protocol opens
m‖g — and lift orbits the message stack as a whole, which puts the
garbage in each automorphism copy rather than after the message's
copies. eq. 38 is written against exactly that layout and reads only
the first copy's g, so _embed is the map from the caller's width to
the inner one and is where the layout is owned.
Soundness is 2/|C| + q1^{-d/2} + q1^{-λ} (Thm 4.5), q1 the smallest
prime factor of q: the challenge term is Fig. 6's, the q1^{-d/2} is
Fig. 7's µ-aggregation, and q1^{-λ} is this layer's Γ. The middle
term is what a reader of Fig. 5 alone would not expect.
Commit-and-prove, not zero-knowledge over a reusable commitment —
§3.2, for the same reason as AbdlopEval: appending g means
(t_A, t_B) leaks more about s2 on every run. The caller passes the
commitment in per proof and must not run two proofs against one.
Source code in zorch/lnp/eval.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 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 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | |
prove ¶
prove(
a1: np.ndarray,
a2: np.ndarray,
b: np.ndarray,
bg: np.ndarray,
b_quad: np.ndarray,
r2: np.ndarray,
r1: np.ndarray,
r0: np.ndarray,
e2: np.ndarray,
e1: np.ndarray,
e0: np.ndarray,
s1: np.ndarray,
s2: np.ndarray,
message: np.ndarray,
rng: np.random.Generator,
transcript: ByteTranscript,
) -> tuple[QuadraticEvalProof, ByteTranscript]
One non-interactive proof that every f_j(s) is zero and every
F̃_j(s) is zero.
s1/s2 are signed integer (m_i, d) arrays as in opening.py;
message is the ring stack m that commit was called with —
without the garbage, which this layer appends itself. b_quad is
Fig. 6's b, distinct from both the BDLOP matrix b and bg.
Source code in zorch/lnp/eval.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
verify ¶
verify(
a1: np.ndarray,
a2: np.ndarray,
b: np.ndarray,
bg: np.ndarray,
b_quad: np.ndarray,
r2: np.ndarray,
r1: np.ndarray,
r0: np.ndarray,
e2: np.ndarray,
e1: np.ndarray,
e0: np.ndarray,
t_a: np.ndarray,
t_b: np.ndarray,
proof: QuadraticEvalProof,
transcript: ByteTranscript,
) -> tuple[bool, ByteTranscript]
Fig. 8's two checks: every h_i has a zero constant coefficient,
and the Π_many^(2) proof of the N + λ relations verifies.
Source code in zorch/lnp/eval.py
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 | |
require_witness ¶
require_witness(
name: str, s1: np.ndarray, s2: np.ndarray
) -> None
The witness gate of the masking this protocol ultimately proves
against, deferred down the chain the way _is_well_formed is.
Same reason: a layer above should not have to know that the masking
sits three constructors down, and the tunnel eval.many.quadratic
.masking would break on any re-parenting.
Source code in zorch/lnp/eval.py
623 624 625 626 627 628 629 630 | |