Skip to content

Commit

Permalink
Bump ff to 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Jan 26, 2021
1 parent fa9be45 commit 6491440
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Bumped dependencies to `ff 0.9`, `group 0.9`, `pairing 0.19`, `rand_core 0.6`.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ edition = "2018"
[dependencies]
bitvec = "0.18"
blake2s_simd = "0.5"
ff = "0.8"
ff = "0.9"
futures = "0.1"
futures-cpupool = { version = "0.1", optional = true }
group = "0.8"
group = "0.9"
num_cpus = { version = "1", optional = true }
crossbeam = { version = "0.7", optional = true }
pairing = { version = "0.18", optional = true }
rand_core = "0.5"
pairing = { version = "0.19", optional = true }
rand_core = "0.6"
byteorder = "1"
subtle = "2.2.1"

[dev-dependencies]
bls12_381 = "0.3"
bls12_381 = "0.4"
hex-literal = "0.2"
rand = "0.7"
rand_xorshift = "0.2"
rand = "0.8"
rand_xorshift = "0.3"
sha2 = "0.9"

[features]
Expand Down
4 changes: 2 additions & 2 deletions src/gadgets/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ pub fn field_into_allocated_bits_le<
let values = match value {
Some(ref value) => {
let field_char = F::char_le_bits();
let mut field_char = field_char.into_iter().rev();
let mut field_char = field_char.iter().by_ref().rev();

let mut tmp = Vec::with_capacity(F::NUM_BITS as usize);

let mut found_one = false;
for b in value.to_le_bits().into_iter().rev().cloned() {
for b in value.to_le_bits().iter().by_val().rev() {
// Skip leading bits
found_one |= field_char.next().unwrap();
if !found_one {
Expand Down
12 changes: 6 additions & 6 deletions src/gadgets/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<Scalar: PrimeField> AllocatedNum<Scalar> {
let b = (-Scalar::one()).to_le_bits();

// Get the bits of a in big-endian order
let mut a = a.as_ref().map(|e| e.into_iter().rev());
let mut a = a.as_ref().map(|e| e.iter().by_val().rev());

let mut result = vec![];

Expand All @@ -116,7 +116,7 @@ impl<Scalar: PrimeField> AllocatedNum<Scalar> {

let mut found_one = false;
let mut i = 0;
for b in b.into_iter().rev().cloned() {
for b in b.iter().by_val().rev() {
let a_bit = a.as_mut().map(|e| e.next().unwrap());

// Skip over unset bits at the beginning
Expand All @@ -131,7 +131,7 @@ impl<Scalar: PrimeField> AllocatedNum<Scalar> {
// This is part of a run of ones. Let's just
// allocate the boolean with the expected value.
let a_bit =
AllocatedBit::alloc(cs.namespace(|| format!("bit {}", i)), a_bit.cloned())?;
AllocatedBit::alloc(cs.namespace(|| format!("bit {}", i)), a_bit.clone())?;
// ... and add it to the current run of ones.
current_run.push(a_bit.clone());
result.push(a_bit);
Expand All @@ -157,7 +157,7 @@ impl<Scalar: PrimeField> AllocatedNum<Scalar> {

let a_bit = AllocatedBit::alloc_conditionally(
cs.namespace(|| format!("bit {}", i)),
a_bit.cloned(),
a_bit.clone(),
&last_run.as_ref().expect("char always starts with a one"),
)?;
result.push(a_bit);
Expand Down Expand Up @@ -566,10 +566,10 @@ mod test {

for (b, a) in r
.to_le_bits()
.into_iter()
.iter()
.by_val()
.rev()
.skip(1)
.cloned()
.zip(bits.iter().rev())
{
if let &Boolean::Is(ref a) = a {
Expand Down
11 changes: 5 additions & 6 deletions src/groth16/tests/dummy_engine.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use bitvec::{array::BitArray, order::Lsb0};
use ff::{Field, PrimeField};
use ff::{Field, FieldBits, PrimeField};
use group::{
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
Curve, Group, GroupEncoding, UncompressedEncoding, WnafGroup,
Expand Down Expand Up @@ -308,16 +307,16 @@ impl PrimeField for Fr {
FrRepr::from(*self)
}

fn to_le_bits(&self) -> BitArray<Lsb0, Self::ReprBits> {
BitArray::new((self.0).0 as u64)
fn to_le_bits(&self) -> FieldBits<Self::ReprBits> {
FieldBits::new((self.0).0 as u64)
}

fn is_odd(&self) -> bool {
(self.0).0 % 2 != 0
}

fn char_le_bits() -> BitArray<Lsb0, Self::ReprBits> {
BitArray::new(MODULUS_R.0 as u64)
fn char_le_bits() -> FieldBits<Self::ReprBits> {
FieldBits::new(MODULUS_R.0 as u64)
}

fn multiplicative_generator() -> Fr {
Expand Down
10 changes: 5 additions & 5 deletions src/multiexp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::multicore::Worker;
use bitvec::{array::BitArray, order::Lsb0, vec::BitVec};
use ff::PrimeField;
use bitvec::{order::Lsb0, vec::BitVec};
use ff::{FieldBits, PrimeField};
use futures::Future;
use group::prime::{PrimeCurve, PrimeCurveAffine};
use std::io;
Expand Down Expand Up @@ -149,7 +149,7 @@ fn multiexp_inner<Q, D, G, S>(
pool: &Worker,
bases: S,
density_map: D,
exponents: Arc<Vec<BitArray<Lsb0, <G::Scalar as PrimeField>::ReprBits>>>,
exponents: Arc<Vec<FieldBits<<G::Scalar as PrimeField>::ReprBits>>>,
mut skip: u32,
c: u32,
handle_trivial: bool,
Expand Down Expand Up @@ -196,9 +196,9 @@ where
} else {
let exp = exp
.into_iter()
.by_val()
.skip(skip as usize)
.take(c as usize)
.cloned()
.enumerate()
.fold(0u64, |acc, (i, b)| acc + ((b as u64) << i));

Expand Down Expand Up @@ -263,7 +263,7 @@ pub fn multiexp<Q, D, G, S>(
pool: &Worker,
bases: S,
density_map: D,
exponents: Arc<Vec<BitArray<Lsb0, <G::Scalar as PrimeField>::ReprBits>>>,
exponents: Arc<Vec<FieldBits<<G::Scalar as PrimeField>::ReprBits>>>,
) -> Box<dyn Future<Item = G, Error = SynthesisError>>
where
for<'a> &'a Q: QueryDensity,
Expand Down

0 comments on commit 6491440

Please sign in to comment.