# CKKS

**CKKS**（Cheon-Kim-Kim-Song）是一种全同态加密方案，由千正熙（Jung Hee Cheon）、金安德烈（Andrey Kim）、金美兰（Miran Kim）和宋永洙（Yongsoo Song）在2017年亚洲密码学会议（ASIACRYPT 2017）上提出，可对加密的实数和复数进行近似算术运算<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup>。与BFV、BGV等返回精确模整数的精确方案不同，CKKS将加密噪声视为明文低位数字的一部分，因此解密得到的是具有预定精度的近似值<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup><sup> • </sup><sup>[2](https://eprint.iacr.org/2016/421.pdf)</sup>。这使其成为加密机器学习推理和实值统计的标准选择<sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 来源 | 《近似数算术的同态加密》，ASIACRYPT 2017，LNCS 10624，第409-437页，作者为千正熙、金安德烈、金美兰和宋永洙<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup> |
| 数据类型 | 定点（近似）实数和复数；原生支持加/减、乘法和SIMD批处理<sup>[4](https://www.frontiersin.org/journals/electronics/articles/10.3389/felec.2022.1091369/pdf)</sup> |
| 安全基础 | 环上带误差学习（RLWE）问题的困难性；密文是\( \mathbb{Z}_q[X]/(X^n+1) \)中的一对多项式<sup>[5](https://doi.org/10.1007/s10207-023-00747-2)</sup> |
| 精度保证 | 评估过程中的精度损失受电路深度约束，比未加密的近似算术至多再多损失一个比特<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup> |
| 自举 | 近似自举；Bossuat等人（EUROCRYPT 2021）报告称，对一个32768槽的密文进行自举需18秒，每槽摊销约0.55毫秒<sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup> |
| 主要库 | SEAL、HEAAN、OpenFHE、Lattigo、HElib、HEonGPU、FIDESlib<sup>[6](https://ckks.org/software/)</sup> |

## 方案原理

CKKS通过复典范嵌入将复数向量编码为特征为零的分圆环中的明文多项式，该嵌入是一种等距环同态，不会放大误差，因此明文精度在编码后得以保留<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup>。加密会在承载消息的有效数字之后的低位添加噪声；这种原本为安全性而添加的噪声被视为近似计算误差的一部分<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup>。

**重缩放。** 同态乘法会将明文尺度平方，因此每次乘法后CKKS执行一步重缩放，同时降低密文模数并将密文除以尺度，从而近似地将消息和噪声都除以尺度因子，并从模数链中丢弃一个模数<sup>[7](https://www.mdpi.com/2079-9292/15/11/2391)</sup>。由于重缩放，密文模数的比特大小随电路深度线性增长而非指数增长，且模数链中每次所需的重缩放都必须对应一个素数<sup>[1](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)</sup><sup> • </sup><sup>[8](https://upcommons.upc.edu/bitstreams/cb990669-a62a-47e1-8ded-fa6c79e57819/download)</sup>。

**参数。** 该方案的主要参数包括多项式次数\( N \)、密文模数\( q \)（由多个相乘的素数构成的链）以及缩放因子\( \Delta \)。它们共同决定安全性、可表示的精度、准确度和可达到的乘法深度：\( N \)设定格维度和\( N/2 \)个SIMD槽，模数链控制噪声预算和重缩放步数，\( \Delta \)设定初始量化误差以及误差在乘法下的传播方式<sup>[9](https://www.sciencedirect.com/science/article/abs/pii/S0377042726004395)</sup>。加法使误差线性增长，而乘法以乘积方式放大误差并主导误差增长；旋转和重线性化会进一步增加噪声<sup>[9](https://www.sciencedirect.com/science/article/abs/pii/S0377042726004395)</sup>。参数集依据HomomorphicEncryption.org发布的社区安全指南来选择<sup>[10](https://homomorphicencryption.org/security-guidelines/)</sup>。

## RNS变体

原始实现无法使用剩余数系统（RNS）分解或数论变换（NTT），而这两者是实用格密码学的核心优化。2018年，千正熙、韩、金安德烈、金美兰和宋永洙提出的全RNS变体引入了一种密文模数结构，允许对分圆多项式进行RNS分解，并在每个RNS分量上进行NTT转换，且仅使用64位字运算即可执行近似模数切换<sup>[11](https://eprint.iacr.org/2018/931)</sup>。在环维度32768下，与早期实现相比，其解密速度提升了17.3倍，常数乘法提升了6.4倍，同态乘法提升了8.3倍；在575个加密样本上的单核逻辑回归训练耗时1.8分钟，而此前四核上需3.5分钟<sup>[11](https://eprint.iacr.org/2018/931)</sup>。生产级CKKS使用一条NTT友好的素数链，每个素数大致等于尺度，重缩放将密文系数除以模数因子并逐分量舍入，因此并非精确地除以某一个素数<sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup><sup> • </sup><sup>[21](https://eprint.iacr.org/2020/1533.pdf)</sup>。

## 自举

自举刷新密文的噪声并恢复乘法深度，从而实现全同态（无深度限制）计算；在CKKS中该过程本身也是近似的<sup>[12](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/CKKS_BOOTSTRAPPING.md)</sup>。流程分为四个阶段：模数提升、CoeffsToSlots线性变换、用小角度正弦函数近似评估的近似模约简EvalMod，以及SlotsToCoeffs逆变换<sup>[12](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/CKKS_BOOTSTRAPPING.md)</sup>。OpenFHE还实现了一种两次迭代流程，对自举误差本身进行自举以提高精度<sup>[12](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/CKKS_BOOTSTRAPPING.md)</sup>。

自举开销在不同方案间差异显著：TFHE约10毫秒自举一个门，BGV/BFV需数秒到数分钟，CKKS每个密文需数十秒，不过每槽的摊销成本可能很小；将摊销值当作延迟来引用是一个常见错误<sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup>。GPU加速已大幅降低这一开销：一项2025年的微架构研究报告称，在RTX 5090上自举32768个复数仅需15.2毫秒，进一步算法优化后可降至12.8毫秒<sup>[13](https://arxiv.org/abs/2512.18345)</sup>。

## 与其他FHE方案的比较

CKKS在主要FHE方案中占据特定生态位。BFV和BGV执行带SIMD批处理的精确整数算术；TFHE和FHEW在单个比特上运算，具有快速可编程自举但无批处理；唯有CKKS原生处理近似实数和复数向量<sup>[4](https://www.frontiersin.org/journals/electronics/articles/10.3389/felec.2022.1091369/pdf)</sup><sup> • </sup><sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup>。其两次自举之间的乘法深度约为4到16层，而BGV/BFV约为10到20层，TFHE则无限制（配合自举）<sup>[3](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)</sup>。

基准测试表明权衡是双向的。在128位安全级别下对癌症RNA-seq数据集进行差异表达分析时，BFV在所有配置下的总延迟均比CKKS低3.5到7.5倍，而在\( N = 16384 \)时CKKS密文每样本小2.66倍<sup>[14](https://link.springer.com/article/10.1186/s12859-026-06609-7)</sup>。在相同工作负载的智能电表聚合基准测试中，CKKS反而表现出更低的加密延迟（6.65毫秒对7.77毫秒）、更低的解密延迟（1.90毫秒对2.52毫秒）、更低的内存占用（975.99 MB对1030.93 MB）以及接近机器级的精度（\( 5.91 \times 10^{-10} \)对BFV的\( 3.21 \times 10^{-3} \)）<sup>[15](https://www.mdpi.com/2410-387X/10/5/63)</sup>。对于比较操作，CKKS的近似精度取决于无法降低的密文噪声，因此只能正确执行少数几次连续比较，这一点不同于TFHE和BGV/BFV<sup>[16](https://petsymposium.org/popets/2021/popets-2021-0046.pdf)</sup>。

## 应用

CKKS是加密实值推理的主导方案。一项在MNIST上对基于CKKS的多层感知机推理进行深度2到8的系统性基准测试发现，只要层级预算充足，加密推理的准确率相较明文推理下降不超过1.2%，而每样本延迟跨越两个数量级以上，从深度2的3.2秒到深度8的228秒；层级数少于网络深度的配置无条件失败<sup>[17](https://www.sciencedirect.com/science/article/pii/S1877050926030206)</sup>。在医疗AI领域，一项范围综述发现CKKS是对实值传感器和图像数据（包括基于CNN的医学图像分类）进行加密推理时使用最多的方案<sup>[18](https://doi.org/10.1007/s44163-026-00920-1)</sup>。研究人员还将其扩展到大语言模型：基于CKKS的Llama-2-7B隐私推理端到端实现可处理多达4096个输入词元，其中最后128个被加密<sup>[19](https://arxiv.org/abs/2601.18511)</sup>。CryptoLab研究人员在NIST研讨会上的报告展示了基于FHE的视觉Transformer训练在车辆分类应用中约需4分钟，推理仅需0.2秒<sup>[20](https://csrc.nist.gov/presentations/2024/wpec2024-2b3)</sup>。

## References

1. [Cheon, Kim, Kim, Song (2017). Homomorphic Encryption for Arithmetic of Approximate Numbers. ASIACRYPT 2017, LNCS 10624, pp. 409-437.](https://snu.elsevierpure.com/en/publications/homomorphic-encryption-for-arithmetic-of-approximate-numbers/)
2. [Cheon, Kim, Kim, Song (2016). Homomorphic Encryption for Arithmetic of Approximate Numbers (preprint). IACR ePrint 2016/421.](https://eprint.iacr.org/2016/421.pdf)
3. [CKKS Lab, Crypto Lab collection (comparison tables and bootstrapping costs).](https://systemslibrarian.github.io/crypto-lab-ckks-lab/)
4. [Zheng et al. (2022). Comparison of FHE schemes. Frontiers in Electronics.](https://www.frontiersin.org/journals/electronics/articles/10.3389/felec.2022.1091369/pdf)
5. [Secure outsourcing of manufacturing compliance checks. International Journal of Information Security (2023).](https://doi.org/10.1007/s10207-023-00747-2)
6. [CKKS.org software directory.](https://ckks.org/software/)
7. [Parameter Settings and Efficient Computation for Homomorphic Encryption in CKKS. Electronics 15(11):2391 (2025).](https://www.mdpi.com/2079-9292/15/11/2391)
8. [CKKS multiplicative depth and rescaling, Universitat Politècnica de Catalunya thesis (2025).](https://upcommons.upc.edu/bitstreams/cb990669-a62a-47e1-8ded-fa6c79e57819/download)
9. [Parallel and memory-efficient homomorphically encrypted CNNs using vector and tensor representations. Journal of Computational and Applied Mathematics.](https://www.sciencedirect.com/science/article/abs/pii/S0377042726004395)
10. [Security Guidelines, HomomorphicEncryption.org.](https://homomorphicencryption.org/security-guidelines/)
11. [Cheon, Han, Kim, Kim, Song (2018). A Full RNS Variant of Approximate Homomorphic Encryption. IACR ePrint 2018/931.](https://eprint.iacr.org/2018/931)
12. [OpenFHE Library - CKKS Bootstrapping documentation.](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/CKKS_BOOTSTRAPPING.md)
13. [Theodosian: A Deep Dive into Memory-Hierarchy-Centric FHE Acceleration. arXiv:2512.18345.](https://arxiv.org/abs/2512.18345)
14. [Privacy-preserving differential expression analysis via fully homomorphic encryption: a systematic tradeoff evaluation of BFV and CKKS on cancer RNA-seq datasets. BMC Bioinformatics (2026).](https://link.springer.com/article/10.1186/s12859-026-06609-7)
15. [A Hierarchical Benchmarking Framework for Homomorphic Encryption-Based Aggregation and Validation Using Real Smart Meter Data. Cryptography 10(5):63 (2026).](https://www.mdpi.com/2410-387X/10/5/63)
16. [Faster homomorphic comparison operations for BGV and BFV. PoPETs 2021(4).](https://petsymposium.org/popets/2021/popets-2021-0046.pdf)
17. [Benchmarking Fully Homomorphic Encryption for Deep Neural Network Inference: A Systematic Study of CKKS Parameter Trade-offs. Procedia Computer Science 290 (2026), pp. 192-199.](https://www.sciencedirect.com/science/article/pii/S1877050926030206)
18. [Homomorphic encryption for secure healthcare artificial intelligence. Discover Artificial Intelligence (2026).](https://doi.org/10.1007/s44163-026-00920-1)
19. [Scaling up Privacy-Preserving ML: A CKKS Implementation of Llama-2-7B. arXiv:2601.18511.](https://arxiv.org/abs/2601.18511)
20. [WPEC 2024 Talk 2b3: Practical performance of CKKS and encrypted training and inference for classification. NIST CSRC.](https://csrc.nist.gov/presentations/2024/wpec2024-2b3)
21. [eprint.iacr.org](https://eprint.iacr.org/2020/1533.pdf)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Database security, privacy, and law › Database encryption and cryptographic protection

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/ckks

English original: https://www.edgepedia.org/ckks
