- TODO: Refactor batch ccSNARK into VECTIS
This is implementation of the VECTIS protocol
| Directory | Description |
|---|---|
src/ |
Contains the source code for the batch ccSNARK protocol |
┣crypto/ |
Contains the cryptographic primitives used in the protocol |
┃┣commitmemt/ |
Batch commitment scheme |
┃┃┣pedersen/ |
Pedersen commitment scheme |
┃┃┃┣constraints.rs |
Gadget for the Pedersen commitment |
┃┃┃┗mod.rs |
Implementation of the Pedersen commitment scheme |
┃┃┣constraints.rs |
Trait of the batch commitment gadget |
┃┃┗mod.rs |
Trait of the batch commitment scheme |
┣gro/ |
Implementation of the ccGrooth16 (LegoSNARK with Batch Commit) |
┣solidity/ |
Implementation of useful utils to format data |
- All public inputs must be challenges
The aggregation check ensures that each commitment was made correctly:
-
$b$ : denotes the total numbers of batches -
$n = \sum_{i}{n_i}$ where$n_i$ denotes the length of messages and openings of the$i$ -th batch -
$m = \sum_{i}{m_i}$ where$m_i$ denotes the size of the$i$ -th batch -
$M_i$ :$n_i \times m_i$ matrix (each row denotes the composition of a commitment)
-
$A$ : denotes the aggregation vector - Where
$\tau$ is a challenge which received from the verifier:
- Committing key is a vector of
$m$ group elements:
The product
If, there is no reason to separate the committing key, the matrix
In this context, the zeros (
Circuit
- All the aggregated values must be at the front of the committed witness
Prover
- Use
CCGroth16::<E>::committo commit the proof-dependent commitment - Use
Pedersen::<C>::batch_committo calculate the commitments - Use
Pedersen::<C>::challengeto retrieve the challenge for aggregation.
Verifier
- Use
Pedersen::<C>::challengeto retrieve the challenge for aggregation. - Use
Pedersen::<C>::aggregateto aggregate the commitments. - Update the proof-dependent commitment by adding the aggregation of the commitments.
// Aggregate inputs
let transposed = public_inputs.transpose();
let slices = cfg_iter!(transposed).map(|x| &x[..]).collect::<Vec<_>>();
let (aggregation_fr, initial) = Pedersen::<E::G1>::scalar_aggregate(&slices, tau, None);
// Aggregate commitments
let (aggregation_g1, _) = Pedersen::<C>::aggregate(&commitments, tau, Some(initial));
// Update proof dependent commitment
let aggregation = aggregation_g1 + vk.ck.batch_g1[0].into_group() * aggregation_fr[0];
proof.d = (proof.d.into_group() + aggregation).into_affine();