From 28dbc2a21bf174f4b0b5792416c69fa7805d57b9 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Fri, 9 Aug 2024 11:10:11 +0200 Subject: [PATCH] node-data: change `Fault` hash algo to SHA3 Resolves #2081 --- node-data/src/ledger/faults.rs | 2 +- node-data/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/node-data/src/ledger/faults.rs b/node-data/src/ledger/faults.rs index 4da51ad0a3..b5f09abbc7 100644 --- a/node-data/src/ledger/faults.rs +++ b/node-data/src/ledger/faults.rs @@ -69,7 +69,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 { diff --git a/node-data/src/lib.rs b/node-data/src/lib.rs index 53927bc807..ad348f246b 100644 --- a/node-data/src/lib.rs +++ b/node-data/src/lib.rs @@ -11,8 +11,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, @@ -77,7 +75,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[..]) }