diff --git a/fs-dkr/src/add_party_message.rs b/fs-dkr/src/add_party_message.rs index ca01beb..62455cf 100644 --- a/fs-dkr/src/add_party_message.rs +++ b/fs-dkr/src/add_party_message.rs @@ -221,7 +221,6 @@ impl JoinMessage { party_index, ¶meters, &paillier_key.ek, - current_t, ); let new_share = Paillier::decrypt(&paillier_key.dk, cipher_text_sum) .0 @@ -244,7 +243,7 @@ impl JoinMessage { #[allow(clippy::needless_range_loop)] for i in 0..new_n as usize { - for j in 1..(current_t + 1) as usize { + for j in 1..refresh_messages.len() { pk_vec[i] = pk_vec[i].clone() + refresh_messages[j].points_committed_vec[i].clone() * li_vec[j].clone(); diff --git a/fs-dkr/src/refresh_message.rs b/fs-dkr/src/refresh_message.rs index 4cb31e3..ce89a7e 100644 --- a/fs-dkr/src/refresh_message.rs +++ b/fs-dkr/src/refresh_message.rs @@ -217,37 +217,33 @@ impl RefreshMessage { party_index: u16, parameters: &'a ShamirSecretSharing, ek: &'a EncryptionKey, - current_t: u16, ) -> (RawCiphertext<'a>, Vec>) { - // TODO: check we have large enough qualified set , at least t+1 - //decrypt the new share // we first homomorphically add all ciphertext encrypted using our // encryption key - let ciphertext_vec: Vec<_> = (0..refresh_messages.len()) - .map(|k| { - refresh_messages[k].points_encrypted_vec - [(party_index - 1) as usize] - .clone() - }) + let indices: Vec = (0..refresh_messages.len()) + .map(|i| refresh_messages[i].old_party_index - 1) .collect(); - let indices: Vec = (0..(current_t + 1) as usize) - .map(|i| refresh_messages[i].old_party_index - 1) + let ciphertext_vec: Vec<_> = refresh_messages + .iter() + .map(|msg| { + msg.points_encrypted_vec[(party_index - 1) as usize].clone() + }) .collect(); // optimization - one decryption - let li_vec: Vec<_> = (0..current_t as usize + 1) + let li_vec: Vec<_> = indices + .iter() .map(|i| { VerifiableSS::::map_share_to_new_params( parameters.clone().borrow(), - indices[i], + *i, &indices, ) }) .collect(); - let ciphertext_vec_at_indices_mapped: Vec<_> = (0..(current_t + 1) - as usize) + let ciphertext_vec_at_indices_mapped: Vec<_> = (0..indices.len()) .map(|i| { Paillier::mul( ek, @@ -412,7 +408,6 @@ impl RefreshMessage { local_key.i, &local_key.vss_scheme.parameters, &old_ek, - current_t, ); for refresh_message in refresh_messages.iter() { @@ -515,7 +510,7 @@ impl RefreshMessage { refresh_messages[0].points_committed_vec[i].clone() * li_vec[0].clone(), ); - for j in 1..current_t as usize + 1 { + for j in 1..refresh_messages.len() { local_key.pk_vec[i] = local_key.pk_vec[i].clone() + refresh_messages[j].points_committed_vec[i].clone() * li_vec[j].clone();