Replace tiny_keccak with sha3 in Monero

This commit is contained in:
Luke Parker 2022-09-28 09:29:58 -04:00
parent fd48bbd15e
commit 49749d96a0
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
3 changed files with 5 additions and 9 deletions

2
Cargo.lock generated
View file

@ -4608,9 +4608,9 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
"sha3 0.10.5",
"subtle",
"thiserror",
"tiny-keccak",
"tokio",
"zeroize",
]

View file

@ -22,7 +22,7 @@ rand_distr = "0.4"
zeroize = { version = "1.3", features = ["zeroize_derive"] }
subtle = "2.4"
tiny-keccak = { version = "2", features = ["keccak"] }
sha3 = "0.10"
blake2 = { version = "0.10", optional = true }
curve25519-dalek = { version = "3", features = ["std"] }

View file

@ -17,7 +17,7 @@ use rand_core::{RngCore, CryptoRng};
use zeroize::{Zeroize, ZeroizeOnDrop};
use tiny_keccak::{Hasher, Keccak};
use sha3::{Digest, Keccak256};
use curve25519_dalek::{
constants::ED25519_BASEPOINT_TABLE,
@ -109,12 +109,8 @@ pub fn random_scalar<R: RngCore + CryptoRng>(rng: &mut R) -> Scalar {
Scalar::from_bytes_mod_order_wide(&r)
}
pub fn hash(data: &[u8]) -> [u8; 32] {
let mut keccak = Keccak::v256();
keccak.update(data);
let mut res = [0; 32];
keccak.finalize(&mut res);
res
pub(crate) fn hash(data: &[u8]) -> [u8; 32] {
Keccak256::digest(data).into()
}
/// Hash the provided data to a scalar via keccak256(data) % l.