Skip to content

Optimize homomorphic encryption (precomputations and other optimizations)#30

Draft
jellevos wants to merge 4 commits into
masterfrom
optimize-he
Draft

Optimize homomorphic encryption (precomputations and other optimizations)#30
jellevos wants to merge 4 commits into
masterfrom
optimize-he

Conversation

@jellevos

@jellevos jellevos commented May 6, 2022

Copy link
Copy Markdown
Owner

Paillier:

  • Precomputed n_squared
  • Sample r from [0, n) instead of generating a random coprime to n_squared

@JSAbrahams JSAbrahams left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just passing by

/// ```
fn generate_keys<R: SecureRng>(&self, rng: &mut GeneralRng<R>) -> (PaillierPK, PaillierSK) {
let (n, lambda) = gen_rsa_modulus(self.modulus_size, rng);
let (n, lambda, _, _) = gen_rsa_modulus(self.modulus_size, rng);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually use .. shorthand here: let (n, lambda, ..) =


/// Compresses the precomputed secret key to a smaller format without precomputations
pub fn compress(self) -> CompressedRsaSK {
CompressedRsaSK {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool rust feature, you can use ...self shorthand in cases like this
CompressedRsaSK { ...self }
But this is a draft so i'm guessing this method isn't complete ofc

fn decrypt_raw(&self, public_key: &PK, ciphertext: &PK::Ciphertext) -> PK::Plaintext;

/// Uses both the secret material from the decryption key and the encryption key to encrypt faster than with only the encryption key.
/// This method is always implemented, but it defaults to simply encrypting without the secret key.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe I misunderstand, but if this is a trait, is there a need to specify that this method is always implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants