我想旋转两个密文向量的乘积向量,但我得到一个错误,我不知道我应该如何尝试解决它。当我旋转一个密文向量时是正确的,但是当这个密文向量是一个产品时,就会发生错误。
int main() {
EncryptionParameters parms(scheme_type::BFV);
parms.set_poly_modulus_degree(poly_modulus_degree);
parms.set_coeff_modulus(CoeffModulus::BFVDefault(poly_modulus_degree));
parms.set_plain_modulus(PlainModulus::Batching(poly_modulus_degree, 20));
auto context = SEALContext::Create(parms);
KeyGenerator keygen(context);
PublicKey psk=keygen.public_key();
SecretKey sk=keygen.secret_key();
RelinKeys rlk=keygen.relin_keys();
GaloisKeys glk=keygen.galois_keys();
Encryptor encryptor(context, psk);
Decryptor decryptor(context, sk);
Evaluator evaluator(context);
BatchEncoder batch_encoder(context);
size_t slot_count = batch_encoder.slot_count();
size_t row_size = slot_count / 2;
mt19937 rnd(time(NULL));
vector<uint64_t> v(slot_count,0ull);
for(int i=0;i<1000;i++){
v[i]=rnd()%1000;
}
print_matrix(v,row_size);
Plaintext pr;
Ciphertext cr;
batch_encoder.encode(v,pr);
encryptor.encrypt(pr,cr);
evaluator.multiply_inplace(cr,cr);
decryptor.decrypt(cr,pr);
batch_encoder.decode(pr,v);
print_matrix(v,row_size);
//error:: what(): encrypted size must be 2
evaluator.rotate_rows(cr,pow(2,0),glk,cr);
return 0;
}