Simplifications in Nova's RO (#98)

* rename methods for better clarity

* rename

* Bump version
This commit is contained in:
Srinath Setty
2022-07-25 12:22:41 -07:00
committed by GitHub
parent c6fa4d44eb
commit 3dc26fd7e4
15 changed files with 172 additions and 219 deletions

View File

@@ -1,5 +1,6 @@
//! This module implements various gadgets necessary for folding R1CS types.
use crate::{
constants::NUM_CHALLENGE_BITS,
gadgets::{
ecc::AllocatedPoint,
utils::{
@@ -8,7 +9,7 @@ use crate::{
},
},
r1cs::{R1CSInstance, RelaxedR1CSInstance},
traits::{Group, HashFuncCircuitTrait, HashFuncConstantsCircuit},
traits::{Group, ROCircuitTrait, ROConstantsCircuit},
};
use bellperson::{
gadgets::{boolean::Boolean, num::AllocatedNum, Assignment},
@@ -60,7 +61,7 @@ where
}
/// Absorb the provided instance in the RO
pub fn absorb_in_ro(&self, ro: &mut G::HashFuncCircuit) {
pub fn absorb_in_ro(&self, ro: &mut G::ROCircuit) {
ro.absorb(self.W.x.clone());
ro.absorb(self.W.y.clone());
ro.absorb(self.W.is_infinity.clone());
@@ -207,7 +208,7 @@ where
pub fn absorb_in_ro<CS: ConstraintSystem<<G as Group>::Base>>(
&self,
mut cs: CS,
ro: &mut G::HashFuncCircuit,
ro: &mut G::ROCircuit,
) -> Result<(), SynthesisError> {
ro.absorb(self.W.x.clone());
ro.absorb(self.W.y.clone());
@@ -262,19 +263,19 @@ where
params: AllocatedNum<G::Base>, // hash of R1CSShape of F'
u: AllocatedR1CSInstance<G>,
T: AllocatedPoint<G::Base>,
ro_consts: HashFuncConstantsCircuit<G>,
ro_consts: ROConstantsCircuit<G>,
limb_width: usize,
n_limbs: usize,
) -> Result<AllocatedRelaxedR1CSInstance<G>, SynthesisError> {
// Compute r:
let mut ro = G::HashFuncCircuit::new(ro_consts);
let mut ro = G::ROCircuit::new(ro_consts);
ro.absorb(params);
self.absorb_in_ro(cs.namespace(|| "absorb running instance"), &mut ro)?;
u.absorb_in_ro(&mut ro);
ro.absorb(T.x.clone());
ro.absorb(T.y.clone());
ro.absorb(T.is_infinity.clone());
let r_bits = ro.get_challenge(cs.namespace(|| "r bits"))?;
let r_bits = ro.squeeze(cs.namespace(|| "r bits"), NUM_CHALLENGE_BITS)?;
let r = le_bits_to_num(cs.namespace(|| "r"), r_bits.clone())?;
// W_fold = self.W + r * u.W