Convert all uses of `Bls12` and friends to refer to root `lib.rs` instead of importing from pairing directly.

This commit is contained in:
Marc Brinkmann 2018-09-25 12:17:12 +02:00
parent 02109b586e
commit 98b50d4b8e
4 changed files with 17 additions and 9 deletions

View File

@ -1,4 +1,4 @@
use pairing::bls12_381::Fr;
use super::Fr;
use pairing::{Field, PrimeField};
/// A conversion into an element of the field `Fr`.

View File

@ -38,7 +38,15 @@ use byteorder::{BigEndian, ByteOrder};
use errno::errno;
use init_with::InitWith;
use memsec::{memzero, mlock, munlock};
use pairing::bls12_381::{Bls12, Fr, G1, G1Affine, G2, G2Affine};
use pairing::bls12_381::Bls12 as PEngine;
type Fq = pairing::bls12_381::Fq;
type Fr = pairing::bls12_381::Fr;
type G1 = pairing::bls12_381::G1;
type G1Affine = pairing::bls12_381::G1Affine;
type G2 = pairing::bls12_381::G2;
type G2Affine = pairing::bls12_381::G2Affine;
use pairing::{CurveAffine, CurveProjective, Engine, Field};
use rand::{ChaChaRng, OsRng, Rand, Rng, SeedableRng};
use tiny_keccak::sha3_256;
@ -137,7 +145,7 @@ impl fmt::Debug for PublicKey {
impl PublicKey {
/// Returns `true` if the signature matches the element of `G2`.
pub fn verify_g2<H: Into<G2Affine>>(&self, sig: &Signature, hash: H) -> bool {
Bls12::pairing(self.0, hash) == Bls12::pairing(G1Affine::one(), sig.0)
PEngine::pairing(self.0, hash) == PEngine::pairing(G1Affine::one(), sig.0)
}
/// Returns `true` if the signature matches the message.
@ -190,7 +198,7 @@ impl PublicKeyShare {
pub fn verify_decryption_share(&self, share: &DecryptionShare, ct: &Ciphertext) -> bool {
let Ciphertext(ref u, ref v, ref w) = *ct;
let hash = hash_g1_g2(*u, v);
Bls12::pairing(share.0, hash) == Bls12::pairing((self.0).0, *w)
PEngine::pairing(share.0, hash) == PEngine::pairing((self.0).0, *w)
}
/// Returns a byte string representation of the public key share.
@ -530,7 +538,7 @@ impl Ciphertext {
pub fn verify(&self) -> bool {
let Ciphertext(ref u, ref v, ref w) = *self;
let hash = hash_g1_g2(*u, v);
Bls12::pairing(G1Affine::one(), *w) == Bls12::pairing(*u, hash)
PEngine::pairing(G1Affine::one(), *w) == PEngine::pairing(*u, hash)
}
}

View File

@ -24,7 +24,7 @@ use std::{cmp, iter, ops};
use errno::errno;
use memsec::{memzero, mlock, munlock};
use pairing::bls12_381::{Fr, G1, G1Affine};
use super::{Fr, G1, G1Affine};
use pairing::{CurveAffine, CurveProjective, Field};
use rand::Rng;
@ -927,7 +927,7 @@ mod tests {
use super::{coeff_pos, BivarPoly, IntoFr, Poly};
use pairing::bls12_381::{Fr, G1Affine};
use super::{Fr, G1Affine};
use pairing::{CurveAffine, Field};
use rand;

View File

@ -152,7 +152,7 @@ pub mod field_vec {
#[cfg(test)]
mod tests {
use bincode;
use pairing::bls12_381::Bls12;
use super::super::PEngine;
use pairing::Engine;
use rand::{self, Rng};
@ -173,7 +173,7 @@ mod tests {
#[test]
fn vecs() {
let mut rng = rand::thread_rng();
let vecs: Vecs<Bls12> = Vecs {
let vecs: Vecs<PEngine> = Vecs {
curve_points: rng.gen_iter().take(10).collect(),
field_elements: rng.gen_iter().take(10).collect(),
};