Skip to content

Commit 55a3e08

Browse files
jpraynaudAlenar
authored andcommitted
Fix party id collisions in fixture builder
1 parent e28d2a6 commit 55a3e08

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

mithril-common/src/entities/mithril_stake_distribution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod tests {
7070

7171
use super::*;
7272

73-
const EXPECTED_HASH: &str = "093b4b8044c9b0f33ed678ac34096f4d5071768c8804bf98e9f239af0bbbfeeb";
73+
const EXPECTED_HASH: &str = "47675a6fad57040b194655b103bc0439ff9d6920a7ba86bd53756db7ce2952f5";
7474

7575
#[test]
7676
fn test_compute_hash() {

mithril-common/src/test_utils/fixture_builder.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,13 @@ impl MithrilFixtureBuilder {
151151
party_index: usize,
152152
kes_key_seed: &mut [u8],
153153
) -> PartyId {
154-
let cold_key_seed: Vec<u8> = self
155-
.party_id_seed
154+
let mut cold_key_seed: Vec<u8> = (party_index)
155+
.to_le_bytes()
156156
.iter()
157-
.copied()
158-
.map(|s| {
159-
s.saturating_mul(self.number_of_signers as u8)
160-
.saturating_add(party_index as u8)
161-
})
157+
.zip(self.party_id_seed)
158+
.map(|(v1, v2)| v1 + v2)
162159
.collect();
160+
cold_key_seed.resize(32, 0);
163161
let keypair =
164162
ColdKeyGenerator::create_deterministic_keypair(cold_key_seed.try_into().unwrap());
165163
let mut dummy_buffer = [0u8; Sum6Kes::SIZE + 4];

0 commit comments

Comments
 (0)