Replace ring with tiny-keccak.
This commit is contained in:
parent
4c533e6873
commit
2d17d0e783
|
@ -18,9 +18,9 @@ log = "0.4.1"
|
|||
pairing = { version = "0.14.2", features = ["u128-support"] }
|
||||
rand = "0.4.2"
|
||||
rand_derive = "0.3.1"
|
||||
ring = "^0.12"
|
||||
serde = "1.0.55"
|
||||
serde_derive = "1.0.55"
|
||||
tiny-keccak = "1.4"
|
||||
|
||||
[dev-dependencies]
|
||||
bincode = "1.0.0"
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -14,10 +14,10 @@ extern crate pairing;
|
|||
extern crate rand;
|
||||
#[macro_use]
|
||||
extern crate rand_derive;
|
||||
extern crate ring;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate tiny_keccak;
|
||||
|
||||
pub mod error;
|
||||
mod into_fr;
|
||||
|
@ -33,7 +33,7 @@ use init_with::InitWith;
|
|||
use pairing::bls12_381::{Bls12, Fr, G1, G1Affine, G2, G2Affine};
|
||||
use pairing::{CurveAffine, CurveProjective, Engine, Field};
|
||||
use rand::{ChaChaRng, OsRng, Rng, SeedableRng};
|
||||
use ring::digest;
|
||||
use tiny_keccak::sha3_256;
|
||||
|
||||
use error::{Error, Result};
|
||||
use into_fr::IntoFr;
|
||||
|
@ -445,7 +445,7 @@ impl SecretKeySet {
|
|||
|
||||
/// Returns a hash of the given message in `G2`.
|
||||
fn hash_g2<M: AsRef<[u8]>>(msg: M) -> G2 {
|
||||
let digest = digest::digest(&digest::SHA256, msg.as_ref());
|
||||
let digest = sha3_256(msg.as_ref());
|
||||
let seed = <[u32; CHACHA_RNG_SEED_SIZE]>::init_with_indices(|i| {
|
||||
BigEndian::read_u32(&digest.as_ref()[(4 * i)..(4 * i + 4)])
|
||||
});
|
||||
|
@ -458,8 +458,7 @@ fn hash_g1_g2<M: AsRef<[u8]>>(g1: G1, msg: M) -> G2 {
|
|||
// If the message is large, hash it, otherwise copy it.
|
||||
// TODO: Benchmark and optimize the threshold.
|
||||
let mut msg = if msg.as_ref().len() > 64 {
|
||||
let digest = digest::digest(&digest::SHA256, msg.as_ref());
|
||||
digest.as_ref().to_vec()
|
||||
sha3_256(msg.as_ref()).to_vec()
|
||||
} else {
|
||||
msg.as_ref().to_vec()
|
||||
};
|
||||
|
@ -469,7 +468,7 @@ fn hash_g1_g2<M: AsRef<[u8]>>(g1: G1, msg: M) -> G2 {
|
|||
|
||||
/// Returns a hash of the group element with the specified length in bytes.
|
||||
fn hash_bytes(g1: G1, len: usize) -> Vec<u8> {
|
||||
let digest = digest::digest(&digest::SHA256, g1.into_affine().into_compressed().as_ref());
|
||||
let digest = sha3_256(g1.into_affine().into_compressed().as_ref());
|
||||
let seed = <[u32; CHACHA_RNG_SEED_SIZE]>::init_with_indices(|i| {
|
||||
BigEndian::read_u32(&digest.as_ref()[(4 * i)..(4 * i + 4)])
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue