The mod function plays a critical role in numerous data encoding and cryptographic primitives. However, the widely used CKKS homomorphic encryption (HE) scheme supports only arithmetic operations, making it difficult to perform mod computations on encrypted data. Approximating the mod function with polynomials has therefore become an important yet challenging problem. Existing homomorphic mod constructions provide accurate results only within limited subranges of the input domain, leaving the problem of achieving accurate approximation across the entire input domain unresolved.In this work, we propose a novel method based on polynomial interpolation and Chebyshev series to accurately approximate the mod function over all integer points in the bounded input interval. Building upon this, we design two efficient data packing schemes, BitStack and CRTStack, tailored for small-integer inputs in CKKS. These schemes significantly improve the utilization of the CKKS plaintext space and enable efficient ciphertext uploads. Furthermore, we apply the proposed HE mod function to implement a homomorphic rounding operation and a general transformation from additive secret shares to CKKS ciphertexts, achieving accurate ciphertext rounding and complete conversion from secret shares to CKKS ciphertexts. Experimental results demonstrate that our approach achieves high approximation accuracy (up to $10^{-8}$).
翻译:模函数在众多数据编码和密码学原语中扮演着关键角色。然而,广泛使用的CKKS同态加密方案仅支持算术运算,这使得在加密数据上执行模运算变得困难。因此,用多项式近似模函数已成为一个重要但具有挑战性的问题。现有的同态模构造仅在输入域的有限子范围内提供精确结果,而无法在整个输入域上实现精确近似的问题仍未解决。本文提出了一种基于多项式插值和切比雪夫级数的新方法,能够在有界输入区间内的所有整数点上精确近似模函数。在此基础上,我们针对CKKS中的小整数输入设计了两种高效的数据打包方案:BitStack和CRTStack。这些方案显著提高了CKKS明文空间的利用率,并实现了高效的密文上传。此外,我们将所提出的同态模函数应用于实现同态取整操作以及从加性秘密共享到CKKS密文的通用转换,从而实现了精确的密文取整和从秘密共享到CKKS密文的完全转换。实验结果表明,我们的方法达到了高近似精度(高达$10^{-8}$)。