Skip to content

Commit

Permalink
Merge pull request #6 from zb99zhou/fix_pcd
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolwindHF authored Jun 1, 2024
2 parents 31fd9e4 + 4dab298 commit ecc9beb
Show file tree
Hide file tree
Showing 61 changed files with 7,929 additions and 7,689 deletions.
181 changes: 0 additions & 181 deletions error.log

This file was deleted.

6 changes: 3 additions & 3 deletions src/bellpepper/r1cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#![allow(non_snake_case)]

use super::{shape_cs::ShapeCS, solver::SatisfyingAssignment, test_shape_cs::TestShapeCS};
use crate::nimfs::ccs::cccs::{CCSWitness, CCCS};
use crate::nimfs::ccs::ccs::CCS;
use crate::traits::commitment::CommitmentEngineTrait;
use crate::{
errors::NovaError,
r1cs::{R1CSInstance, R1CSShape, R1CSWitness, R1CS},
Expand All @@ -12,9 +15,6 @@ use crate::{
use bellpepper_core::{Index, LinearCombination};
use ff::{Field, PrimeField};
use rand_core::OsRng;
use crate::nimfs::ccs::cccs::{CCCS, CCSWitness};
use crate::nimfs::ccs::ccs::CCS;
use crate::traits::commitment::CommitmentEngineTrait;

/// `NovaWitness` provide a method for acquiring an `R1CSInstance` and `R1CSWitness` from implementers.
pub trait NovaWitness<G: Group> {
Expand Down
20 changes: 11 additions & 9 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
//! the other into the running instance

use crate::{
constants::{NUM_FE_WITHOUT_IO_FOR_CRHF, NUM_HASH_BITS},
constants::NUM_HASH_BITS,
gadgets::{
ecc::AllocatedPoint,
r1cs::{AllocatedR1CSInstance, AllocatedRelaxedR1CSInstance},
utils::{
alloc_num_equals, alloc_scalar_as_base, alloc_zero, conditionally_select_vec_allocated_num, le_bits_to_num,
alloc_num_equals, alloc_scalar_as_base, alloc_zero, conditionally_select_vec_allocated_num,
le_bits_to_num,
},
},
r1cs::{R1CSInstance, RelaxedR1CSInstance},
Expand Down Expand Up @@ -125,6 +126,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
),
SynthesisError,
> {
const IO_NUM: usize = 2;
// Allocate the params
let params = alloc_scalar_as_base::<G, _>(
cs.namespace(|| "params"),
Expand Down Expand Up @@ -159,6 +161,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
self.inputs.get().as_ref().map_or(None, |inputs| {
inputs.U.get().as_ref().map_or(None, |U| Some(U))
}),
IO_NUM,
self.params.limb_width,
self.params.n_limbs,
)?;
Expand All @@ -169,6 +172,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
self.inputs.get().as_ref().map_or(None, |inputs| {
inputs.u.get().as_ref().map_or(None, |u| Some(u))
}),
IO_NUM,
)?;

// Allocate T
Expand All @@ -194,6 +198,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
cs.namespace(|| "Allocate U_default"),
self.params.limb_width,
self.params.n_limbs,
2,
)?
} else {
// The secondary circuit returns the incoming R1CS instance
Expand All @@ -220,13 +225,10 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
U: &AllocatedRelaxedR1CSInstance<G>,
u: &AllocatedR1CSInstance<G>,
T: &AllocatedPoint<G>,
arity: usize,
_arity: usize,
) -> Result<(AllocatedRelaxedR1CSInstance<G>, AllocatedBit), SynthesisError> {
// Check that u.x[0] = Hash(params, U, i, z0, zi)
let mut ro = G::ROCircuit::new(
self.ro_consts.clone(),
NUM_FE_WITHOUT_IO_FOR_CRHF + 2 * arity,
);
let mut ro = G::ROCircuit::new(self.ro_consts.clone(), 0);
ro.absorb(params);
ro.absorb(i);
for e in z_0 {
Expand All @@ -246,7 +248,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
)?;

// Run NIFS Verifier
let U_fold = U.fold_with_r1cs(
let U_fold = U.fold_with_r1cs_contains_r(
cs.namespace(|| "compute fold of U and u"),
params,
u,
Expand Down Expand Up @@ -343,7 +345,7 @@ impl<'a, G: Group, SC: StepCircuit<G::Base>> NovaAugmentedCircuit<'a, G, SC> {
}

// Compute the new hash H(params, Unew, i+1, z0, z_{i+1})
let mut ro = G::ROCircuit::new(self.ro_consts, NUM_FE_WITHOUT_IO_FOR_CRHF + 2 * arity);
let mut ro = G::ROCircuit::new(self.ro_consts, 0);
ro.absorb(&params);
ro.absorb(&i_new);
for e in &z_0 {
Expand Down
8 changes: 4 additions & 4 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! This module defines errors returned by the library.
use core::fmt::Debug;
use bellpepper_core::SynthesisError;
use thiserror::Error;
use crate::nimfs::ccs::ccs::CCSError;
use crate::nimfs::espresso::errors::ArithErrors;
use bellpepper_core::SynthesisError;
use core::fmt::Debug;
use thiserror::Error;

/// Errors returned by Nova
#[derive(Debug, Error)]
Expand Down Expand Up @@ -104,4 +104,4 @@ impl From<CCSError> for NovaError {
fn from(e: CCSError) -> Self {
Self::CCSErrors(e)
}
}
}
Loading

0 comments on commit ecc9beb

Please sign in to comment.