We add a BatchedRelaxedR1CSSNARKTrait
which generalizes the existing RelaxedR1CSSNARKTrait
in src/traits/snark.rs
. The main difference is that the setup
, prove
and verify
methods take as inputs slices of
S
U
W
We also implement a CompressedSNARK
proof for the SuperNova RecursiveSNARK
. The main differences with the original are
BatchedRelaxedR1CSSNARK
.In src/spartan
, we implement batched versions of snark.rs
and pp_snark.rs
in batched.rs
and batched_ppsnark.rs
.
The BatchedRelaxedR1CSSNARK
structs in both cases resemble their non-batched counter-parts, except that fields containing commitments or evaluations are replaced with vectors of the same elements. The Sumcheck and PCS proofs are batched so their count remains constant with regards to the number of instances.
The proving/verification keys are also mainly the same, apart from having to store parameters for each individual circuit being proved.
The implementation attempts to mirror the existing SNARK and pp-SNARK as much as possible.
In the "IOP" portion of the protocol, where the prover sends commitments to polynomials or evaluations thereof, and the verifier responds with challenges, we simply repeat this step for each instance. The prover messages are added to the transcript in batches, and stored in the proof as vectors.
The Sumcheck claims are set up slightly differently to account for circuits of different sizes. In particular, when a claim of size EqPolynomials
for each instance. Given a single random challenge EqPolynomial
for a claim over
Since the original SNARKs already implement batching of MLE evaluations, we are able to reuse the code to batch all polynomials across the several instances. We explain the subtleties of the batching argument for the ppSNARK in a later section.
Multiple Sumcheck claims can be batched together by running the protocol over a random-linear combination of the input claims. The existing implementation of ppSNARK already includes this functionality, though we augmented it to handle instances defined over fewer variables.
A Sumcheck instance implements the SumcheckEngine
trait. It may be composed of multiple independent claims of the type
where
In rounds
The prover sends the random linear combination of all univariate polynomials
After the
We can use the same Sumcheck instantiation to batch instances of different sizes.
Let
where
We can prove this claim with
Here, we "lift" the
In rounds
Given the initial claim
Moreover, binding the polynomials
Once the prover reaches rounds
In order to minimize the amount of changes to the existing ppsnark.rs
code, we implemented the above technique by recreating a prove_helper
method which handles batching of multiple instances of different sizes. Our changes are compatible with the existing Instances implementing the SumcheckEngine
trait.
The prove_helper
function takes as input multiple SumcheckEngine
implementations, each of which contains one or more independent claims. These claims hold over multilinear polynomials of the same size contained in the instance struct. It is assumed that all instances have degree 3. We let
Let
For each instance at index
At the start of the protocol, the verifier sends a challenge
The SumcheckProof::verify_batch
algorithm only considers the flattened list of claims
If the verifier accepts the final check, it must then check that all polynomial evaluations are correct.
Note that this batching technique implemented in the ppSNARK's prove_helper
method was also ported to the prove_quad_batch
and prove_cubic_with_additive_term_batch
methods of spartan::sumcheck::SumcheckProof
.
At the start of the protocol, the prover will have compute commitments to polynomials
We assume the PCS supports opening multilinear polynomials over
We commit to this polynomial by computing the MSM with the commitment key base points
If a polynomial is defined over
This interpretation allows us to compute the MSM using only
Effectively, we have committed to the polynomial
During Sumcheck though, for polynomial defined over
In order to open
For each evaluation
In the non-pre-processing SNARK, the verifier needs to verify the evaluations of multiple multi-linear polynomials at various points defined by the inner and outer Sumcheck instances. Unfortunately, the polynomial commitment schemes only support batching of evaluations for polynomials opened at the same point.
Since the creation of the opening argument is expensive, the original implementation uses a specialized Sumcheck argument to reduce each evaluation to an evaluation at a common point. All of these can be batched via random linear combination so that only a single PCS opening argument needs to be created.
Let
For each evaluation instance
The protocol proceeds as described in [[Compressed SNARK#Batched Sumcheck]], where all claims are appropriately scaled to
The output is a query point
The methods batch_eval_prove
and
batch_eval_verify
represent sub-protocols that reduce the task of checking the validity
In the pre-processing SNARK, the Sumcheck claims of each RelaxedR1CS instance are padded to
The public input
The prover provides a commitment to
The evaluation of MaskedEqPolynomial
.
This polynomial can be succinctly evaluated by noting that it is equal to
The Sumcheck instance we end up proving is
By definition of
We include this check as a separate SumcheckEngine
implementation, defined in spartan::batched_ppsnark::WitnessBoundSumcheck
. The constructor takes as input a random element
One of the benefits of including this new instance is that the Sumcheck prover will have computed the multi-linear evaluation of