1

有没有一种简单的方法来计算使用 PolyCRTBuilder 组成并加密的密文的平均值。

这是代码片段:

EncryptionParameters parms;
parms.set_poly_modulus("1x^4096 + 1");
parms.set_coeff_modulus(coeff_modulus_128(4096));
parms.set_plain_modulus(40961);
SEALContext context(parms);
print_parameters(context);
KeyGenerator keygen(context);
auto public_key = keygen.public_key();
// auto secret_key = keygen.secret_key();

Encryptor encryptor(context, public_key);
Evaluator evaluator(context);
// Decryptor decryptor(context, secret_key);

PolyCRTBuilder crtbuilder(context);

int slot_count = crtbuilder.slot_count();
int row_size = slot_count / 2;

vector<uint64_t> pod_matrix(slot_count, 0);
pod_matrix[0] = 5;
pod_matrix[1] = 2;
pod_matrix[2] = 56;
pod_matrix[3] = 34;
pod_matrix[row_size] = 47;
pod_matrix[row_size + 1] = 35;
pod_matrix[row_size + 2] = 16;
pod_matrix[row_size + 3] = 37;

Plaintext plain_matrix;
crtbuilder.compose(pod_matrix, plain_matrix);

Ciphertext encrypted_matrix;

encryptor.encrypt(plain_matrix, encrypted_matrix);

// Is there a way to compute the MEAN of encrypted_matrix and return one ciphertext that is the mean.
// I am trying to not use the secret key

基本上我有一个数组,我使用 SEAL 中的批处理技术将所有数组元素打包成一个密文。创建密文后,我需要找到密文数组的平均值。平均值应该是密文 (IntegerEncoded or FractionalEncoded) 。有没有办法在不使用密钥的情况下实现这一点?谢谢你。

4

1 回答 1

1

您需要首先总结您使用的所有批处理槽中的值。这总是可以log(degree(poly_modulus))通过将密文旋转 0、1、2、4、8……槽并在每次旋转后求和来逐步完成。对于最后一步,您还需要总结两行,因此您需要进行列旋转。您最终会得到一个密文,其中每个插槽都包含值的总和。在这种情况下,解密后的明文多项式将只是一个常数多项式,因此请确保您的plain_modulus值足够大以包含总和。

对于批量大小的划分,也许您可​​以在解密后进行,但也许最好的选择是使用 CKKS 方案(在 SEAL 3.0 中),在这种方案中,这样的密文逐明文划分很容易。

于 2018-10-17T19:04:30.950 回答