diff --git a/Cargo.toml b/Cargo.toml index 6e88e54..4c5a04d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ version = "0.0.1" [dependencies] rand = "0.4.0" +ff = { version = "0.4", features = ["derive"] } # sha3 = "0.8" [dependencies.merlin] @@ -18,6 +19,7 @@ version = "1.0.0" [dependencies.pairing] git = "https://github.com/burdges/pairing" -branch = "derives_borrows_etc0" +branch = "master-hashing-derives_borrows_etc0" +# branch = "derives_borrows_etc0" # git = "https://github.com/mmaker/pairing" # branch = "master" diff --git a/src/lib.rs b/src/lib.rs index abb1a0a..5c7c497 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,9 @@ // #![feature(generic_associated_types)] #![feature(associated_type_defaults)] +// #[macro_use] +extern crate ff; + extern crate merlin; extern crate pairing; extern crate rand; @@ -10,7 +13,8 @@ extern crate rand; use std::borrow::Borrow; -use pairing::{CurveAffine, CurveProjective, Engine, Field, PrimeField, SqrtField}; +use ff::{Field, PrimeField, ScalarEngine, SqrtField}; // PrimeFieldDecodingError, PrimeFieldRepr +use pairing::{CurveAffine, CurveProjective, Engine}; use rand::{Rand, Rng}; pub mod single; @@ -69,8 +73,8 @@ impl<'a> From<&'a [u8]> for Message { /// We also extract two functions users may with to override: /// random scalar generation and hashing to the singature curve. pub trait EngineBLS { - type Engine: Engine; - type Scalar: PrimeField + SqrtField; + type Engine: Engine + ScalarEngine; + type Scalar: PrimeField + SqrtField; // = ::Fr; /// Group where BLS public keys live /// @@ -182,7 +186,7 @@ pub struct UsualBLS(pub E); impl EngineBLS for UsualBLS { type Engine = E; - type Scalar = ::Fr; + type Scalar = ::Fr; type PublicKeyGroup = E::G1; type SignatureGroup = E::G2; @@ -223,7 +227,7 @@ pub struct TinyBLS(pub E); impl EngineBLS for TinyBLS { type Engine = E; - type Scalar = ::Fr; + type Scalar = ::Fr; type PublicKeyGroup = E::G2; type SignatureGroup = E::G1; diff --git a/src/single.rs b/src/single.rs index 1f255e4..cd7e49e 100644 --- a/src/single.rs +++ b/src/single.rs @@ -23,7 +23,8 @@ //! https://github.com/ebfull/pairing/pull/87#issuecomment-402397091 //! https://github.com/poanetwork/hbbft/blob/38178af1244ddeca27f9d23750ca755af6e886ee/src/crypto/serde_impl.rs#L95 -use pairing::{CurveAffine, CurveProjective, Field}; // Engine, PrimeField, SqrtField +use ff::{Field}; // PrimeField, ScalarEngine, SqrtField +use pairing::{CurveAffine, CurveProjective}; // Engine, PrimeField, SqrtField use rand::{Rng, thread_rng}; // use rand::prelude::*; // ThreadRng,thread_rng // use rand_chacha::ChaChaRng;