Skip to content
Draft
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
83 changes: 70 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 11 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,18 @@ version = "0.10.0"
edition = "2021"
rust-version = "1.63"

[dependencies.bitvec]
version = "1"
default-features = false

[dependencies.bls12_381]
version = "0.8"
default-features = false

[dependencies.ff]
version = "0.13"
default-features = false

[dependencies.group]
version = "0.13"
default-features = false

[dependencies.rand_core]
version = "0.6"
default-features = false

[dependencies.subtle]
version = "^2.2.1"
default-features = false
[dependencies]
bitvec = { version = "1", default-features = false }
bls12_381 = { version = "0.8", default-features = false }
ff = { version = "=0.14.0-pre.0", default-features = false }
group = { version = "=0.14.0-pre.0", default-features = false }
rand_core = { version = "0.9", default-features = false }
subtle = { version = "^2.2.1", default-features = false }

[dev-dependencies]
criterion = "0.3"
csv = ">= 1.0, < 1.2" # csv 1.2 has MSRV 1.60

[dev-dependencies.rand_xorshift]
version = "0.3"
default-features = false
rand_xorshift = { version = "0.4", default-features = false }

[features]
default = ["alloc", "bits"]
Expand All @@ -62,3 +43,6 @@ harness = false
[[bench]]
name = "point_bench"
harness = false

[patch.crates-io]
bls12_381 = { git = "https://github.com/zkcrypto/bls12_381.git", rev = "d5df9da6b20619bf77cc432447c02f8f6a6a1fb3" }
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased
## Changed
- Bumped MSRV to `1.63.0`
- Bumped dependencies to `bls12_381 0.9`, `ff 0.14`, `group 0.14`.

# 0.10.0
## Changed
Expand Down
8 changes: 4 additions & 4 deletions src/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};

use ff::{Field, PrimeField};
use rand_core::RngCore;
use rand_core::TryRngCore;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "bits")]
Expand Down Expand Up @@ -681,10 +681,10 @@ impl Field for Fr {
const ZERO: Self = Self::zero();
const ONE: Self = Self::one();

fn random(mut rng: impl RngCore) -> Self {
fn try_from_rng<R: TryRngCore + ?Sized>(rng: &mut R) -> Result<Self, R::Error> {
let mut buf = [0; 64];
rng.fill_bytes(&mut buf);
Self::from_bytes_wide(&buf)
rng.try_fill_bytes(&mut buf)?;
Ok(Self::from_bytes_wide(&buf))
}

#[must_use]
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use group::{
prime::PrimeGroup,
Curve, Group, GroupEncoding,
};
use rand_core::RngCore;
use rand_core::TryRngCore;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -1241,10 +1241,10 @@ impl_binops_multiplicative!(SubgroupPoint, Fr);
impl Group for ExtendedPoint {
type Scalar = Fr;

fn random(mut rng: impl RngCore) -> Self {
fn try_from_rng<R: TryRngCore + ?Sized>(rng: &mut R) -> Result<Self, R::Error> {
loop {
let v = Fq::random(&mut rng);
let flip_sign = rng.next_u32() % 2 != 0;
let v = Fq::try_from_rng(rng)?;
let flip_sign = rng.try_next_u32()? % 2 != 0;

// See AffinePoint::from_bytes for details.
let v2 = v.square();
Expand All @@ -1260,7 +1260,7 @@ impl Group for ExtendedPoint {
let p = p.unwrap().to_curve();

if bool::from(!p.is_identity()) {
return p;
return Ok(p);
}
}
}
Expand All @@ -1287,12 +1287,12 @@ impl Group for ExtendedPoint {
impl Group for SubgroupPoint {
type Scalar = Fr;

fn random(mut rng: impl RngCore) -> Self {
fn try_from_rng<R: TryRngCore + ?Sized>(rng: &mut R) -> Result<Self, R::Error> {
loop {
let p = ExtendedPoint::random(&mut rng).clear_cofactor();
let p = ExtendedPoint::try_from_rng(rng)?.clear_cofactor();

if bool::from(!p.is_identity()) {
return p;
return Ok(p);
}
}
}
Expand Down
Loading