Skip to content

Commit

Permalink
Migrate to ff 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Jul 4, 2018
1 parent 4752a91 commit c5b883f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions src/bls12_381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c5b883f

Please sign in to comment.