spark-based commitments to R1CS matrices (#152)

* spark-based commitments to R1CS matrices

* small fixes
This commit is contained in:
Srinath Setty
2023-03-20 18:16:06 -07:00
committed by GitHub
parent eb97499907
commit 7b1bb44e45
20 changed files with 1758 additions and 98 deletions

View File

@@ -46,8 +46,7 @@ mod tests {
// First create the shape
let mut cs: ShapeCS<G> = ShapeCS::new();
let _ = synthesize_alloc_bit(&mut cs);
let shape = cs.r1cs_shape();
let ck = cs.commitment_key();
let (shape, ck) = cs.r1cs_shape();
// Now get the assignment
let mut cs: SatisfyingAssignment<G> = SatisfyingAssignment::new();

View File

@@ -22,12 +22,10 @@ pub trait NovaWitness<G: Group> {
) -> Result<(R1CSInstance<G>, R1CSWitness<G>), NovaError>;
}
/// `NovaShape` provides methods for acquiring `R1CSShape` and `R1CSGens` from implementers.
/// `NovaShape` provides methods for acquiring `R1CSShape` and `CommitmentKey` from implementers.
pub trait NovaShape<G: Group> {
/// Return an appropriate `R1CSShape` struct.
fn r1cs_shape(&self) -> R1CSShape<G>;
/// Return an appropriate `CommitmentKey` struct.
fn commitment_key(&self) -> CommitmentKey<G>;
/// Return an appropriate `R1CSShape` and `CommitmentKey` structs.
fn r1cs_shape(&self) -> (R1CSShape<G>, CommitmentKey<G>);
}
impl<G: Group> NovaWitness<G> for SatisfyingAssignment<G>
@@ -54,7 +52,7 @@ impl<G: Group> NovaShape<G> for ShapeCS<G>
where
G::Scalar: PrimeField,
{
fn r1cs_shape(&self) -> R1CSShape<G> {
fn r1cs_shape(&self) -> (R1CSShape<G>, CommitmentKey<G>) {
let mut A: Vec<(usize, usize, G::Scalar)> = Vec::new();
let mut B: Vec<(usize, usize, G::Scalar)> = Vec::new();
let mut C: Vec<(usize, usize, G::Scalar)> = Vec::new();
@@ -84,11 +82,9 @@ where
res.unwrap()
};
S
}
let ck = R1CS::<G>::commitment_key(&S);
fn commitment_key(&self) -> CommitmentKey<G> {
R1CS::<G>::commitment_key(self.num_constraints(), self.num_aux())
(S, ck)
}
}