CKKS:How to extract each element in the plaintext to a variable

  Plaintext serverPlaintext;
  serverCC->Decrypt(serverKP.secretKey, serverCiphertext, &serverPlaintext);
  serverPlaintext->SetLength(batchSize);
  return (double)serverPlaintext[0];

The code is as above, I want to extract each element in the decrypted plaintext vector, but simple subscripts cannot. Is there any way to do it? My mother tongue is not English, please excuse any mistakes.

Like the following

  Plaintext serverPlaintext;
  serverCC->Decrypt(serverKP.secretKey, serverCiphertext, &serverPlaintext);
  serverPlaintext->SetLength(batchSize);

  auto myVec = serverPlaintext->GetX(); // <-------- What you're looking for

Where GetX depends on your scheme

  • CKKS: GetCKKSPackedValue, which returns a vector of complex values
  • CKKS: GetRealPackedValue, which returns a vector of real values
  • BFV/ BGV: GetPackedValue, which returns a vector of ints
1 Like