Skip to content

Commit

Permalink
Update to current master that uses ff crate
Browse files Browse the repository at this point in the history
  • Loading branch information
burdges committed Apr 8, 2019
1 parent d95b737 commit fc4d831
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version = "0.0.1"

[dependencies]
rand = "0.4.0"
ff = { version = "0.4", features = ["derive"] }
# sha3 = "0.8"

[dependencies.merlin]
Expand All @@ -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"
14 changes: 9 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
// #![feature(generic_associated_types)]
#![feature(associated_type_defaults)]

// #[macro_use]
extern crate ff;

extern crate merlin;
extern crate pairing;
extern crate rand;
// extern crate sha3;

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;
Expand Down Expand Up @@ -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<Fr = Self::Scalar>;
type Scalar: PrimeField + SqrtField;
type Engine: Engine + ScalarEngine<Fr = Self::Scalar>;
type Scalar: PrimeField + SqrtField; // = <Self::Engine as ScalarEngine>::Fr;

/// Group where BLS public keys live
///
Expand Down Expand Up @@ -182,7 +186,7 @@ pub struct UsualBLS<E: Engine>(pub E);

impl<E: Engine> EngineBLS for UsualBLS<E> {
type Engine = E;
type Scalar = <Self::Engine as Engine>::Fr;
type Scalar = <Self::Engine as ScalarEngine>::Fr;
type PublicKeyGroup = E::G1;
type SignatureGroup = E::G2;

Expand Down Expand Up @@ -223,7 +227,7 @@ pub struct TinyBLS<E: Engine>(pub E);

impl<E: Engine> EngineBLS for TinyBLS<E> {
type Engine = E;
type Scalar = <Self::Engine as Engine>::Fr;
type Scalar = <Self::Engine as ScalarEngine>::Fr;
type PublicKeyGroup = E::G2;
type SignatureGroup = E::G1;

Expand Down
3 changes: 2 additions & 1 deletion src/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fc4d831

Please sign in to comment.