homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.15k stars 764 forks source link

the difference and connection between Plaintext slots and PlaintextArray #24

Closed ldwaiwai closed 10 years ago

ldwaiwai commented 10 years ago

hi, I was read the Design and Implementation of a Homomorphic-Encryption Library.Yet I don't know it well the difference and connection between Plaintext slots and PlaintextArray. Is there some paper to help understand the concepts?

shaih commented 10 years ago

The PlaintextArray class is mostly useful for debugging, you can find examples of working with it in TestGeneral.cpp, and examples of working without it in some of the other Test... programs. A typical code fragment (not using PlaintextArray) would look like this:

  // ... Set the context, secretKey, and publicKey
  EncryptedArray ea(context);
  Ctxt c(publicKey);  //  a new empty ciphertext

  vector<long> v1;
  ea.random(v1); // random values in the slots
  v1[ea.size()-1] = 1;          // set the last plaintext slot to one
  ea.encrypt(c, publicKey, v1); // encrypt in c the integers from v1

  vector<long> v2;
  ea.decrypt(c, secretKey, v2); // decrypt c into v2