Skip to content

Commit

Permalink
Release 0.6.1 (#215)
Browse files Browse the repository at this point in the history
* Replaced prints with logs, and added error logs where needed (#211)

* Bump version to 0.6.1
  • Loading branch information
DanieleDiBenedetto authored Oct 24, 2023
1 parent 46a3ce6 commit 35cd278
Show file tree
Hide file tree
Showing 54 changed files with 892 additions and 606 deletions.
4 changes: 2 additions & 2 deletions algebra/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "algebra"
version = "0.6.0"
version = "0.6.1"
authors = [
"Sean Bowe",
"Alessandro Chiesa",
Expand Down Expand Up @@ -42,10 +42,10 @@ colored = { version = "2.0.0", optional = true }
rayon = { version = "1.5.1", optional = true }
rayon-core = { version = "1.9.1", optional = true }


unroll = "0.1.5"

serde = { version = "1.0.130", features = ["derive"] }
log = { version = "0.4.0", features = ["std"] }

[dev-dependencies]
blake2 = "0.8.1"
Expand Down
4 changes: 2 additions & 2 deletions algebra/algebra-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "algebra-derive"
version = "0.6.0"
authors = [ "arkworks Contributors" ]
version = "0.6.1"
authors = ["arkworks Contributors"]
description = "A library for deriving serialization traits"
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion algebra/field-assembly/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "field-assembly"
version = "0.6.0"
version = "0.6.1"
authors = [
"jon-chuang <[email protected]>",
"Michele d'Amico <[email protected]>",
Expand All @@ -11,6 +11,7 @@ rust-version = "1.60"
[dependencies]
quote = "1.0.0"
syn = { version = "1.0.0", features = ["full", "parsing", "extra-traits"] }
log = { version = "0.4.0", features = ["std"] }

[lib]
proc-macro = true
2 changes: 1 addition & 1 deletion algebra/src/fft/polynomial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<F: Field> DenseOrSparsePolynomial<'_, F> {
if self.is_zero() {
Some((DensePolynomial::zero(), DensePolynomial::zero()))
} else if divisor.is_zero() {
eprintln!("Dividing by zero polynomial");
log::error!("Dividing by zero polynomial");
None
} else if self.degree() < divisor.degree() {
Some((DensePolynomial::zero(), self.clone().into()))
Expand Down
2 changes: 1 addition & 1 deletion algebra/src/fields/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ macro_rules! sqrt_impl {
check.square_in_place();
}
if !check.is_one() {
eprintln!("Input is not a square root, but it passed the QR test");
log::error!("Input is not a square root, but it passed the QR test");
return None;
}
}
Expand Down
44 changes: 23 additions & 21 deletions algebra/src/fields/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ macro_rules! impl_Fp {
let mut s = $BigInteger::from(1);
let mut k: u16 = 0;
// TODO: Make it independent from the limb size
let two_n : u16 = 2 * 64 * $limbs; // R2 = 2^two_n mod MODULUS
// At each step we want to have the following equalities:
// something * p + r*A = - u, something * p + s*A = v
// The inverse at the end will be -r mod p. The sign is due to the fact
// that our big integers are unsigned so we can work with positive numbers.
// The arithmetic can be improved drastically since, at the beginning,
// r and s are very small.
let two_n: u16 = 2 * 64 * $limbs; // R2 = 2^two_n mod MODULUS
// At each step we want to have the following equalities:
// something * p + r*A = - u, something * p + s*A = v
// The inverse at the end will be -r mod p. The sign is due to the fact
// that our big integers are unsigned so we can work with positive numbers.
// The arithmetic can be improved drastically since, at the beginning,
// r and s are very small.
while v != zero {
while u.is_even() {
u.div2();
Expand Down Expand Up @@ -280,20 +280,22 @@ macro_rules! impl_Fp {
// byte_size + 1 > output_byte_size
fn from_random_bytes_with_flags<F: Flags>(bytes: &[u8]) -> Option<(Self, F)> {
if F::BIT_SIZE > 8 {
return None
return None;
} else {
let mut result_bytes = [0u8; $limbs * 8 + 1];
// Copy the input into a temporary buffer.
result_bytes.iter_mut().zip(bytes).for_each(|(result, input)| {
*result = *input;
});
result_bytes
.iter_mut()
.zip(bytes)
.for_each(|(result, input)| {
*result = *input;
});
// This mask retains everything in the last limb
// that is below `P::MODULUS_BITS`.
let last_limb_mask = (u64::MAX >> P::REPR_SHAVE_BITS).to_le_bytes();
let mut last_bytes_mask = [0u8; 9];
last_bytes_mask[..8].copy_from_slice(&last_limb_mask);


// Length of the buffer containing the field element and the flag.
let output_byte_size = buffer_byte_size(P::MODULUS_BITS as usize + F::BIT_SIZE);
// Location of the flag is the last byte of the serialized
Expand Down Expand Up @@ -377,7 +379,7 @@ macro_rules! impl_Fp {
fn full_root_of_unity() -> Option<Self> {
match P::FULL_ROOT_OF_UNITY {
Some(v) => Some($Fp::<P>(v, PhantomData)),
None => None
None => None,
}
}
}
Expand Down Expand Up @@ -447,21 +449,21 @@ macro_rules! impl_Fp {
impl<P: $FpParameters> FromBytes for $Fp<P> {
#[inline]
fn read<R: Read>(reader: R) -> IoResult<Self> {
$BigInteger::read(reader).and_then( |b|
$BigInteger::read(reader).and_then(|b| {
if b.is_zero() {
Ok($Fp::zero())
} else {
let f = $Fp::from_repr(b);
if f == $Fp::zero() {
Err(IoError::new(
ErrorKind::InvalidData,
"Attempt to deserialize a field element over the modulus")
)
"Attempt to deserialize a field element over the modulus",
))
} else {
Ok(f)
}
}
)
})
}
}

Expand Down Expand Up @@ -507,10 +509,10 @@ macro_rules! impl_Fp {
res.add_assign(&Self::from_repr(<Self as PrimeField>::BigInt::from(
u64::from(c),
)));
},
}
None => {
return Err(());
},
}
}
}
if !res.is_valid() {
Expand All @@ -524,7 +526,7 @@ macro_rules! impl_Fp {
impl<P: $FpParameters> Display for $Fp<P> {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, stringify!($Fp"({})"), self.into_repr())
write!(f, stringify!("({})"$Fp), self.into_repr())
}
}

Expand Down Expand Up @@ -651,5 +653,5 @@ macro_rules! impl_Fp {
other.into_repr().into()
}
}
}
};
}
2 changes: 0 additions & 2 deletions algebra/src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ pub trait PrimeField:
}

