Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Feb 26, 2024
1 parent 762ac67 commit f0e61fe
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 278 deletions.
2 changes: 1 addition & 1 deletion ferveo-tdec/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<E: Pairing> PrivateDecryptionContextSimple<E> {
.collect::<Vec<_>>();
let lagrange_coeffs = prepare_combine_simple::<E>(&domain);

DecryptionSharePrecomputed::new(
DecryptionSharePrecomputed::create(
self.index,
&self.setup_params.b,
&self.private_key_share,
Expand Down
14 changes: 13 additions & 1 deletion ferveo-tdec/src/decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ impl<E: Pairing> ValidatorShareChecksum<E> {
}
}

/// A decryption share for a simple variant of the threshold decryption scheme.
/// In this variant, the decryption share require additional computation on the
/// client side int order to be combined.
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DecryptionShareSimple<E: Pairing> {
Expand Down Expand Up @@ -141,6 +144,11 @@ impl<E: Pairing> DecryptionShareSimple<E> {
}
}

/// A decryption share for a precomputed variant of the threshold decryption scheme.
/// In this variant, the decryption share is precomputed and can be combined
/// without additional computation on the client side.
/// The downside is that the threshold of decryption shares required to decrypt
/// is equal to the number of private key shares in the scheme.
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DecryptionSharePrecomputed<E: Pairing> {
Expand All @@ -155,7 +163,9 @@ pub struct DecryptionSharePrecomputed<E: Pairing> {
}

impl<E: Pairing> DecryptionSharePrecomputed<E> {
pub fn new(
/// Create a decryption share from the given parameters.
/// This function checks that the ciphertext is valid.
pub fn create(
validator_index: usize,
validator_decryption_key: &E::ScalarField,
private_key_share: &PrivateKeyShare<E>,
Expand All @@ -174,6 +184,8 @@ impl<E: Pairing> DecryptionSharePrecomputed<E> {
)
}

/// Create a decryption share from the given parameters.
/// This function does not check that the ciphertext is valid.
pub fn create_unchecked(
validator_index: usize,
validator_decryption_key: &E::ScalarField,
Expand Down
Loading

0 comments on commit f0e61fe

Please sign in to comment.