Skip to content

Commit

Permalink
Merge pull request #1607 from subspace/replace-evaluation-seed-deriva…
Browse files Browse the repository at this point in the history
…tion-function

Replace evaluation seed derivation function according to update spec
  • Loading branch information
nazar-pc authored Jun 29, 2023
2 parents c0ca66c + 1e30e6b commit e856404
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions crates/subspace-core-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod tests;
extern crate alloc;

use crate::crypto::kzg::{Commitment, Witness};
use crate::crypto::{blake2b_256_hash, blake2b_256_hash_with_key, Scalar};
use crate::crypto::{blake2b_256_hash, blake2b_256_hash_list, blake2b_256_hash_with_key, Scalar};
#[cfg(feature = "serde")]
use ::serde::{Deserialize, Serialize};
use core::convert::AsRef;
Expand Down Expand Up @@ -829,17 +829,11 @@ impl SectorId {

/// Derive evaluation seed
pub fn evaluation_seed(&self, piece_offset: PieceOffset, history_size: HistorySize) -> PosSeed {
let mut evaluation_seed = self.0;

for (output, input) in evaluation_seed.iter_mut().zip(piece_offset.to_bytes()) {
*output ^= input;
}
for (output, input) in evaluation_seed
.iter_mut()
.zip(history_size.get().to_le_bytes())
{
*output ^= input;
}
let evaluation_seed = blake2b_256_hash_list(&[
&self.0,
&piece_offset.to_bytes(),
&history_size.get().to_le_bytes(),
]);

PosSeed::from(evaluation_seed)
}
Expand Down

0 comments on commit e856404

Please sign in to comment.