From edfbb2557c6e68cf1990a43006eb3c5d0efdb8ce Mon Sep 17 00:00:00 2001 From: Akilesh Tangella Date: Sat, 22 Oct 2022 15:42:15 -0400 Subject: [PATCH] Akilesh/cggmp work edits to make cggmp work with fs-dkr (#9) --- src/refresh_message.rs | 13 +++++++------ src/test.rs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/refresh_message.rs b/src/refresh_message.rs index 0233b9e..66eb85d 100644 --- a/src/refresh_message.rs +++ b/src/refresh_message.rs @@ -26,6 +26,7 @@ use zk_paillier::zkproofs::{DLogStatement, NiCorrectKeyProof, SALT_STRING}; // Everything here can be broadcasted #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RefreshMessage { + pub(crate) old_party_index: u16, pub(crate) party_index: u16, pdl_proof_vec: Vec>, range_proofs: Vec>, @@ -43,6 +44,7 @@ pub struct RefreshMessage { impl RefreshMessage { pub fn distribute( + old_party_index: u16, local_key: &mut LocalKey, new_n: u16, ) -> FsDkrResult<(RefreshMessage, DecryptionKey)> { @@ -113,6 +115,7 @@ impl RefreshMessage { Ok(( RefreshMessage { + old_party_index, party_index: local_key.i, pdl_proof_vec, range_proofs, @@ -189,12 +192,10 @@ impl RefreshMessage { .map(|k| refresh_messages[k].points_encrypted_vec[(party_index - 1) as usize].clone()) .collect(); - let mut indices: Vec = (0..(parameters.threshold + 1) as usize) - .map(|i| refresh_messages[i].party_index - 1) + let indices: Vec = (0..(parameters.threshold + 1) as usize) + .map(|i| refresh_messages[i].old_party_index - 1) .collect(); - indices.sort(); - // optimization - one decryption let li_vec: Vec<_> = (0..parameters.threshold as usize + 1) .map(|i| { @@ -299,11 +300,11 @@ impl RefreshMessage { ); } } - + let old_party_index = key.i; key.i = *old_to_new_map.get(&key.i).unwrap(); key.n = new_n; - RefreshMessage::distribute(key, new_n as u16) + RefreshMessage::distribute(old_party_index, key, new_n as u16) } pub fn collect( diff --git a/src/test.rs b/src/test.rs index 5a3b7f8..b798bac 100644 --- a/src/test.rs +++ b/src/test.rs @@ -231,7 +231,7 @@ mod tests { // TODO: Verify this is correct let new_n = keys.len() as u16; for key in keys.iter_mut() { - let (refresh_message, new_dk) = RefreshMessage::distribute(key, new_n).unwrap(); + let (refresh_message, new_dk) = RefreshMessage::distribute(key.i, key, new_n).unwrap(); refresh_messages.push(refresh_message.clone()); new_dks.insert(refresh_message.party_index.into(), new_dk); party_key.insert(refresh_message.party_index.into(), key.clone()); @@ -300,7 +300,7 @@ mod tests { let keys_len = keys.len(); for key in keys.iter_mut() { let (refresh_message, new_dk) = - RefreshMessage::distribute(key, keys_len as u16).unwrap(); + RefreshMessage::distribute(key.i, key, keys_len as u16).unwrap(); broadcast_vec.push(refresh_message); new_dks.push(new_dk); }