mirror of
https://github.com/arnaucube/Nova.git
synced 2026-01-19 04:11:31 +01:00
Separate prover and verifier keys in CompressedSNARK (#145)
* checkpoint * simplify further * checkpoint * gens --> ck * update benches * address clippy * cleanup * update version
This commit is contained in:
@@ -47,14 +47,14 @@ mod tests {
|
||||
let mut cs: ShapeCS<G> = ShapeCS::new();
|
||||
let _ = synthesize_alloc_bit(&mut cs);
|
||||
let shape = cs.r1cs_shape();
|
||||
let gens = cs.r1cs_gens();
|
||||
let ck = cs.commitment_key();
|
||||
|
||||
// Now get the assignment
|
||||
let mut cs: SatisfyingAssignment<G> = SatisfyingAssignment::new();
|
||||
let _ = synthesize_alloc_bit(&mut cs);
|
||||
let (inst, witness) = cs.r1cs_instance_and_witness(&shape, &gens).unwrap();
|
||||
let (inst, witness) = cs.r1cs_instance_and_witness(&shape, &ck).unwrap();
|
||||
|
||||
// Make sure that this is satisfiable
|
||||
assert!(shape.is_sat(&gens, &inst, &witness).is_ok());
|
||||
assert!(shape.is_sat(&ck, &inst, &witness).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,23 +3,22 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use super::{shape_cs::ShapeCS, solver::SatisfyingAssignment};
|
||||
use bellperson::{Index, LinearCombination};
|
||||
|
||||
use ff::PrimeField;
|
||||
|
||||
use crate::{
|
||||
errors::NovaError,
|
||||
r1cs::{R1CSGens, R1CSInstance, R1CSShape, R1CSWitness},
|
||||
r1cs::{R1CSInstance, R1CSShape, R1CSWitness, R1CS},
|
||||
traits::Group,
|
||||
CommitmentKey,
|
||||
};
|
||||
use bellperson::{Index, LinearCombination};
|
||||
use ff::PrimeField;
|
||||
|
||||
/// `NovaWitness` provide a method for acquiring an `R1CSInstance` and `R1CSWitness` from implementers.
|
||||
pub trait NovaWitness<G: Group> {
|
||||
/// Return an instance and witness, given a shape and gens.
|
||||
/// Return an instance and witness, given a shape and ck.
|
||||
fn r1cs_instance_and_witness(
|
||||
&self,
|
||||
shape: &R1CSShape<G>,
|
||||
gens: &R1CSGens<G>,
|
||||
ck: &CommitmentKey<G>,
|
||||
) -> Result<(R1CSInstance<G>, R1CSWitness<G>), NovaError>;
|
||||
}
|
||||
|
||||
@@ -27,8 +26,8 @@ pub trait NovaWitness<G: Group> {
|
||||
pub trait NovaShape<G: Group> {
|
||||
/// Return an appropriate `R1CSShape` struct.
|
||||
fn r1cs_shape(&self) -> R1CSShape<G>;
|
||||
/// Return an appropriate `R1CSGens` struct.
|
||||
fn r1cs_gens(&self) -> R1CSGens<G>;
|
||||
/// Return an appropriate `CommitmentKey` struct.
|
||||
fn commitment_key(&self) -> CommitmentKey<G>;
|
||||
}
|
||||
|
||||
impl<G: Group> NovaWitness<G> for SatisfyingAssignment<G>
|
||||
@@ -38,12 +37,12 @@ where
|
||||
fn r1cs_instance_and_witness(
|
||||
&self,
|
||||
shape: &R1CSShape<G>,
|
||||
gens: &R1CSGens<G>,
|
||||
ck: &CommitmentKey<G>,
|
||||
) -> Result<(R1CSInstance<G>, R1CSWitness<G>), NovaError> {
|
||||
let W = R1CSWitness::<G>::new(shape, &self.aux_assignment)?;
|
||||
let X = &self.input_assignment[1..];
|
||||
|
||||
let comm_W = W.commit(gens);
|
||||
let comm_W = W.commit(ck);
|
||||
|
||||
let instance = R1CSInstance::<G>::new(shape, &comm_W, X)?;
|
||||
|
||||
@@ -88,8 +87,8 @@ where
|
||||
S
|
||||
}
|
||||
|
||||
fn r1cs_gens(&self) -> R1CSGens<G> {
|
||||
R1CSGens::<G>::new(self.num_constraints(), self.num_aux())
|
||||
fn commitment_key(&self) -> CommitmentKey<G> {
|
||||
R1CS::<G>::commitment_key(self.num_constraints(), self.num_aux())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user