Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/contrib' into 3.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei Dai committed Jun 15, 2021
2 parents af9d300 + 16f40b4 commit cb96d43
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions native/src/seal/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,21 +842,16 @@ namespace seal
// Set up iterators for input ciphertext
auto encrypted_iter = iter(encrypted);

// Allocate temporary space for the result
SEAL_ALLOCATE_ZERO_GET_POLY_ITER(temp, dest_size, coeff_count, coeff_modulus_size, pool);

// Compute c0^2
dyadic_product_coeffmod(encrypted_iter[0], encrypted_iter[0], coeff_modulus_size, coeff_modulus, temp[0]);
// Compute c1^2
dyadic_product_coeffmod(
encrypted_iter[1], encrypted_iter[1], coeff_modulus_size, coeff_modulus, encrypted_iter[2]);

// Compute 2*c0*c1
dyadic_product_coeffmod(encrypted_iter[0], encrypted_iter[1], coeff_modulus_size, coeff_modulus, temp[1]);
add_poly_coeffmod(temp[1], temp[1], coeff_modulus_size, coeff_modulus, temp[1]);

// Compute c1^2
dyadic_product_coeffmod(encrypted_iter[1], encrypted_iter[1], coeff_modulus_size, coeff_modulus, temp[2]);
dyadic_product_coeffmod(encrypted_iter[0], encrypted_iter[1], coeff_modulus_size, coeff_modulus, encrypted_iter[1]);
add_poly_coeffmod(encrypted_iter[1], encrypted_iter[1], coeff_modulus_size, coeff_modulus, encrypted_iter[1]);

// Set the final result
set_poly_array(temp, dest_size, coeff_count, coeff_modulus_size, encrypted.data());
// Compute c0^2
dyadic_product_coeffmod(encrypted_iter[0], encrypted_iter[0], coeff_modulus_size, coeff_modulus, encrypted_iter[0]);

// Set the scale
encrypted.scale() = new_scale;
Expand Down

0 comments on commit cb96d43

Please sign in to comment.