diff --git a/src/into_fr.rs b/src/into_fr.rs index ad09d79..9ff3897 100644 --- a/src/into_fr.rs +++ b/src/into_fr.rs @@ -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`. diff --git a/src/lib.rs b/src/lib.rs index 9bdc274..05ba9ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,16 @@ use std::ptr::copy_nonoverlapping; use byteorder::{BigEndian, ByteOrder}; use init_with::InitWith; -use pairing::bls12_381::{Bls12, Fr, G1Affine, G2Affine, G1, G2}; +use memsec::{memzero, mlock, munlock}; + +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; @@ -93,7 +102,7 @@ impl fmt::Debug for PublicKey { impl PublicKey { /// Returns `true` if the signature matches the element of `G2`. pub fn verify_g2>(&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. @@ -156,7 +165,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. @@ -529,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) } } diff --git a/src/poly.rs b/src/poly.rs index 0760554..2c8758c 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -22,7 +22,9 @@ use std::hash::{Hash, Hasher}; use std::mem::size_of_val; use std::{cmp, iter, ops}; -use pairing::bls12_381::{Fr, G1Affine, G1}; +use super::{Fr, G1Affine, G1}; +use errno::errno; +use memsec::{memzero, mlock, munlock}; use pairing::{CurveAffine, CurveProjective, Field}; use rand::Rng; @@ -931,7 +933,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; diff --git a/src/serde_impl.rs b/src/serde_impl.rs index ae1f5fd..caaa869 100644 --- a/src/serde_impl.rs +++ b/src/serde_impl.rs @@ -196,8 +196,8 @@ pub mod field_vec { #[cfg(test)] mod tests { + use super::super::PEngine; use bincode; - use pairing::bls12_381::Bls12; use pairing::Engine; use rand::{self, Rng}; @@ -220,7 +220,7 @@ mod tests { #[test] fn vecs() { let mut rng = rand::thread_rng(); - let vecs: Vecs = Vecs { + let vecs: Vecs = Vecs { curve_points: rng.gen_iter().take(10).collect(), field_elements: rng.gen_iter().take(10).collect(), };