Microsoft SEAL:在减去两个 PolyCRT 组成的密文后的结果需要负值

Microsoft SEAL : Required negative values as a result after subtraction of two PolyCRT composed ciphertexts

假设我有两个向量x = [1,2,3,4] and y = [5,1,2,6]

我使用 PolyCRTBuilder(Ciphertextx 和 Ciphertexty)组合并加密了两个数组。

如果我减去两个密文 ( Ciphertextx MINUS Ciphertexty ),我应该得到 Result = [-4, 1, 1, -2] 但在同态减法之后我得到 ResultDecrypted = [40957, 1, 1, 40959]

我了解到,因为明文仅定义为模 plain_modulus,所以我们得到了那个结果。但是我希望将得到的负值用于下一次计算我怎样才能将得到的负值分配给一个向量并将其用于进一步的计算

如果 SEAL 仍有 PolyCRTBuilder,则说明您使用的是相当旧的 SEAL 版本;在较新版本的库中,它已重命名为 BatchEncoder 并且它支持编码 to/from std::vector<std::int64_t>,我相信这就是您想要的。