Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn u64_into_bit_vec_le<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
Ok(bits)
}

/// Gets as input the little indian representation of a number and spits out the number
/// Gets as input the little endian representation of a number and spits out the number
pub fn le_bits_to_num<Scalar, CS>(
mut cs: CS,
bits: &[AllocatedBit],
Expand Down Expand Up @@ -167,11 +167,11 @@ impl<G: Group> StepCircuit<G::Scalar> for AndCircuit<G> {
let mut c_bits = Vec::new();

// perform bitwise AND
for i in 0..64 {
for bit_idx in 0..64 {
let c_bit = AllocatedBit::and(
cs.namespace(|| format!("and_bit_{i}")),
&a_bits[i],
&b_bits[i],
cs.namespace(|| format!("and_bit_{}_{}", i, bit_idx)),
&a_bits[bit_idx],
&b_bits[bit_idx],
)?;
c_bits.push(c_bit);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/hashchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ impl<G: Group> StepCircuit<G::Scalar> for HashChainCircuit<G> {
}
}

/// cargo run --release --example and
/// cargo run --release --example hashchain
fn main() {
println!("=========================================================");
println!("Nova-based hashchain example");
println!("=========================================================");

let num_steps = 10;
for num_elts_per_step in [1024, 2048, 4096] {
// number of instances of AND per Nova's recursive step
// number of field elements per hash chain node
let circuit = HashChainCircuit::new(num_elts_per_step);

// produce public parameters
Expand Down
16 changes: 8 additions & 8 deletions examples/minroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ struct MinRootIteration<G: Group> {
impl<G: Group> MinRootIteration<G> {
// produces a sample non-deterministic advice, executing one invocation of MinRoot per step
fn new(num_iters: usize, x_0: &G::Scalar, y_0: &G::Scalar) -> (Vec<G::Scalar>, Vec<Self>) {
// exp = (p - 3 / 5), where p is the order of the group
// exp = (p - 3) * 5^(-1) mod p, where p is the order of the group
// This computes the exponent such that x^exp ≡ x^(1/5) (mod p)
// x^{exp} mod p provides the fifth root of x
let exp = {
let p = G::group_params().2.to_biguint().unwrap();
Expand Down Expand Up @@ -89,8 +90,10 @@ impl<G: Group> StepCircuit<G::Scalar> for MinRootCircuit<G> {
cs: &mut CS,
z: &[AllocatedNum<G::Scalar>],
) -> Result<Vec<AllocatedNum<G::Scalar>>, SynthesisError> {
let mut z_out: Result<Vec<AllocatedNum<G::Scalar>>, SynthesisError> =
Err(SynthesisError::AssignmentMissing);
// Handle empty sequence case
if self.seq.is_empty() {
return Ok(z.to_vec());
}

// use the provided inputs
let x_0 = z[0].clone();
Expand Down Expand Up @@ -121,16 +124,13 @@ impl<G: Group> StepCircuit<G::Scalar> for MinRootCircuit<G> {
|lc| lc + x_i.get_variable() + y_i.get_variable(),
);

if i == self.seq.len() - 1 {
z_out = Ok(vec![x_i_plus_1.clone(), x_i.clone()]);
}

// update x_i and y_i for the next iteration
y_i = x_i;
x_i = x_i_plus_1;
}

z_out
// Return final state
Ok(vec![x_i, y_i])
}
}

Expand Down
Loading