From aa6073bee8007b396a50cb2b47c830490173ae27 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 23:34:28 +0000 Subject: [PATCH] v1.15: adds hash domain to merkle shreds (backport of #29339) (#30346) adds hash domain to merkle shreds (#29339) (cherry picked from commit 06bb71c79fca73ebbf3a2d4bbbc87890adc4e9c7) Co-authored-by: behzad nouri --- ledger/src/shred/merkle.rs | 6 ++++-- ledger/src/shredder.rs | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ledger/src/shred/merkle.rs b/ledger/src/shred/merkle.rs index 179388b4fb7b70..10646edd39fae8 100644 --- a/ledger/src/shred/merkle.rs +++ b/ledger/src/shred/merkle.rs @@ -41,8 +41,10 @@ const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 1203); // Defense against second preimage attack: // https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack -const MERKLE_HASH_PREFIX_LEAF: &[u8] = &[0x00]; -const MERKLE_HASH_PREFIX_NODE: &[u8] = &[0x01]; +// Following Certificate Transparency, 0x00 and 0x01 bytes are prepended to +// hash data when computing leaf and internal node hashes respectively. +const MERKLE_HASH_PREFIX_LEAF: &[u8] = b"\x00SOLANA_MERKLE_SHREDS_LEAF"; +const MERKLE_HASH_PREFIX_NODE: &[u8] = b"\x01SOLANA_MERKLE_SHREDS_NODE"; type MerkleProofEntry = [u8; 20]; diff --git a/ledger/src/shredder.rs b/ledger/src/shredder.rs index 6c1e6b0b4c6e64..9ef0a68fdc5c08 100644 --- a/ledger/src/shredder.rs +++ b/ledger/src/shredder.rs @@ -7,7 +7,7 @@ use { lru::LruCache, rayon::{prelude::*, ThreadPool}, reed_solomon_erasure::{ - galois_8::Field, + galois_8::ReedSolomon, Error::{InvalidIndex, TooFewDataShards, TooFewShardsPresent}, }, solana_entry::entry::Entry, @@ -38,8 +38,6 @@ pub(crate) const ERASURE_BATCH_SIZE: [usize; 33] = [ 55, 56, 58, 59, 60, 62, 63, 64, // 32 ]; -type ReedSolomon = reed_solomon_erasure::ReedSolomon; - pub struct ReedSolomonCache( Mutex>>, );