impl<F: PrimeField> ToBits for F {

/// Serializes `self` into a vector of bits, in big-endian bit order.
#[inline]
fn write_bits(&self) -> Vec<bool> {
Expand All @@ -433,7 +432,6 @@ impl<F: PrimeField> ToBits for F {
}
}


impl<F: PrimeField> FromBits for F {
// Defines a prime field element from a big endian bit-ordered vector of
// bits, which must not exceed the field modulus.
Expand Down
2 changes: 1 addition & 1 deletion bench-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bench-utils"
version = "0.6.0"
version = "0.6.1"
authors = [
"Sean Bowe",
"Alessandro Chiesa",
Expand Down
3 changes: 2 additions & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "primitives"
version = "0.6.0"
version = "0.6.1"
authors = [
"Sean Bowe",
"Alessandro Chiesa",
Expand Down Expand Up @@ -43,6 +43,7 @@ sha2 = { version = "0.8.2", optional = true }
hmac = { version = "0.7.1", optional = true }

serde = { version = "1.0.130", features = ["derive"] }
log = { version = "0.4.0", features = ["std"] }

[features]
asm = ["algebra/asm"]
Expand Down
9 changes: 2 additions & 7 deletions primitives/benches/crypto_primitives/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl PedersenWindow for CommWindow {
}

const BENCH_INPUT_SIZE: usize = 128;
type C = PedersenCommitment::<MNT4Projective, CommWindow, BENCH_INPUT_SIZE>;
type C = PedersenCommitment<MNT4Projective, CommWindow, BENCH_INPUT_SIZE>;

fn pedersen_comm_setup(c: &mut Criterion) {
c.bench_function("Pedersen Commitment Setup", move |b| {
Expand All @@ -33,12 +33,7 @@ fn pedersen_comm_eval(c: &mut Criterion) {
b.iter(|| {
let rng = &mut rand::thread_rng();
let commitment_randomness = PedersenRandomness::rand(rng);
C::commit(
&parameters,
&input,
&commitment_randomness,
)
.unwrap();
C::commit(&parameters, &input, &commitment_randomness).unwrap();
})
});
}
Expand Down
5 changes: 3 additions & 2 deletions primitives/benches/crypto_primitives/ecvrf.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use algebra::curves::mnt6753::G1Projective as MNT6G1Projective;
use algebra::fields::mnt4753::fr::{Fr as MNT4Fr, FrParameters as MNT4FrParameters};
use algebra::{UniformRand, FpParameters};
use algebra::{FpParameters, UniformRand};
use criterion::Criterion;
use primitives::{
crh::{bowe_hopwood::BoweHopwoodPedersenCRH, pedersen::PedersenWindow, MNT4PoseidonHash},
Expand All @@ -18,7 +18,8 @@ impl PedersenWindow for TestWindow {
const NUM_WINDOWS: usize = 2;
}

const BHMNT6_INPUT_SIZE: usize = ((MNT4FrParameters::MODULUS_BITS + MNT4FrParameters::REPR_SHAVE_BITS)/8) as usize;
const BHMNT6_INPUT_SIZE: usize =
((MNT4FrParameters::MODULUS_BITS + MNT4FrParameters::REPR_SHAVE_BITS) / 8) as usize;
type BHMNT6 = BoweHopwoodPedersenCRH<MNT6G1Projective, TestWindow, BHMNT6_INPUT_SIZE>;
type EcVrfMNT4 = FieldBasedEcVrf<MNT4Fr, MNT6G1Projective, MNT4PoseidonHash, BHMNT6>;

Expand Down
2 changes: 0 additions & 2 deletions primitives/src/commitment/pedersen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl<G: Group, W: PedersenWindow, const N: usize> CommitmentScheme for PedersenC
type Output = G;

fn setup<R: Rng>(rng: &mut R) -> Result<Self::Parameters, Error> {

let time = start_timer!(|| format!(
"PedersenCOMM::Setup: {} {}-bit windows; {{0,1}}^{{{}}} -> G",
W::NUM_WINDOWS,
Expand All @@ -81,7 +80,6 @@ impl<G: Group, W: PedersenWindow, const N: usize> CommitmentScheme for PedersenC
input: &[u8],
randomness: &Self::Randomness,
) -> Result<Self::Output, Error> {

let commit_time = start_timer!(|| "PedersenCOMM::Commit");

// Invoke Pedersen CRH here, to prevent code duplication.
Expand Down
Loading

0 comments on commit 35cd278

Please sign in to comment.