HEaaN
Crypto Lab's great homomorphic encryption library
|
A class consisting of basic operation of Ciphertext and Message. More...
#include <HomEvaluator.hpp>
Public Member Functions | |
HomEvaluator (const Context &context, const std::string &key_dir_path) | |
HomEvaluator (const Context &context, const KeyPack &pack) | |
void | negate (const Message &msg, Message &msg_out) const |
Negate a Message. More... | |
void | negate (const Plaintext &ptxt, Plaintext &ptxt_out) const |
Negate a Plaintext. More... | |
void | negate (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Negate a Ciphertext. More... | |
void | add (const Message &msg1, const Complex &cnst_complex, Message &msg_out) const |
Message + Complex Constant. More... | |
void | add (const Message &msg1, const Message &msg2, Message &msg_out) const |
Message + Message. More... | |
void | add (const Plaintext &ptxt1, const Complex &cnst_complex, Plaintext &ptxt_out) const |
Plaintext + Complex Constant. More... | |
void | add (const Plaintext &ptxt1, const Plaintext &ptxt2, Plaintext &ptxt_out) const |
Plaintext + Plaintext. More... | |
void | add (const Ciphertext &ctxt1, const Complex &cnst_complex, Ciphertext &ctxt_out) const |
Ciphertext + Complex Constant. More... | |
void | add (const Ciphertext &ctxt1, const Message &msg2, Ciphertext &ctxt_out) const |
Ciphertext + Message. More... | |
void | add (const Ciphertext &ctxt1, const Plaintext &ptxt2, Ciphertext &ctxt_out) const |
Ciphertext + Plaintext. More... | |
void | add (const Ciphertext &ctxt1, const Ciphertext &ctxt2, Ciphertext &ctxt_out) const |
Ciphertext + Ciphertext. More... | |
void | sub (const Message &msg1, const Complex &cnst_complex, Message &msg_out) const |
Message - Complex Constant. More... | |
void | sub (const Message &msg1, const Message &msg2, Message &msg_out) const |
Message - Message. More... | |
void | sub (const Plaintext &ptxt1, const Complex &cnst_complex, Plaintext &ptxt_out) const |
Plaintext - Complex Constant. More... | |
void | sub (const Plaintext &ptxt1, const Plaintext &ptxt2, Plaintext &ptxt_out) const |
Plaintext - Plaintext. More... | |
void | sub (const Ciphertext &ctxt1, const Complex &cnst_complex, Ciphertext &ctxt_out) const |
Ciphertext - Complex Constant. More... | |
void | sub (const Ciphertext &ctxt1, const Message &msg2, Ciphertext &ctxt_out) const |
Ciphertext - Message. More... | |
void | sub (const Ciphertext &ctxt1, const Plaintext &ptxt2, Ciphertext &ctxt_out) const |
Ciphertext - Plaintext. More... | |
void | sub (const Ciphertext &ctxt1, const Ciphertext &ctxt2, Ciphertext &ctxt_out) const |
Ciphertext - Ciphertext. More... | |
void | mult (const Message &msg1, const Complex &cnst_complex, Message &msg_out) const |
Message * Complex Constant. More... | |
void | mult (const Message &msg1, const Message &msg2, Message &msg_out) const |
Message * Message. More... | |
void | mult (const Plaintext &ptxt1, const Plaintext &ptxt2, Plaintext &ptxt_out) const |
Plaintext * Plaintext. More... | |
void | mult (const Plaintext &ptxt1, const Complex &cnst_complex, Plaintext &ptxt_out) const |
Plaintext * Complex Constant. More... | |
void | mult (const Ciphertext &ctxt1, const Complex &cnst_complex, Ciphertext &ctxt_out) const |
Ciphertext * Complex Constant. More... | |
void | mult (const Ciphertext &ctxt1, const Message &msg2, Ciphertext &ctxt_out) const |
Ciphertext * Message. More... | |
void | mult (const Ciphertext &ctxt1, const Plaintext &ptxt2, Ciphertext &ctxt_out) const |
Ciphertext * Plaintext. More... | |
void | mult (const Ciphertext &ctxt1, const Ciphertext &ctxt2, Ciphertext &ctxt_out) const |
Ciphertext * Ciphertext. More... | |
void | multImagUnit (const Message &msg, Message &msg_out) const |
multiply a Message by the imaginary unit √(-1) More... | |
void | multImagUnit (const Plaintext &ptxt, Plaintext &ptxt_out) const |
multiply a Plaintext by the imaginary unit √(-1) More... | |
void | multImagUnit (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
multiply a Ciphertext by the imaginary unit √(-1) More... | |
void | multInteger (const Plaintext &ptxt, u64 cnst_integer, Plaintext &ptxt_out) const |
Plaintext * Positive Integer. More... | |
void | multInteger (const Ciphertext &ctxt, u64 cnst_integer, Ciphertext &ctxt_out) const |
Ciphertext * Positive Integer. More... | |
void | square (const Message &msg, Message &msg_out) const |
Compute the square of a Message. More... | |
void | square (const Plaintext &ptxt, Plaintext &ptxt_out) const |
Compute the square of a Plaintext. More... | |
void | square (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Compute the square of a Ciphertext. More... | |
void | leftRotate (const Message &msg, u64 rot, Message &msg_out) const |
Rotate components of Message by rot. More... | |
void | leftRotate (const Plaintext &ptxt, u64 rot, Plaintext &ptxt_out) const |
Rotate components of the message which Plaintext encodes by rot. More... | |
void | leftRotate (const Ciphertext &ctxt, u64 rot, Ciphertext &ctxt_out) const |
Rotate components of the message which Ciphertext encrypts by rot. More... | |
void | rightRotate (const Message &msg, u64 rot, Message &msg_out) const |
Rotate components of Message by rot. More... | |
void | rightRotate (const Plaintext &ptxt, u64 rot, Plaintext &ptxt_out) const |
Rotate components of the message which Ciphertext encrypts by rot. More... | |
void | rightRotate (const Ciphertext &ctxt, u64 rot, Ciphertext &ctxt_out) const |
Rotate components of the message which Ciphertext encrypts by rot. More... | |
void | rotSum (const std::vector< Ciphertext > &ctxt, const std::vector< u64 > &rot_idx, Ciphertext &ctxt_out) const |
Compute Σ rot_i (ctxt_i) More... | |
void | leftRotateReduce (const Message &msg, const u64 &idx_interval, const u64 &num_summation, Message &msg_out) const |
Compute left Rotate Reduce of Message. More... | |
void | rightRotateReduce (const Message &msg, const u64 &idx_interval, const u64 &num_summation, Message &msg_out) const |
Compute right Rotate Reduce of Message. More... | |
void | leftRotateReduce (const Ciphertext &ctxt, const u64 &idx_interval, const u64 &num_summation, Ciphertext &ctxt_out) const |
Compute left Rotate Reduce of Ciphertext. More... | |
void | rightRotateReduce (const Ciphertext &ctxt, const u64 &idx_interval, const u64 &num_summation, Ciphertext &ctxt_out) const |
Compute right Rotate Reduce of Ciphertext. More... | |
void | conjugate (const Message &msg, Message &msg_out) const |
Compute complex conjugate a Message component-wise. More... | |
void | conjugate (const Plaintext &ptxt, Plaintext &ptxt_out) const |
Compute complex conjugate the message ptxt encodes. More... | |
void | conjugate (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Compute complex conjugate the message ctxt encrypts. More... | |
void | killImag (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Get the real part of the message which ctxt encrypts. More... | |
void | multWithoutRescale (const Ciphertext &ctxt1, const Complex &cnst_complex, Ciphertext &ctxt_out) const |
Multiply Ciphertext by a complex constant. More... | |
void | multWithoutRescale (const Ciphertext &ctxt1, const Plaintext &ptxt2, Ciphertext &ctxt_out) const |
Multiply Ciphertext and Plaintext. More... | |
void | multWithoutRescale (const Ciphertext &ctxt1, const Ciphertext &ctxt2, Ciphertext &ctxt_out) const |
Multiply two Ciphertext. More... | |
void | tensor (const Ciphertext &ctxt1, const Ciphertext &ctxt2, Ciphertext &ctxt_out) const |
Compute (a1b2 + a2b1, b1b2, a1a2) More... | |
void | relinearize (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Mult relinearization key. More... | |
void | rescale (Plaintext &ptxt) const |
Divide a Plaintext by the scale factor. More... | |
void | rescale (Ciphertext &ctxt) const |
Divide a Ciphertext by the scale factor. More... | |
void | inverseRescale (Plaintext &ptxt) const |
Increase one level and multiply the prime at current level + 1. More... | |
void | inverseRescale (Ciphertext &ctxt) const |
Increase one level and multiply the prime at current level + 1. More... | |
void | levelDown (const Ciphertext &ctxt, u64 target_level, Ciphertext &ctxt_out) const |
Decrease the level of Ciphertext. More... | |
void | levelDownOne (const Ciphertext &ctxt, Ciphertext &ctxt_out) const |
Decrease the level of Ciphertext by one. More... | |
void | relevel (const Plaintext &ptxt, const u64 target_level, Plaintext &ptxt_out) const |
Adjust the level of plaintext. More... | |
const Context & | getContext () const |
Get the internal Context object. More... | |
Private Attributes | |
const Context | context_ |
A context with which HomEvaluator is associated. More... | |
std::shared_ptr< HomEvaluatorImpl > | impl_ |
Internal implementation object. More... | |
Friends | |
class | BootstrapperImpl |
A class consisting of basic operation of Ciphertext and Message.
|
explicit |
void HEaaN::HomEvaluator::add | ( | const Ciphertext & | ctxt1, |
const Ciphertext & | ctxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ctxt2 | |
[out] | ctxt_out |
Add two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.
RuntimeException | if ctxt1 and ctxt2 have the different rescale counter |
void HEaaN::HomEvaluator::add | ( | const Ciphertext & | ctxt1, |
const Complex & | cnst_complex, | ||
Ciphertext & | ctxt_out | ||
) | const |
Ciphertext + Complex Constant.
[in] | ctxt1 | |
[in] | cnst_complex | |
[out] | ctxt_out |
Add cnst_complex to each component of the message which Ciphertext encrypts
RuntimeException | if ctxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::add | ( | const Ciphertext & | ctxt1, |
const Message & | msg2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | msg2 | |
[out] | ctxt_out |
Add msg2 to the message which ctxt1 encrypts. The result is a Ciphertext which encrypts the sum of those two messages.
void HEaaN::HomEvaluator::add | ( | const Ciphertext & | ctxt1, |
const Plaintext & | ptxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ptxt2 | |
[out] | ctxt_out |
Add Ciphertext and Plaintext. If the levels of ctxt1 and ptxt2 are different, we adjust the level.
void HEaaN::HomEvaluator::add | ( | const Message & | msg1, |
const Message & | msg2, | ||
Message & | msg_out | ||
) | const |
[in] | msg1 | |
[in] | msg2 | |
[out] | msg_out |
Add two Message component-wise
RuntimeException | if msg1 and msg2 have the different size |
void HEaaN::HomEvaluator::add | ( | const Plaintext & | ptxt1, |
const Complex & | cnst_complex, | ||
Plaintext & | ptxt_out | ||
) | const |
Plaintext + Complex Constant.
[in] | ptxt1 | |
[in] | cnst_complex | |
[out] | ptxt_out |
Add cnst_complex to each component of the message which Plaintext encodes
RuntimeException | if ptxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::add | ( | const Plaintext & | ptxt1, |
const Plaintext & | ptxt2, | ||
Plaintext & | ptxt_out | ||
) | const |
[in] | ptxt1 | |
[in] | ptxt2 | |
[out] | ptxt_out |
RuntimeException | if ptxt1 and ptxt2 have the different level or the different rescale counter |
void HEaaN::HomEvaluator::conjugate | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Compute complex conjugate the message ctxt encrypts.
[in] | ctxt | |
[out] | ctxt_out |
Compute complex conjugate a Message component-wise.
[in] | msg | |
[out] | msg_out |
Compute complex conjugate the message ptxt encodes.
[in] | ptxt | |
[out] | ptxt_out |
|
inline |
Get the internal Context object.
void HEaaN::HomEvaluator::inverseRescale | ( | Ciphertext & | ctxt | ) | const |
Increase one level and multiply the prime at current level + 1.
[in,out] | ctxt |
It transforms a ciphetext of a level ℓ encrypting a message m into a ciphertext of level ℓ+1 encrypting the message {q_{ℓ+1}} m. The rescale counter is increased by 1 after this operation. When you rotate/conjugate, you can put inverseRescale and rescale before and after such operation to reduce the error of the operation. Also, inverseRescale can be used to match the rescale counter and level of two ciphertexts.
RuntimeException | if the level of a ciphertext is greater than or equal to the maximum level. |
void HEaaN::HomEvaluator::inverseRescale | ( | Plaintext & | ptxt | ) | const |
Increase one level and multiply the prime at current level + 1.
[in,out] | ptxt |
It transforms a plaintext of a level ℓ encoding a message m into a plaintext of level ℓ+1 encoding the message {q_{ℓ+1}} m. The rescale counter is increased by 1 after this operation. When you encrypt, you can put inverseRescale before encryption to reduce the encryption error. Also, inverseRescale can be used to match the rescale counter and level of two plaintexts.
RuntimeException | if the level of a plaintext is greater than or equal to the maximum level. |
void HEaaN::HomEvaluator::killImag | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Get the real part of the message which ctxt encrypts.
[in] | ctxt | |
[out] | ctxt_out |
void HEaaN::HomEvaluator::leftRotate | ( | const Ciphertext & | ctxt, |
u64 | rot, | ||
Ciphertext & | ctxt_out | ||
) | const |
Rotate components of the message which Ciphertext encrypts by rot.
[in] | ctxt | |
[in] | rot | |
[out] | ctxt_out |
(m_0, m_1, ...) -> (m_r, m_r+1, ...)
Rotate components of Message by rot.
[in] | msg | |
[in] | rot | |
[out] | msg_out |
(m_0, m_1, ...) -> (m_r, m_r+1, ...)
void HEaaN::HomEvaluator::leftRotate | ( | const Plaintext & | ptxt, |
u64 | rot, | ||
Plaintext & | ptxt_out | ||
) | const |
Rotate components of the message which Plaintext encodes by rot.
[in] | ptxt | |
[in] | rot | |
[out] | ptxt_out |
(m_0, m_1, ...) -> (m_r, m_r+1, ...)
void HEaaN::HomEvaluator::leftRotateReduce | ( | const Ciphertext & | ctxt, |
const u64 & | idx_interval, | ||
const u64 & | num_summation, | ||
Ciphertext & | ctxt_out | ||
) | const |
Compute left Rotate Reduce of Ciphertext.
[in] | ctxt | |
[in] | idx_interval | |
[in] | num_summation | |
[out] | ctxt_out |
\( \sum_{idx} leftRotate(ctxt, idx) \) where \( {idx} \) = {0, i, ..., (n-1) * i}, i = idx_interval and n = num_summation.
void HEaaN::HomEvaluator::leftRotateReduce | ( | const Message & | msg, |
const u64 & | idx_interval, | ||
const u64 & | num_summation, | ||
Message & | msg_out | ||
) | const |
Compute left Rotate Reduce of Message.
[in] | msg | |
[in] | idx_interval | |
[in] | num_summation | |
[out] | msg_out |
\( \sum_{idx} leftRotate(msg, idx) \) where \( {idx} \) = {0, i, ..., (n-1) * i}, i = idx_interval and n = num_summation
void HEaaN::HomEvaluator::levelDown | ( | const Ciphertext & | ctxt, |
u64 | target_level, | ||
Ciphertext & | ctxt_out | ||
) | const |
Decrease the level of Ciphertext.
[in] | ctxt | |
[in] | target_level | |
[out] | ctxt_out |
RuntimeException | if target_level is greater than level of ctxt |
RuntimeException | if ctxt has nonzero rescale counter. |
void HEaaN::HomEvaluator::levelDownOne | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Decrease the level of Ciphertext by one.
[in] | ctxt | |
[out] | ctxt_out |
RuntimeException | if level of ctxt is zero |
RuntimeException | if ctxt has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Ciphertext & | ctxt1, |
const Ciphertext & | ctxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ctxt2 | |
[out] | ctxt_out |
Multiply two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.
RuntimeException | if any of the input operands has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Ciphertext & | ctxt1, |
const Complex & | cnst_complex, | ||
Ciphertext & | ctxt_out | ||
) | const |
Ciphertext * Complex Constant.
[in] | ctxt1 | |
[in] | cnst_complex | |
[out] | ctxt_out |
Multiply cnst_complex to each component of the message which Ciphertext encrypts. Note that if the input cnst_complex
is sufficiently close to a Gaussian integer (i.e. a complex number with integer real and imaginary parts), then the multiplication will take place via multInteger
, i.e. without any depth consumption. More precisely, "sufficiently close" here means that the absolute value of the difference of the real (resp. imaginary) part with its closest integer is less than or equal to 1e-8.
RuntimeException | if ctxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Ciphertext & | ctxt1, |
const Message & | msg2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | msg2 | |
[out] | ctxt_out |
Multiply msg2 to the message which ctxt1 encrypts The result is a Ciphertext which encrypts the product of those two messages.
RuntimeException | if ctxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Ciphertext & | ctxt1, |
const Plaintext & | ptxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ptxt2 | |
[out] | ctxt_out |
Multiply Ciphertext and Plaintext. If the levels of ctxt1 and ptxt2 are different, we adjust the level.
RuntimeException | if any of the input operands has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Message & | msg1, |
const Message & | msg2, | ||
Message & | msg_out | ||
) | const |
[in] | msg1 | |
[in] | msg2 | |
[out] | msg_out |
Multiply two Message component-wise
RuntimeException | if msg1 and msg2 have the different size |
void HEaaN::HomEvaluator::mult | ( | const Plaintext & | ptxt1, |
const Complex & | cnst_complex, | ||
Plaintext & | ptxt_out | ||
) | const |
Plaintext * Complex Constant.
[in] | ptxt1 | |
[in] | cnst_complex | |
[out] | ptxt_out |
Multiply cnst_complex to each component of the message which Plaintext encodes
RuntimeException | if ptxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::mult | ( | const Plaintext & | ptxt1, |
const Plaintext & | ptxt2, | ||
Plaintext & | ptxt_out | ||
) | const |
[in] | ptxt1 | |
[in] | ptxt2 | |
[out] | ptxt_out |
Multiply two Plaintext.
RuntimeException | if any of the input operands has nonzero rescale counter. |
void HEaaN::HomEvaluator::multImagUnit | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
multiply a Ciphertext by the imaginary unit √(-1)
[in] | ctxt | |
[out] | ctxt_out |
multiply a Message by the imaginary unit √(-1)
[in] | msg | |
[out] | msg_out |
multiply a Plaintext by the imaginary unit √(-1)
[in] | ptxt | |
[out] | ptxt_out |
void HEaaN::HomEvaluator::multInteger | ( | const Ciphertext & | ctxt, |
u64 | cnst_integer, | ||
Ciphertext & | ctxt_out | ||
) | const |
Ciphertext * Positive Integer.
[in] | ctxt | |
[in] | cnst_integer | |
[out] | ctxt_out |
void HEaaN::HomEvaluator::multInteger | ( | const Plaintext & | ptxt, |
u64 | cnst_integer, | ||
Plaintext & | ptxt_out | ||
) | const |
Plaintext * Positive Integer.
[in] | ptxt | |
[in] | cnst_integer | |
[out] | ptxt_out |
void HEaaN::HomEvaluator::multWithoutRescale | ( | const Ciphertext & | ctxt1, |
const Ciphertext & | ctxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
Multiply two Ciphertext.
[in] | ctxt1 | |
[in] | ctxt2 | |
[out] | ctxt_out |
There are no memory check. You should perform the rescale function.
RuntimeException | if ctxt1 and ctxt2 have the different level |
RuntimeException | if any of the input operands has nonzero rescale counter. |
void HEaaN::HomEvaluator::multWithoutRescale | ( | const Ciphertext & | ctxt1, |
const Complex & | cnst_complex, | ||
Ciphertext & | ctxt_out | ||
) | const |
Multiply Ciphertext by a complex constant.
[in] | ctxt1 | |
[in] | cnst_complex | |
[out] | ctxt_out |
There are no memory check.
void HEaaN::HomEvaluator::multWithoutRescale | ( | const Ciphertext & | ctxt1, |
const Plaintext & | ptxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
Multiply Ciphertext and Plaintext.
[in] | ctxt1 | |
[in] | ptxt2 | |
[out] | ctxt_out |
There are no memory check. You should perform the rescale function.
RuntimeException | if ctxt1 and ptxt2 must have the different level |
RuntimeException | if any of the input operands has nonzero rescale counter. |
void HEaaN::HomEvaluator::negate | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Negate a Ciphertext.
[in] | ctxt | |
[out] | ctxt_out |
Negate a Message.
[in] | msg | |
[out] | msg_out |
Negate a Plaintext.
[in] | ptxt | |
[out] | ptxt_out |
void HEaaN::HomEvaluator::relevel | ( | const Plaintext & | ptxt, |
const u64 | target_level, | ||
Plaintext & | ptxt_out | ||
) | const |
Adjust the level of plaintext.
[in] | ptxt | Input plaintext |
[in] | target_level | Target level |
[out] | ptxt_out |
RuntimeException | if target_level exceeds context->getMaxLevel() |
void HEaaN::HomEvaluator::relinearize | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Mult relinearization key.
[in] | ctxt | |
[out] | ctxt_out |
This is the latter part of multWithoutRescale function.
void HEaaN::HomEvaluator::rescale | ( | Ciphertext & | ctxt | ) | const |
Divide a Ciphertext by the scale factor.
[in,out] | ctxt |
It transforms a ciphertext of a level ℓ encrypting a message m into a ciphertext of level ℓ-1 encrypting the message {q_ℓ}^{-1} m.
RuntimeException | if ctxt has nonzero rescale counter. |
void HEaaN::HomEvaluator::rescale | ( | Plaintext & | ptxt | ) | const |
Divide a Plaintext by the scale factor.
[in,out] | ptxt |
It transforms a plaintext of a level ℓ encoding a message m into a plaintext of level ℓ-1 encoding the message {q_ℓ}^{-1} m.
RuntimeException | if ptxt has nonzero rescale counter. |
void HEaaN::HomEvaluator::rightRotate | ( | const Ciphertext & | ctxt, |
u64 | rot, | ||
Ciphertext & | ctxt_out | ||
) | const |
Rotate components of the message which Ciphertext encrypts by rot.
[in] | ctxt | |
[in] | rot | |
[out] | ctxt_out |
(m_0, m_1, ...) -> (..., m_0, m_1, ...)
Rotate components of Message by rot.
[in] | msg | |
[in] | rot | |
[out] | msg_out |
(m_0, m_1, ...) -> (..., m_0, m_1, ...)
void HEaaN::HomEvaluator::rightRotate | ( | const Plaintext & | ptxt, |
u64 | rot, | ||
Plaintext & | ptxt_out | ||
) | const |
Rotate components of the message which Ciphertext encrypts by rot.
[in] | ptxt | |
[in] | rot | |
[out] | ptxt_out |
(m_0, m_1, ...) -> (..., m_0, m_1, ...)
void HEaaN::HomEvaluator::rightRotateReduce | ( | const Ciphertext & | ctxt, |
const u64 & | idx_interval, | ||
const u64 & | num_summation, | ||
Ciphertext & | ctxt_out | ||
) | const |
Compute right Rotate Reduce of Ciphertext.
[in] | ctxt | |
[in] | idx_interval | |
[in] | num_summation | |
[out] | ctxt_out |
\( \sum_{idx} rightRotate(ctxt, idx) \) where \( {idx} \) = {0, i, ..., (n-1) * i}, i = idx_interval and n = num_summation.
void HEaaN::HomEvaluator::rightRotateReduce | ( | const Message & | msg, |
const u64 & | idx_interval, | ||
const u64 & | num_summation, | ||
Message & | msg_out | ||
) | const |
Compute right Rotate Reduce of Message.
[in] | msg | |
[in] | idx_interval | |
[in] | num_summation | |
[out] | msg_out |
\( \sum_{idx} rightRotate(msg, idx) \) where \( {idx} \) = {0, i, ..., (n-1) * i}, i = idx_interval and n = num_summation.
void HEaaN::HomEvaluator::rotSum | ( | const std::vector< Ciphertext > & | ctxt, |
const std::vector< u64 > & | rot_idx, | ||
Ciphertext & | ctxt_out | ||
) | const |
Compute Σ rot_i (ctxt_i)
[in] | ctxt | |
[in] | rot_idx | |
[out] | ctxt_out |
We suppose that all Ciphertext have the same level
void HEaaN::HomEvaluator::square | ( | const Ciphertext & | ctxt, |
Ciphertext & | ctxt_out | ||
) | const |
Compute the square of a Ciphertext.
[in] | ctxt | |
[out] | ctxt_out |
Compute the square of a Message.
[in] | msg | |
[out] | msg_out |
Compute the square of a Plaintext.
[in] | ptxt | |
[out] | ptxt_out |
void HEaaN::HomEvaluator::sub | ( | const Ciphertext & | ctxt1, |
const Ciphertext & | ctxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ctxt2 | |
[out] | ctxt_out |
Subtract two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.
RuntimeException | if ctxt1 and ctxt2 have the different rescale counter |
void HEaaN::HomEvaluator::sub | ( | const Ciphertext & | ctxt1, |
const Complex & | cnst_complex, | ||
Ciphertext & | ctxt_out | ||
) | const |
Ciphertext - Complex Constant.
[in] | ctxt1 | |
[in] | cnst_complex | |
[out] | ctxt_out |
Subtract cnst_complex from each slot of the message which Ciphertext encrypts
RuntimeException | if ctxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::sub | ( | const Ciphertext & | ctxt1, |
const Message & | msg2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | msg2 | |
[out] | ctxt_out |
Subtract msg2 from the message which ctxt1 encrypts The result is a Ciphertext which encrypts the difference of those two messages.
void HEaaN::HomEvaluator::sub | ( | const Ciphertext & | ctxt1, |
const Plaintext & | ptxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
[in] | ctxt1 | |
[in] | ptxt2 | |
[out] | ctxt_out |
Subtract ptxt2 from ctxt1. If the levels of ctxt1 and ptxt2 are different, we adjust the level.
void HEaaN::HomEvaluator::sub | ( | const Message & | msg1, |
const Message & | msg2, | ||
Message & | msg_out | ||
) | const |
[in] | msg1 | |
[in] | msg2 | |
[out] | msg_out |
Subtract two Message component-wise
RuntimeException | if msg1 and msg2 have the different size |
void HEaaN::HomEvaluator::sub | ( | const Plaintext & | ptxt1, |
const Complex & | cnst_complex, | ||
Plaintext & | ptxt_out | ||
) | const |
Plaintext - Complex Constant.
[in] | ptxt1 | |
[in] | cnst_complex | |
[out] | ptxt_out |
Sub cnst_complex to each component of the message which Plaintext encodes
RuntimeException | if ptxt1 has nonzero rescale counter. |
void HEaaN::HomEvaluator::sub | ( | const Plaintext & | ptxt1, |
const Plaintext & | ptxt2, | ||
Plaintext & | ptxt_out | ||
) | const |
[in] | ptxt1 | |
[in] | ptxt2 | |
[out] | ptxt_out |
RuntimeException | if ptxt1 and ptxt2 have the different level or the different rescale counter |
void HEaaN::HomEvaluator::tensor | ( | const Ciphertext & | ctxt1, |
const Ciphertext & | ctxt2, | ||
Ciphertext & | ctxt_out | ||
) | const |
Compute (a1b2 + a2b1, b1b2, a1a2)
[in] | ctxt1 | |
[in] | ctxt2 | |
[out] | ctxt_out |
ctxt_out.getPoly(1) = ctxt1.getPoly(1) * ctxt2.getPoly(0) + ctxt2.getPoly(1) * ctxt1.getPoly(0), ctxt_out.getPoly(0) = ctxt1.getPoly(0) * ctxt2.getPoly(0), ctxt_out.getPoly(2) = ctxt1.getPoly(1) * ctxt2.getPoly(1)
RuntimeException | if ctxt1 and ctxt2 have the different level |
RuntimeException | if any of the input operands has nonzero rescale counter. |
|
friend |
|
private |
A context with which HomEvaluator is associated.
|
private |
Internal implementation object.