Microsoft SEAL是一个同态加密库,它允许在加密的整数或实数上执行加法和乘法。
SEAL提供了两种机制的同态加密,BFV
和CKKS
。SEAL采用的同态加密算法基于RLWE,其中有几个重要的参数:
polynomial modulus
coefficient modulus
plaintext modulus (只在BFV机制中)
其中polynomial modulus
和max coefficient modulus bit-length
有一个对应关系,示例代码中给出了对应关系,比如1024 对应27,8192对应218。SEAL提供了默认设置的函数,其中polynomial modulus
是必须设置的。
① 选择CKKS参数 parms
② 生成CKKS框架 context
③ 构建CKKS模块 keygenerator
,encoder
,encryptor
,evaluator
和decryptor
④ 使用encoder
将 数据n
编码为 明文m
⑤ 使用encryptor
将 明文m
加密为 密文c
⑥ 使用evaluator
对 密文c
运算为 密文c’
⑦ 使用decryptor
将 密文c’
解密为 明文m’
⑧ 使用encoder
将 明文m’
解码为 数据n’