Skip to content

Commit

Permalink
adds hash domain to merkle shreds
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Jan 25, 2023
1 parent 77c45f0 commit 3b45f24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ledger/src/shred/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ 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];
const MERKLE_HASH_PREFIX_LEAF: &[u8] = b"\x00SOLANA_MERKLE_SHREDS_LEAF";
const MERKLE_HASH_PREFIX_NODE: &[u8] = b"\x01SOLANA_MERKLE_SHREDS_NODE";

pub(crate) type MerkleRoot = MerkleProofEntry;
type MerkleProofEntry = [u8; 20];
Expand Down
4 changes: 1 addition & 3 deletions ledger/src/shredder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Field>;

pub struct ReedSolomonCache(
Mutex<LruCache<(/*data_shards:*/ usize, /*parity_shards:*/ usize), Arc<ReedSolomon>>>,
);
Expand Down

0 comments on commit 3b45f24

Please sign in to comment.