Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repository = "https://github.com/ebfull/pairing"
rand = "0.4"
byteorder = "1"
ff = { version = "0.4", features = ["derive"] }
group = "0.1"

[features]
unstable-features = ["expose-arith"]
Expand Down
4 changes: 2 additions & 2 deletions benches/bls12_381/ec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod g1 {
use rand::{Rand, SeedableRng, XorShiftRng};

use group::CurveProjective;
use pairing::bls12_381::*;
use pairing::CurveProjective;

#[bench]
fn bench_g1_mul_assign(b: &mut ::test::Bencher) {
Expand Down Expand Up @@ -65,8 +65,8 @@ mod g1 {
mod g2 {
use rand::{Rand, SeedableRng, XorShiftRng};

use group::CurveProjective;
use pairing::bls12_381::*;
use pairing::CurveProjective;

#[bench]
fn bench_g2_mul_assign(b: &mut ::test::Bencher) {
Expand Down
2 changes: 1 addition & 1 deletion benches/bls12_381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod fr;
use rand::{Rand, SeedableRng, XorShiftRng};

use pairing::bls12_381::*;
use pairing::{CurveAffine, Engine};
use pairing::{Engine, PairingCurveAffine};

#[bench]
fn bench_pairing_g1_preparation(b: &mut ::test::Bencher) {
Expand Down
1 change: 1 addition & 0 deletions benches/pairing_benches.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(test)]

extern crate ff;
extern crate group;
extern crate pairing;
extern crate rand;
extern crate test;
Expand Down
30 changes: 19 additions & 11 deletions src/bls12_381/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,9 @@ macro_rules! curve_impl {
type Engine = Bls12;
type Scalar = $scalarfield;
type Base = $basefield;
type Prepared = $prepared;
type Projective = $projective;
type Uncompressed = $uncompressed;
type Compressed = $compressed;
type Pair = $pairing;
type PairingResult = Fq12;

fn zero() -> Self {
$affine {
Expand Down Expand Up @@ -182,6 +179,17 @@ macro_rules! curve_impl {
}
}

fn into_projective(&self) -> $projective {
(*self).into()
}

}

impl PairingCurveAffine for $affine {
type Prepared = $prepared;
type Pair = $pairing;
type PairingResult = Fq12;

fn prepare(&self) -> Self::Prepared {
$prepared::from_affine(*self)
}
Expand All @@ -190,10 +198,6 @@ macro_rules! curve_impl {
self.perform_pairing(other)
}

fn into_projective(&self) -> $projective {
(*self).into()
}

}

impl Rand for $projective {
Expand Down Expand Up @@ -624,9 +628,10 @@ pub mod g1 {
use super::super::{Bls12, Fq, Fq12, FqRepr, Fr, FrRepr};
use super::g2::G2Affine;
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField};
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
use rand::{Rand, Rng};
use std::fmt;
use {CurveAffine, CurveProjective, EncodedPoint, Engine, GroupDecodingError};
use {Engine, PairingCurveAffine};

curve_impl!(
"G1",
Expand Down Expand Up @@ -1261,17 +1266,19 @@ pub mod g1 {

#[test]
fn g1_curve_tests() {
::tests::curve::curve_tests::<G1>();
use group::tests::curve_tests;
curve_tests::<G1>();
}
}

pub mod g2 {
use super::super::{Bls12, Fq, Fq12, Fq2, FqRepr, Fr, FrRepr};
use super::g1::G1Affine;
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField};
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
use rand::{Rand, Rng};
use std::fmt;
use {CurveAffine, CurveProjective, EncodedPoint, Engine, GroupDecodingError};
use {Engine, PairingCurveAffine};

curve_impl!(
"G2",
Expand Down Expand Up @@ -2014,7 +2021,8 @@ pub mod g2 {

#[test]
fn g2_curve_tests() {
::tests::curve::curve_tests::<G2>();
use group::tests::curve_tests;
curve_tests::<G2>();
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/bls12_381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ pub use self::fq2::Fq2;
pub use self::fq6::Fq6;
pub use self::fr::{Fr, FrRepr};

use super::{CurveAffine, Engine};
use super::{Engine, PairingCurveAffine};

use ff::{BitIterator, Field, ScalarEngine};
use group::CurveAffine;

// The BLS parameter x for BLS12-381 is -0xd201000000010000
const BLS_X: u64 = 0xd201000000010000;
Expand All @@ -46,8 +47,8 @@ impl Engine for Bls12 {
where
I: IntoIterator<
Item = &'a (
&'a <Self::G1Affine as CurveAffine>::Prepared,
&'a <Self::G2Affine as CurveAffine>::Prepared,
&'a <Self::G1Affine as PairingCurveAffine>::Prepared,
&'a <Self::G2Affine as PairingCurveAffine>::Prepared,
),
>,
{
Expand Down
3 changes: 3 additions & 0 deletions src/bls12_381/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use ff::PrimeFieldRepr;
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};

use super::*;
use *;

Expand Down
Loading