mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 05:59:23 +00:00
Remove sender_i from DkgShares
It was a piece of duplicated data used to achieve context-less de)serialization. This new Vec code is a bit tricker to first read, yet overall clean and removes a potential fault. Saves 2 bytes from DkgShares messages.
This commit is contained in:
@@ -160,18 +160,17 @@ async fn dkg_test() {
|
||||
for (k, key) in keys.iter().enumerate() {
|
||||
let attempt = 0;
|
||||
|
||||
let mut shares = HashMap::new();
|
||||
let mut shares = vec![];
|
||||
for i in 0 .. keys.len() {
|
||||
if i != k {
|
||||
let mut share = vec![0; 256];
|
||||
OsRng.fill_bytes(&mut share);
|
||||
shares.insert(Participant::new((i + 1).try_into().unwrap()).unwrap(), share);
|
||||
shares.push(share);
|
||||
}
|
||||
}
|
||||
|
||||
let mut tx = Transaction::DkgShares {
|
||||
attempt,
|
||||
sender_i: Participant::new((k + 1).try_into().unwrap()).unwrap(),
|
||||
shares,
|
||||
confirmation_nonces: crate::tributary::dkg_confirmation_nonces(key, &spec),
|
||||
signed: Transaction::empty_signed(),
|
||||
@@ -219,10 +218,15 @@ async fn dkg_test() {
|
||||
.enumerate()
|
||||
.filter_map(|(l, tx)| {
|
||||
if let Transaction::DkgShares { shares, .. } = tx {
|
||||
shares
|
||||
.get(&Participant::new((i + 1).try_into().unwrap()).unwrap())
|
||||
.cloned()
|
||||
.map(|share| (Participant::new((l + 1).try_into().unwrap()).unwrap(), share))
|
||||
if i == l {
|
||||
None
|
||||
} else {
|
||||
let relative_i = i - (if i > l { 1 } else { 0 });
|
||||
Some((
|
||||
Participant::new((l + 1).try_into().unwrap()).unwrap(),
|
||||
shares[relative_i].clone(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
panic!("txs had non-shares");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user