diff --git a/node-data/src/ledger/faults.rs b/node-data/src/ledger/faults.rs index 4da51ad0a3..960ffc0357 100644 --- a/node-data/src/ledger/faults.rs +++ b/node-data/src/ledger/faults.rs @@ -21,7 +21,6 @@ use execution_core::{ MultisigSignature as BlsMultisigSignature, }, stake::EPOCH, - BlsScalar, }; use thiserror::Error; use tracing::error; @@ -69,7 +68,7 @@ impl Fault { pub fn hash(&self) -> [u8; 32] { let mut b = vec![]; self.write(&mut b).expect("Write to a vec shall not fail"); - BlsScalar::hash_to_scalar(&b[..]).to_bytes() + sha3::Sha3_256::digest(&b[..]).into() } pub fn same(&self, other: &Fault) -> bool { @@ -87,26 +86,20 @@ impl Fault { match self { Fault::DoubleCandidate(a, b) => { let seed = Candidate::SIGN_SEED; - let a = BlsScalar::hash_to_scalar(&a.get_signed_data(seed)[..]) - .to_bytes(); - let b = BlsScalar::hash_to_scalar(&b.get_signed_data(seed)[..]) - .to_bytes(); + let a = sha3::Sha3_256::digest(a.get_signed_data(seed)).into(); + let b = sha3::Sha3_256::digest(b.get_signed_data(seed)).into(); (a, b) } Fault::DoubleRatificationVote(a, b) => { let seed = Ratification::SIGN_SEED; - let a = BlsScalar::hash_to_scalar(&a.get_signed_data(seed)[..]) - .to_bytes(); - let b = BlsScalar::hash_to_scalar(&b.get_signed_data(seed)[..]) - .to_bytes(); + let a = sha3::Sha3_256::digest(a.get_signed_data(seed)).into(); + let b = sha3::Sha3_256::digest(b.get_signed_data(seed)).into(); (a, b) } Fault::DoubleValidationVote(a, b) => { let seed = Validation::SIGN_SEED; - let a = BlsScalar::hash_to_scalar(&a.get_signed_data(seed)[..]) - .to_bytes(); - let b = BlsScalar::hash_to_scalar(&b.get_signed_data(seed)[..]) - .to_bytes(); + let a = sha3::Sha3_256::digest(a.get_signed_data(seed)).into(); + let b = sha3::Sha3_256::digest(b.get_signed_data(seed)).into(); (a, b) } } diff --git a/node-data/src/lib.rs b/node-data/src/lib.rs index b59b0d2829..3c217fd584 100644 --- a/node-data/src/lib.rs +++ b/node-data/src/lib.rs @@ -12,8 +12,6 @@ pub mod message; use std::io::{self, Read, Write}; -use ledger::Hash; - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum StepName { Proposal = 0, @@ -78,7 +76,7 @@ pub trait Serializable { } } -impl Serializable for Hash { +impl Serializable for [u8; N] { fn write(&self, w: &mut W) -> io::Result<()> { w.write_all(&self[..]) }