Compare commits

...

4 Commits

Author SHA1 Message Date
Jack Grigg b010c995c3 Migrate to `group::CurveAffine` 2023-07-30 09:51:41 +00:00
str4d a586b8c2db
Merge pull request #68 from zcash/msrv-1.60
Bump MSRV to 1.60
2023-07-30 10:36:55 +01:00
Jack Grigg cb43e87faf `criterion 0.4` 2023-03-02 17:23:42 +00:00
Jack Grigg ef9cc828f9 Bump MSRV to 1.60.0 2023-03-02 17:09:58 +00:00
8 changed files with 26 additions and 48 deletions

View File

@ -6,6 +6,9 @@ and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- MSRV is now 1.60.0.
## [0.5.1] - 2023-03-02
### Fixed
- Fix a bug on 32-bit platforms that could cause the square root implementation

View File

@ -9,7 +9,7 @@ authors = [
"Jack Grigg <jack@electriccoin.co>",
]
edition = "2021"
rust-version = "1.56"
rust-version = "1.60"
license = "MIT OR Apache-2.0"
repository = "https://github.com/zcash/pasta_curves"
documentation = "https://docs.rs/pasta_curves"
@ -21,8 +21,7 @@ rustdoc-args = ["--cfg", "docsrs", "--html-in-header", "katex-header.html"]
[dev-dependencies]
bincode = "1.3"
criterion = "0.3"
csv = ">= 1.0, < 1.2" # csv 1.2 has MSRV 1.60
criterion = "0.4"
rand_xorshift = "0.3"
serde_json = "1.0"
@ -73,3 +72,6 @@ sqrt-table = ["alloc", "lazy_static"]
repr-c = []
uninline-portable = []
serde = ["hex", "serde_crate"]
[patch.crates-io]
group = { git = "https://github.com/zkcrypto/group.git", rev = "85c484fff517135cedfe265ef893bd4b8d745300" }

View File

@ -8,7 +8,7 @@ Pallas and Vesta. More details about the Pasta curves can be found
## Minimum Supported Rust Version
Requires Rust **1.56** or higher.
Requires Rust **1.60** or higher.
Minimum supported Rust version can be changed in the future, but it will be done with a
minor version bump.

View File

@ -33,7 +33,7 @@ fn point_bench<C: CurveExt>(c: &mut Criterion, name: &str) {
for &n in [100, 1000, 10000].iter() {
let input = vec![a; n];
let mut output = vec![C::AffineRepr::default(); n];
let mut output = vec![C::Affine::default(); n];
group.bench_function(format!("point batch_normalize/{}", n), |bencher| {
bencher.iter(|| C::batch_normalize(input.as_slice(), output.as_mut_slice()));
});

View File

@ -1,3 +1,3 @@
[toolchain]
channel = "1.56.0"
channel = "1.60.0"
components = [ "clippy", "rustfmt" ]

View File

@ -24,7 +24,7 @@ pub trait CurveExt:
+ Default
+ ConditionallySelectable
+ ConstantTimeEq
+ From<<Self as PrimeCurve>::Affine>
+ From<Self::Affine>
{
/// The scalar field of this elliptic curve.
type ScalarExt: ff::WithSmallOrderMulGroup<3>;
@ -88,15 +88,13 @@ pub trait CurveExt:
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub trait CurveAffine:
PrimeCurveAffine<
Scalar = <Self as CurveAffine>::ScalarExt,
Curve = <Self as CurveAffine>::CurveExt,
> + Default
+ Add<Output = <Self as PrimeCurveAffine>::Curve>
+ Sub<Output = <Self as PrimeCurveAffine>::Curve>
PrimeCurveAffine<Curve = Self::CurveExt, Scalar = Self::ScalarExt>
+ Default
+ Add<Output = Self::Curve>
+ Sub<Output = Self::Curve>
+ ConditionallySelectable
+ ConstantTimeEq
+ From<<Self as PrimeCurveAffine>::Curve>
+ From<Self::Curve>
{
/// The scalar field of this elliptic curve.
type ScalarExt: ff::WithSmallOrderMulGroup<3> + Ord;

View File

@ -12,8 +12,8 @@ use alloc::boxed::Box;
use ff::{Field, PrimeField};
use group::{
cofactor::{CofactorCurve, CofactorGroup},
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
Curve as _, Group as _, GroupEncoding,
prime::{PrimeCurve, PrimeGroup},
Curve as _, CurveAffine as _, Group as _, GroupEncoding,
};
use rand::RngCore;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
@ -168,9 +168,9 @@ macro_rules! new_curve_impl {
}
impl group::Curve for $name {
type AffineRepr = $name_affine;
type Affine = $name_affine;
fn batch_normalize(p: &[Self], q: &mut [Self::AffineRepr]) {
fn batch_normalize(p: &[Self], q: &mut [Self::Affine]) {
assert_eq!(p.len(), q.len());
let mut acc = $base::one();
@ -207,7 +207,7 @@ macro_rules! new_curve_impl {
}
}
fn to_affine(&self) -> Self::AffineRepr {
fn to_affine(&self) -> Self::Affine {
let zinv = self.z.invert().unwrap_or($base::zero());
let zinv2 = zinv.square();
let x = self.x * zinv2;
@ -244,13 +244,9 @@ macro_rules! new_curve_impl {
}
}
impl PrimeCurve for $name {
type Affine = $name_affine;
}
impl PrimeCurve for $name {}
impl CofactorCurve for $name {
type Affine = $name_affine;
}
impl CofactorCurve for $name {}
impl GroupEncoding for $name {
type Repr = [u8; 32];
@ -610,7 +606,7 @@ macro_rules! new_curve_impl {
}
}
impl PrimeCurveAffine for $name_affine {
impl group::CurveAffine for $name_affine {
type Curve = $name;
type Scalar = $scalar;
@ -636,27 +632,6 @@ macro_rules! new_curve_impl {
}
}
impl group::cofactor::CofactorCurveAffine for $name_affine {
type Curve = $name;
type Scalar = $scalar;
fn identity() -> Self {
<Self as PrimeCurveAffine>::identity()
}
fn generator() -> Self {
<Self as PrimeCurveAffine>::generator()
}
fn is_identity(&self) -> Choice {
<Self as PrimeCurveAffine>::is_identity(self)
}
fn to_curve(&self) -> Self::Curve {
<Self as PrimeCurveAffine>::to_curve(self)
}
}
impl GroupEncoding for $name_affine {
type Repr = [u8; 32];

View File

@ -137,7 +137,7 @@ mod tests {
use core::fmt::Debug;
use ff::Field;
use group::{prime::PrimeCurveAffine, Curve, Group};
use group::{Curve, CurveAffine, Group};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;