Skip to content

Commit

Permalink
Semi Honest Threshold Decryption (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycscaly authored Jan 8, 2024
1 parent 16558f0 commit 20e25e8
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/decryption_key_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,23 @@ impl DecryptionKeyShare {
}
}

pub fn generate_decryption_shares(
pub fn generate_decryption_shares_semi_honest(
&self,
ciphertexts: Vec<PaillierModulusSizedNumber>,
rng: &mut impl CryptoRngCore,
) -> Result<Message> {
) -> Result<Vec<PaillierModulusSizedNumber>> {
let (_, decryption_shares) =
self.generate_decryption_shares_semi_honest_internal(ciphertexts)?;

Ok(decryption_shares)
}

fn generate_decryption_shares_semi_honest_internal(
&self,
ciphertexts: Vec<PaillierModulusSizedNumber>,
) -> Result<(
Vec<PaillierModulusSizedNumber>,
Vec<PaillierModulusSizedNumber>,
)> {
let n2 = self.encryption_key.n2;

#[cfg(not(feature = "parallel"))]
Expand All @@ -111,7 +123,7 @@ impl DecryptionKeyShare {
#[cfg(feature = "parallel")]
let iter = decryption_share_bases.par_iter();

let decryption_shares: Vec<PaillierModulusSizedNumber> = iter
let decryption_shares = iter
.map(|decryption_share_base| {
// $ c_i = c^{2n!d_i} $
decryption_share_base
Expand All @@ -127,6 +139,19 @@ impl DecryptionKeyShare {
})
.collect();

Ok((decryption_share_bases, decryption_shares))
}

pub fn generate_decryption_shares(
&self,
ciphertexts: Vec<PaillierModulusSizedNumber>,
rng: &mut impl CryptoRngCore,
) -> Result<Message> {
let n2 = self.encryption_key.n2;

let (decryption_share_bases, decryption_shares) =
self.generate_decryption_shares_semi_honest_internal(ciphertexts)?;

let decryption_shares_and_bases: Vec<(
PaillierModulusSizedNumber,
PaillierModulusSizedNumber,
Expand Down

0 comments on commit 20e25e8

Please sign in to comment.