-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CKKS Composite Scaling #910
Open
Comments
This was
linked to
pull requests
Jan 3, 2025
dsuponitskiy
pushed a commit
that referenced
this issue
Jan 14, 2025
* Initial commit: adding composite scaling parameters and scaling tech mode. * Initial commit: adding composite scaling parameters and scaling tech mode. * Some review changes. * Update composite scaling unittests and fix unittest runtime issue. * Move COMPOSITESCALING support error handling. * Disable composite scaling set methods for non-CKKS schemes. * Removing additional constructor that accepts composite scaling parameters.
dsuponitskiy
pushed a commit
that referenced
this issue
Feb 14, 2025
…phase 2) (#929) * Initial commit: adding composite scaling parameters and scaling tech mode. * Initial commit: adding composite scaling parameters and scaling tech mode. * Composite prime generation and adaptive scaling factors. * Propagating composite degree to mod reduce calls. * Handling overflow for scaling factors over 64 bits on composite scaling mode. * Bug fix of overflow handling for d > 2 and sc > 64. * Update impl of Rescale and Mod/LevelReduce methods with composite degree. * Minor bug fix: else case missing. * Update EvalPoly functions to use composite degree. * Update Compress function to raise error. * Update/Add new composite scaling examples. * Recalculate sizeP and update EstimateLogP interface. * Update composite-prime generation function. * Remove comments from prime gen function. * Update composite scaling unittests and fix unittest runtime issue. * Some review changes. * Update composite scaling unittests and fix unittest runtime issue. * Disable composite scaling set methods for non-CKKS schemes. * Move COMPOSITESCALING support error handling. * Disable composite scaling set methods for non-CKKS schemes. * Removing additional constructor that accepts composite scaling parameters. * Review changes for PR 910 phase 2. * Review updates and fixes. * Review updates and fixes. * Review updates and fixes.
dsuponitskiy
pushed a commit
that referenced
this issue
Mar 11, 2025
* Initial commit: adding composite scaling parameters and scaling tech mode. * Initial commit: adding composite scaling parameters and scaling tech mode. * Composite prime generation and adaptive scaling factors. * Propagating composite degree to mod reduce calls. * Handling overflow for scaling factors over 64 bits on composite scaling mode. * Bug fix of overflow handling for d > 2 and sc > 64. * Update impl of Rescale and Mod/LevelReduce methods with composite degree. * Minor bug fix: else case missing. * Update EvalPoly functions to use composite degree. * Update Compress function to raise error. * Update/Add new composite scaling examples. * Recalculate sizeP and update EstimateLogP interface. * Updated CKKS bootstrapping for composite scaling with examples. * Update error conditions. * Update poly evaluation example. * Tweak error condition regarding prime moduli size. * Update composite-prime generation function. * Remove comments from prime gen function. * Update composite scaling unittests and fix unittest runtime issue. * Some review changes. * Update composite scaling unittests and fix unittest runtime issue. * Disable composite scaling set methods for non-CKKS schemes. * Move COMPOSITESCALING support error handling. * Disable composite scaling set methods for non-CKKS schemes. * Removing additional constructor that accepts composite scaling parameters. * Review changes for PR 910 phase 2. * Review updates and fixes. * Review updates and fixes. * Review updates and fixes. * Update error message. * Update error message. * Code improvements * Avoid infinite loop in next prime sampling. * Fix decryption failed bug. * Replace std::round(std::log2()) by std::frexp to get bit size of qDouble. * Update error message. * Code improvements --------- Co-authored-by: Dmitriy Suponitskiy <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CKKS Composite Scaling
This issue concerns the implementation of the composite scaling technique for CKKS presented in https://eprint.iacr.org/2023/1462.pdf. It enables high-precision RNS-CKKS when the hardware architecture word size is smaller than the scaling factor.
The enablement of the composite scaling CKKS as a feature into the OpenFHE library:
CKKS composite scaling is designed to achieve high-precision RNS-CKKS encrypted computation with scaling factors greater than the target hardware architecture's register word size. For example, with composite scaling, we can configure the RNS scaling factor to be 58 bits, i.e. choosing prime moduli with 58 bits of precision, and compute on an accelerator whose architecture's register size is 32 bits. This feature is introduced into the OpenFHE API as a new scaling technique. This new scaling technique mode is architected into 4 Pull Requests, each of which entails specific parts of the composite scaling technique enablement, as depicted in the diagram below. This includes generating composite prime moduli, where each level is represented by the product of
d
primes that fit in XX-bit registers (e.g., 32-bit registers), andd
is greater than or equal to 2, known as the composite degree. Our new mode also extends its support to both the conventional bootstrapping algorithm and the most recently proposed Meta-BTS bootstrapping algorithm.It is introduced as a new scaling technique in OpenFHE. There are two ways to enable CKKS composite scaling:
By setting the scaling technique to COMPOSITESCALINGAUTO: This is the most suitable choice for any developer trying out or not familiar with the intricate details of composite scaling.
By setting the scaling technique to COMPOSITESCALINGMANUAL: This mode is meant for developers that wish to experiment with untested/unlikely combinations of composite scaling parameters that may only be functional under special circumstances. In those special cases, the program may be more sensitive to runtime errors due to insufficient availability of prime moduli for given certain values for the tuple <register word size, multiplicative depth, ring size>.
Composite Modulus Chain Generation
All prime moduli are NTT-friendly (tested up to 2^16).
All primes in the modulus chain are distinct from each other.
q_i = p_1 x ... x p_ d ~ 2 ^\delta
, where\delta
is the scaling factor,q_i
is the composite coefficient modulus comprised of the prime moduli{p_1, ..., p_d}
, andd
is the composite degree that characterizes the composite scaling approach.p_i
is chosen to be very close2^( (scalingModSize) / (composite degree) )
Composite Scaling Bootstrapping
Current implementation supports single-iteration CKKS bootstrapping.
Current implementation supports Meta-BTS (or multiple-iteration) CKKS bootstrapping.
Current Constraints
This current CKKS composite scaling implementation only supports single-key CKKS.
By design when operating on composite scaling mode (i.e., COMPOSITESCALINGAUTO), the target hardware platform is assumed to have fixed word size smaller than 64 bits. However, in general, it still works under the scenario where scaling factors greater than 64 bits running on hardware architectures having 64-bit register word size (this capability is still under refactoring).
Regardless of the target architecture word size, the OpenFHE library needs to be compiled using NATIVEINT=64 compilation flag.
COMPOSITESCALING<AUTO/MANUAL> scaling technique mode only works with the CKKS scheme.
The secret key distribution needs to be set to UNIFORM_TERNARY.
The text was updated successfully, but these errors were encountered: