Implement optimized bootstrapping algorithm from eprint.iacr.org/2020/1203 #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 precisionmod_up_from_q0(): Fixes modulus raising from Q₀ to full Q, and adds optional key switching between dense and sparse keyscoeff_to_slot_v2(),slot_to_coeff_v2(): Update BSGS (Baby-Step Giant-Step) algorithm for transformation matrices based on configurable BSGS ratioeval_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
mult_i(),div_i(): Efficient imaginary unit operations without consuming modulus levelsadd_plain_v2(): Adds complex constant to ciphertext using Gaussian integer addition. Employs NTL big integer library for overflow-safescaling, 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 multiplicationscale_up(): Wrapper aroundmultiply_plain_v2()for real-only scaling, commonly used in bootstrapping to adjust ciphertext scale factors3. Key Generation Support
generate_secret_key_v2(): Collision-free secret key generation with exact Hamming weight control using CPU-side Fisher-Yates shuffle algorithmTesting and Examples
4. New Example Program
example/bootstrapping/5_ckks_regular_bootstrapping_v2.cu: Demonstrates the newregular_bootstrapping_v2()function with non-sparse keysKey Benefits
Performance