diff --git a/Cargo.toml b/Cargo.toml index f170c84..5f16018 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,9 @@ repository = "https://github.com/ebfull/pairing" [dependencies] rand = "0.4" byteorder = "1" -ff = "0.3" +ff = { version = "0.4", features = ["derive"] } [features] unstable-features = ["expose-arith"] expose-arith = [] -u128-support = ["ff/u128-support"] default = [] diff --git a/README.md b/README.md index d71d0c5..bf386de 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,6 @@ This is a Rust crate for using pairing-friendly elliptic curves. Currently, only Bring the `pairing` crate into your project just as you normally would. -If you're using a supported platform and the nightly Rust compiler, you can enable the `u128-support` feature for faster arithmetic. - -```toml -[dependencies.pairing] -version = "0.14" -features = ["u128-support"] -``` - ## Security Warnings This library does not make any guarantees about constant-time operations, memory access patterns, or resistance to side-channel attacks. diff --git a/src/bls12_381/mod.rs b/src/bls12_381/mod.rs index c6c13c5..106591e 100644 --- a/src/bls12_381/mod.rs +++ b/src/bls12_381/mod.rs @@ -20,7 +20,7 @@ pub use self::fr::{Fr, FrRepr}; use super::{CurveAffine, Engine}; -use ff::{BitIterator, Field}; +use ff::{BitIterator, Field, ScalarEngine}; // The BLS parameter x for BLS12-381 is -0xd201000000010000 const BLS_X: u64 = 0xd201000000010000; @@ -29,8 +29,11 @@ const BLS_X_IS_NEGATIVE: bool = true; #[derive(Clone, Debug)] pub struct Bls12; -impl Engine for Bls12 { +impl ScalarEngine for Bls12 { type Fr = Fr; +} + +impl Engine for Bls12 { type G1 = G1; type G1Affine = G1Affine; type G2 = G2; diff --git a/src/lib.rs b/src/lib.rs index c3640c4..75af6e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,17 +25,14 @@ pub mod bls12_381; mod wnaf; pub use self::wnaf::Wnaf; -use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField}; +use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, ScalarEngine, SqrtField}; use std::error::Error; use std::fmt; /// An "engine" is a collection of types (fields, elliptic curve groups, etc.) /// with well-defined relationships. In particular, the G1/G2 curve groups are /// of prime order `r`, and are equipped with a bilinear pairing function. -pub trait Engine: Sized + 'static + Clone { - /// This is the scalar field of the G1/G2 groups. - type Fr: PrimeField + SqrtField; - +pub trait Engine: ScalarEngine { /// The projective representation of an element in G1. type G1: CurveProjective< Engine = Self,