Skip to content

zorch.spartan.lincheck

Spartan claim batching and inner lincheck roles.

BatchedClaims dataclass

The RLC challenge and joint value derived between the two stages.

Source code in zorch/spartan/lincheck.py
28
29
30
31
32
33
@dataclass(frozen=True)
class BatchedClaims:
    """The RLC challenge and joint value derived between the two stages."""

    challenge: Array
    joint: Array

LincheckClaim dataclass

Public claim reduced by the inner linearization sumcheck.

Source code in zorch/spartan/lincheck.py
51
52
53
54
55
56
57
@dataclass(frozen=True)
class LincheckClaim:
    """Public claim reduced by the inner linearization sumcheck."""

    instance: R1CS
    row: RowEvaluationClaim
    batch: BatchedClaims

LincheckWitness dataclass

Private assignment witnessing a LincheckClaim.

Source code in zorch/spartan/lincheck.py
60
61
62
63
64
@dataclass(frozen=True)
class LincheckWitness:
    """Private assignment witnessing a ``LincheckClaim``."""

    assignment: Array

ColumnEvaluationClaim dataclass

Claimed matrix-times-assignment evaluation at the column point.

Source code in zorch/spartan/lincheck.py
67
68
69
70
71
72
@dataclass(frozen=True)
class ColumnEvaluationClaim:
    """Claimed matrix-times-assignment evaluation at the column point."""

    point: Array
    value: Array

InnerProof dataclass

The inner sumcheck reduction proof.

Source code in zorch/spartan/lincheck.py
75
76
77
78
79
@dataclass(frozen=True)
class InnerProof:
    """The inner sumcheck reduction proof."""

    sumcheck: Any

InnerProver

Bases: ProverStage[LincheckClaim, LincheckWitness, ColumnEvaluationClaim, InnerProof]

Prove lincheck conditional on a column-evaluation claim.

Source code in zorch/spartan/lincheck.py
 82
 83
 84
 85
 86
 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
class InnerProver(
    ProverStage[LincheckClaim, LincheckWitness, ColumnEvaluationClaim, InnerProof]
):
    """Prove lincheck conditional on a column-evaluation claim."""

    def __init__(
        self,
        *,
        sumcheck: (
            ProverStage[SumClaim, SumcheckWitness, EvaluationClaim, Any] | None
        ) = None,
        challenges: ChallengePolicy,
    ) -> None:
        self.sumcheck = sumcheck or SumcheckProver(
            StandardRound(ProductSummand(2), challenges=challenges),
        )

    def prove(
        self,
        claim: LincheckClaim,
        witness: LincheckWitness,
        transcript: Transcript,
    ) -> ProveResult[ColumnEvaluationClaim, InnerProof]:
        matrix = claim.instance.combined_row_mle(claim.row.point, claim.batch.challenge)
        state = fnp.stack([matrix, witness.assignment])
        reduced = self.sumcheck.prove(
            SumClaim(claim.batch.joint, claim.instance.s_y),
            SumcheckWitness(state),
            transcript,
        )
        return ProveResult(
            ColumnEvaluationClaim(
                reduced.reduced_claim.point, reduced.reduced_claim.value
            ),
            InnerProof(reduced.reduction_proof),
            reduced.transcript,
        )

InnerVerifier

Bases: VerifierStage[LincheckClaim, ColumnEvaluationClaim, InnerProof]

Verify lincheck conditional on a column-evaluation claim.

Source code in zorch/spartan/lincheck.py
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
class InnerVerifier(VerifierStage[LincheckClaim, ColumnEvaluationClaim, InnerProof]):
    """Verify lincheck conditional on a column-evaluation claim."""

    def __init__(
        self,
        *,
        sumcheck: VerifierStage[SumClaim, EvaluationClaim, Any] | None = None,
        challenges: ChallengePolicy,
    ) -> None:
        self.sumcheck = sumcheck or SumcheckVerifier(SumcheckRound(2, challenges))

    def verify(
        self,
        claim: LincheckClaim,
        reduction_proof: InnerProof,
        transcript: Transcript,
    ) -> VerifyResult[ColumnEvaluationClaim]:
        reduced = self.sumcheck.verify(
            SumClaim(claim.batch.joint, claim.instance.s_y),
            reduction_proof.sumcheck,
            transcript,
        )
        return VerifyResult(
            ColumnEvaluationClaim(
                reduced.reduced_claim.point, reduced.reduced_claim.value
            ),
            reduced.transcript,
            reduced.ok,
        )

batch_claims

batch_claims(
    claims: Array,
    transcript: Transcript,
    challenges: ChallengePolicy,
) -> tuple[BatchedClaims, Transcript]

Sample the batching challenge and derive the joint value.

Source code in zorch/spartan/lincheck.py
41
42
43
44
45
46
47
48
def batch_claims(
    claims: Array,
    transcript: Transcript,
    challenges: ChallengePolicy,
) -> tuple[BatchedClaims, Transcript]:
    """Sample the batching challenge and derive the joint value."""
    transcript, challenge = challenges.sample(transcript)
    return BatchedClaims(challenge, _joint_claim(claims, challenge)), transcript