Skip to content

Commit

Permalink
fix: use all refresh msgs for combining new keyshares (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub authored Oct 11, 2023
1 parent be6242e commit 448296d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
3 changes: 1 addition & 2 deletions fs-dkr/src/add_party_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ impl<E: Curve, H: Digest + Clone, const M: usize> JoinMessage<E, H, M> {
party_index,
&parameters,
&paillier_key.ek,
current_t,
);
let new_share = Paillier::decrypt(&paillier_key.dk, cipher_text_sum)
.0
Expand All @@ -244,7 +243,7 @@ impl<E: Curve, H: Digest + Clone, const M: usize> JoinMessage<E, H, M> {

#[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();
Expand Down
29 changes: 12 additions & 17 deletions fs-dkr/src/refresh_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,37 +217,33 @@ impl<E: Curve, H: Digest + Clone, const M: usize> RefreshMessage<E, H, M> {
party_index: u16,
parameters: &'a ShamirSecretSharing,
ek: &'a EncryptionKey,
current_t: u16,
) -> (RawCiphertext<'a>, Vec<Scalar<E>>) {
// 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<u16> = (0..refresh_messages.len())
.map(|i| refresh_messages[i].old_party_index - 1)
.collect();

let indices: Vec<u16> = (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::<E, sha2::Sha256>::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,
Expand Down Expand Up @@ -412,7 +408,6 @@ impl<E: Curve, H: Digest + Clone, const M: usize> RefreshMessage<E, H, M> {
local_key.i,
&local_key.vss_scheme.parameters,
&old_ek,
current_t,
);

for refresh_message in refresh_messages.iter() {
Expand Down Expand Up @@ -515,7 +510,7 @@ impl<E: Curve, H: Digest + Clone, const M: usize> RefreshMessage<E, H, M> {
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();
Expand Down

0 comments on commit 448296d

Please sign in to comment.