Skip to content

zorch.sumcheck.stage

Sumcheck roles reducing a sum claim to an evaluation claim.

SumClaim dataclass

Public claim that a polynomial sums to value over a Boolean cube.

Source code in zorch/sumcheck/stage.py
20
21
22
23
24
25
@dataclass(frozen=True)
class SumClaim:
    """Public claim that a polynomial sums to ``value`` over a Boolean cube."""

    value: Array
    rounds: int

SumcheckWitness dataclass

Dense factor tables witnessing a SumClaim.

Source code in zorch/sumcheck/stage.py
28
29
30
31
32
@dataclass(frozen=True)
class SumcheckWitness:
    """Dense factor tables witnessing a ``SumClaim``."""

    state: Array

EvaluationClaim dataclass

Claim that the reduced polynomial evaluates to value at point.

Source code in zorch/sumcheck/stage.py
35
36
37
38
39
40
@dataclass(frozen=True)
class EvaluationClaim:
    """Claim that the reduced polynomial evaluates to ``value`` at ``point``."""

    point: Array
    value: Array

SumcheckProver

Bases: ProverStage[SumClaim, SumcheckWitness, EvaluationClaim, Array]

The prover role of dense sumcheck.

Source code in zorch/sumcheck/stage.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class SumcheckProver(ProverStage[SumClaim, SumcheckWitness, EvaluationClaim, Array]):
    """The prover role of dense sumcheck."""

    def __init__(self, prover_round: ProverRound[FoldingClaim, Array]) -> None:
        # No verifier round: the prover reduces its own claim through the same
        # `sumcheck.reduce` definition the verifier uses, so it needs the
        # arithmetic, not the other role.
        self.prover_round = prover_round

    def prove(
        self,
        claim: SumClaim,
        witness: SumcheckWitness,
        transcript: Transcript,
    ) -> ProveResult[EvaluationClaim, Array]:
        folded, transcript, messages = fold_rounds(
            self.prover_round,
            initial_claim(witness.state, claim.value, claim.rounds),
            transcript,
            claim.rounds,
        )
        reduced = folded.claim
        return ProveResult(
            EvaluationClaim(reduced.point, reduced.value),
            fnp.stack(messages),
            transcript,
        )

SumcheckVerifier

Bases: VerifierStage[SumClaim, EvaluationClaim, Array]

The verifier role of dense sumcheck.

Source code in zorch/sumcheck/stage.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class SumcheckVerifier(VerifierStage[SumClaim, EvaluationClaim, Array]):
    """The verifier role of dense sumcheck."""

    def __init__(self, verifier_round: VerifierRound[RunningClaim, Array]) -> None:
        self.verifier_round = verifier_round

    def verify(
        self,
        claim: SumClaim,
        reduction_proof: Array,
        transcript: Transcript,
    ) -> VerifyResult[EvaluationClaim]:
        if reduction_proof.shape[0] != claim.rounds:
            raise ValueError(
                f"expected {claim.rounds} sumcheck rounds, "
                f"got {reduction_proof.shape[0]}"
            )
        point, value, transcript, ok = verify(
            self.verifier_round, claim.value, reduction_proof, transcript
        )
        return VerifyResult(EvaluationClaim(point, value), transcript, ok)