Skip to content

Conversation

@Yanbin-Li-Oct
Copy link

Overview

This PR implements enhanced CKKS bootstrapping functionality based on the papers "Efficient Bootstrapping for Approximate Homomorphic Encryption with Non-Sparse Keys" (https://eprint.iacr.org/2020/1203.pdf) and "Better bootstrapping for approximate homomorphic encryption" (https://eprint.iacr.org/2019/688.pdf). The changes include new operator functions, improved bootstrapping algorithms, and support for non-sparse secret keys.


Functional Enhancements

1. New Bootstrapping Implementation

  • regular_bootstrapping_v2(): Implements efficient bootstrapping with non-sparse key support and improved precision
  • mod_up_from_q0(): Fixes modulus raising from Q₀ to full Q, and adds optional key switching between dense and sparse keys
  • coeff_to_slot_v2(), slot_to_coeff_v2(): Update BSGS (Baby-Step Giant-Step) algorithm for transformation matrices based on configurable BSGS ratio
  • eval_mod(): Computes modular reduction using range-reduced Chebyshev approximation of cos(2^(-r)(x - 0.5)) with optimally-placed interpolation nodes, followed by r double-angle iterations. Implements errorless and depth-optimal polynomial evaluation.

2. New Utility Functions

  • Complex arithmetic operations:
    • mult_i(), div_i(): Efficient imaginary unit operations without consuming modulus levels
  • Enhanced plaintext operations:
    • add_plain_v2(): Adds complex constant to ciphertext using Gaussian integer addition. Employs NTL big integer library for overflow-safe
      scaling, computes accurate per-modulus RNS representation.
    • multiply_plain_v2(): Multiplies ciphertext by complex constant with automatic precision preservation for fractional parts (scales by prime modulus when needed), employs NTL library for overflow-safe Gaussian integer multiplication
    • scale_up(): Wrapper around multiply_plain_v2() for real-only scaling, commonly used in bootstrapping to adjust ciphertext scale factors

3. Key Generation Support

  • generate_secret_key_v2(): Collision-free secret key generation with exact Hamming weight control using CPU-side Fisher-Yates shuffle algorithm
  • Switch key generation: Support for dense-to-sparse and sparse-to-dense key conversions

Testing and Examples

4. New Example Program

  • example/bootstrapping/5_ckks_regular_bootstrapping_v2.cu: Demonstrates the new regular_bootstrapping_v2() function with non-sparse keys

Key Benefits

  • Removes sparse key constraints for bootstrapping operations, complies with the most recent security recommendations
  • Preserves more modulus levels, enabling deeper homomorphic computation circuits after refresh, and reducing the frequency of costly bootstrapping operations

Performance

  • Runtime: About ~277 ms on NVIDIA GeForce RTX 3090 (poly_modulus_degree = 2^16)
  • Precision: Achieves ~17-18 bits average precision (log₂ scale) after bootstrapping

…ping for Approximate Homomorphic Encryption with Non-Sparse Keys"
@Alisah-Ozcan
Copy link
Owner

Hi, thanks for PR, I will review it and let you know.

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