HEaaN
Crypto Lab's great homomorphic encryption library
Public Member Functions | Private Attributes | Friends | List of all members
HEaaN::HomEvaluator Class Reference

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 ContextgetContext () 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
 

Detailed Description

A class consisting of basic operation of Ciphertext and Message.

Constructor & Destructor Documentation

◆ HomEvaluator() [1/2]

HEaaN::HomEvaluator::HomEvaluator ( const Context context,
const std::string &  key_dir_path 
)
explicit

◆ HomEvaluator() [2/2]

HEaaN::HomEvaluator::HomEvaluator ( const Context context,
const KeyPack pack 
)
explicit

Member Function Documentation

◆ add() [1/8]

void HEaaN::HomEvaluator::add ( const Ciphertext ctxt1,
const Ciphertext ctxt2,
Ciphertext ctxt_out 
) const

Ciphertext + Ciphertext.

Parameters
[in]ctxt1
[in]ctxt2
[out]ctxt_out

Add two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.

Exceptions
RuntimeExceptionif ctxt1 and ctxt2 have the different rescale counter

◆ add() [2/8]

void HEaaN::HomEvaluator::add ( const Ciphertext ctxt1,
const Complex cnst_complex,
Ciphertext ctxt_out 
) const

Ciphertext + Complex Constant.

Parameters
[in]ctxt1
[in]cnst_complex
[out]ctxt_out

Add cnst_complex to each component of the message which Ciphertext encrypts

Exceptions
RuntimeExceptionif ctxt1 has nonzero rescale counter.

◆ add() [3/8]

void HEaaN::HomEvaluator::add ( const Ciphertext ctxt1,
const Message msg2,
Ciphertext ctxt_out 
) const

Ciphertext + Message.

Parameters
[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.

◆ add() [4/8]

void HEaaN::HomEvaluator::add ( const Ciphertext ctxt1,
const Plaintext ptxt2,
Ciphertext ctxt_out 
) const

Ciphertext + Plaintext.

Parameters
[in]ctxt1
[in]ptxt2
[out]ctxt_out

Add Ciphertext and Plaintext. If the levels of ctxt1 and ptxt2 are different, we adjust the level.

◆ add() [5/8]

void HEaaN::HomEvaluator::add ( const Message msg1,
const Complex cnst_complex,
Message msg_out 
) const

Message + Complex Constant.

Parameters
[in]msg1
[in]cnst_complex
[out]msg_out

Add cnst_complex to each component of Message

◆ add() [6/8]

void HEaaN::HomEvaluator::add ( const Message msg1,
const Message msg2,
Message msg_out 
) const

Message + Message.

Parameters
[in]msg1
[in]msg2
[out]msg_out

Add two Message component-wise

Exceptions
RuntimeExceptionif msg1 and msg2 have the different size

◆ add() [7/8]

void HEaaN::HomEvaluator::add ( const Plaintext ptxt1,
const Complex cnst_complex,
Plaintext ptxt_out 
) const

Plaintext + Complex Constant.

Parameters
[in]ptxt1
[in]cnst_complex
[out]ptxt_out

Add cnst_complex to each component of the message which Plaintext encodes

Exceptions
RuntimeExceptionif ptxt1 has nonzero rescale counter.

◆ add() [8/8]

void HEaaN::HomEvaluator::add ( const Plaintext ptxt1,
const Plaintext ptxt2,
Plaintext ptxt_out 
) const

Plaintext + Plaintext.

Parameters
[in]ptxt1
[in]ptxt2
[out]ptxt_out
Exceptions
RuntimeExceptionif ptxt1 and ptxt2 have the different level or the different rescale counter

◆ conjugate() [1/3]

void HEaaN::HomEvaluator::conjugate ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Compute complex conjugate the message ctxt encrypts.

Parameters
[in]ctxt
[out]ctxt_out

◆ conjugate() [2/3]

void HEaaN::HomEvaluator::conjugate ( const Message msg,
Message msg_out 
) const

Compute complex conjugate a Message component-wise.

Parameters
[in]msg
[out]msg_out

◆ conjugate() [3/3]

void HEaaN::HomEvaluator::conjugate ( const Plaintext ptxt,
Plaintext ptxt_out 
) const

Compute complex conjugate the message ptxt encodes.

Parameters
[in]ptxt
[out]ptxt_out

◆ getContext()

const Context& HEaaN::HomEvaluator::getContext ( ) const
inline

Get the internal Context object.

Returns
The context object required.

◆ inverseRescale() [1/2]

void HEaaN::HomEvaluator::inverseRescale ( Ciphertext ctxt) const

Increase one level and multiply the prime at current level + 1.

Parameters
[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.

Exceptions
RuntimeExceptionif the level of a ciphertext is greater than or equal to the maximum level.

◆ inverseRescale() [2/2]

void HEaaN::HomEvaluator::inverseRescale ( Plaintext ptxt) const

Increase one level and multiply the prime at current level + 1.

Parameters
[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.

Exceptions
RuntimeExceptionif the level of a plaintext is greater than or equal to the maximum level.

◆ killImag()

void HEaaN::HomEvaluator::killImag ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Get the real part of the message which ctxt encrypts.

Parameters
[in]ctxt
[out]ctxt_out

◆ leftRotate() [1/3]

void HEaaN::HomEvaluator::leftRotate ( const Ciphertext ctxt,
u64  rot,
Ciphertext ctxt_out 
) const

Rotate components of the message which Ciphertext encrypts by rot.

Parameters
[in]ctxt
[in]rot
[out]ctxt_out

(m_0, m_1, ...) -> (m_r, m_r+1, ...)

◆ leftRotate() [2/3]

void HEaaN::HomEvaluator::leftRotate ( const Message msg,
u64  rot,
Message msg_out 
) const

Rotate components of Message by rot.

Parameters
[in]msg
[in]rot
[out]msg_out

(m_0, m_1, ...) -> (m_r, m_r+1, ...)

◆ leftRotate() [3/3]

void HEaaN::HomEvaluator::leftRotate ( const Plaintext ptxt,
u64  rot,
Plaintext ptxt_out 
) const

Rotate components of the message which Plaintext encodes by rot.

Parameters
[in]ptxt
[in]rot
[out]ptxt_out

(m_0, m_1, ...) -> (m_r, m_r+1, ...)

◆ leftRotateReduce() [1/2]

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.

Parameters
[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.

◆ leftRotateReduce() [2/2]

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.

Parameters
[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

◆ levelDown()

void HEaaN::HomEvaluator::levelDown ( const Ciphertext ctxt,
u64  target_level,
Ciphertext ctxt_out 
) const

Decrease the level of Ciphertext.

Parameters
[in]ctxt
[in]target_level
[out]ctxt_out
Exceptions
RuntimeExceptionif target_level is greater than level of ctxt
RuntimeExceptionif ctxt has nonzero rescale counter.

◆ levelDownOne()

void HEaaN::HomEvaluator::levelDownOne ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Decrease the level of Ciphertext by one.

Parameters
[in]ctxt
[out]ctxt_out
Exceptions
RuntimeExceptionif level of ctxt is zero
RuntimeExceptionif ctxt has nonzero rescale counter.

◆ mult() [1/8]

void HEaaN::HomEvaluator::mult ( const Ciphertext ctxt1,
const Ciphertext ctxt2,
Ciphertext ctxt_out 
) const

Ciphertext * Ciphertext.

Parameters
[in]ctxt1
[in]ctxt2
[out]ctxt_out

Multiply two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.

Exceptions
RuntimeExceptionif any of the input operands has nonzero rescale counter.

◆ mult() [2/8]

void HEaaN::HomEvaluator::mult ( const Ciphertext ctxt1,
const Complex cnst_complex,
Ciphertext ctxt_out 
) const

Ciphertext * Complex Constant.

Parameters
[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.

Exceptions
RuntimeExceptionif ctxt1 has nonzero rescale counter.

◆ mult() [3/8]

void HEaaN::HomEvaluator::mult ( const Ciphertext ctxt1,
const Message msg2,
Ciphertext ctxt_out 
) const

Ciphertext * Message.

Parameters
[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.

Exceptions
RuntimeExceptionif ctxt1 has nonzero rescale counter.

◆ mult() [4/8]

void HEaaN::HomEvaluator::mult ( const Ciphertext ctxt1,
const Plaintext ptxt2,
Ciphertext ctxt_out 
) const

Ciphertext * Plaintext.

Parameters
[in]ctxt1
[in]ptxt2
[out]ctxt_out

Multiply Ciphertext and Plaintext. If the levels of ctxt1 and ptxt2 are different, we adjust the level.

Exceptions
RuntimeExceptionif any of the input operands has nonzero rescale counter.

◆ mult() [5/8]

void HEaaN::HomEvaluator::mult ( const Message msg1,
const Complex cnst_complex,
Message msg_out 
) const

Message * Complex Constant.

Parameters
[in]msg1
[in]cnst_complex
[out]msg_out

Multiply cnst_complex to each component of Message

◆ mult() [6/8]

void HEaaN::HomEvaluator::mult ( const Message msg1,
const Message msg2,
Message msg_out 
) const

Message * Message.

Parameters
[in]msg1
[in]msg2
[out]msg_out

Multiply two Message component-wise

Exceptions
RuntimeExceptionif msg1 and msg2 have the different size

◆ mult() [7/8]

void HEaaN::HomEvaluator::mult ( const Plaintext ptxt1,
const Complex cnst_complex,
Plaintext ptxt_out 
) const

Plaintext * Complex Constant.

Parameters
[in]ptxt1
[in]cnst_complex
[out]ptxt_out

Multiply cnst_complex to each component of the message which Plaintext encodes

Exceptions
RuntimeExceptionif ptxt1 has nonzero rescale counter.

◆ mult() [8/8]

void HEaaN::HomEvaluator::mult ( const Plaintext ptxt1,
const Plaintext ptxt2,
Plaintext ptxt_out 
) const

Plaintext * Plaintext.

Parameters
[in]ptxt1
[in]ptxt2
[out]ptxt_out

Multiply two Plaintext.

Exceptions
RuntimeExceptionif any of the input operands has nonzero rescale counter.

◆ multImagUnit() [1/3]

void HEaaN::HomEvaluator::multImagUnit ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

multiply a Ciphertext by the imaginary unit √(-1)

Parameters
[in]ctxt
[out]ctxt_out

◆ multImagUnit() [2/3]

void HEaaN::HomEvaluator::multImagUnit ( const Message msg,
Message msg_out 
) const

multiply a Message by the imaginary unit √(-1)

Parameters
[in]msg
[out]msg_out

◆ multImagUnit() [3/3]

void HEaaN::HomEvaluator::multImagUnit ( const Plaintext ptxt,
Plaintext ptxt_out 
) const

multiply a Plaintext by the imaginary unit √(-1)

Parameters
[in]ptxt
[out]ptxt_out

◆ multInteger() [1/2]

void HEaaN::HomEvaluator::multInteger ( const Ciphertext ctxt,
u64  cnst_integer,
Ciphertext ctxt_out 
) const

Ciphertext * Positive Integer.

Parameters
[in]ctxt
[in]cnst_integer
[out]ctxt_out

◆ multInteger() [2/2]

void HEaaN::HomEvaluator::multInteger ( const Plaintext ptxt,
u64  cnst_integer,
Plaintext ptxt_out 
) const

Plaintext * Positive Integer.

Parameters
[in]ptxt
[in]cnst_integer
[out]ptxt_out

◆ multWithoutRescale() [1/3]

void HEaaN::HomEvaluator::multWithoutRescale ( const Ciphertext ctxt1,
const Ciphertext ctxt2,
Ciphertext ctxt_out 
) const

Multiply two Ciphertext.

Parameters
[in]ctxt1
[in]ctxt2
[out]ctxt_out

There are no memory check. You should perform the rescale function.

Exceptions
RuntimeExceptionif ctxt1 and ctxt2 have the different level
RuntimeExceptionif any of the input operands has nonzero rescale counter.

◆ multWithoutRescale() [2/3]

void HEaaN::HomEvaluator::multWithoutRescale ( const Ciphertext ctxt1,
const Complex cnst_complex,
Ciphertext ctxt_out 
) const

Multiply Ciphertext by a complex constant.

Parameters
[in]ctxt1
[in]cnst_complex
[out]ctxt_out

There are no memory check.

◆ multWithoutRescale() [3/3]

void HEaaN::HomEvaluator::multWithoutRescale ( const Ciphertext ctxt1,
const Plaintext ptxt2,
Ciphertext ctxt_out 
) const

Multiply Ciphertext and Plaintext.

Parameters
[in]ctxt1
[in]ptxt2
[out]ctxt_out

There are no memory check. You should perform the rescale function.

Exceptions
RuntimeExceptionif ctxt1 and ptxt2 must have the different level
RuntimeExceptionif any of the input operands has nonzero rescale counter.

◆ negate() [1/3]

void HEaaN::HomEvaluator::negate ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Negate a Ciphertext.

Parameters
[in]ctxt
[out]ctxt_out

◆ negate() [2/3]

void HEaaN::HomEvaluator::negate ( const Message msg,
Message msg_out 
) const

Negate a Message.

Parameters
[in]msg
[out]msg_out

◆ negate() [3/3]

void HEaaN::HomEvaluator::negate ( const Plaintext ptxt,
Plaintext ptxt_out 
) const

Negate a Plaintext.

Parameters
[in]ptxt
[out]ptxt_out

◆ relevel()

void HEaaN::HomEvaluator::relevel ( const Plaintext ptxt,
const u64  target_level,
Plaintext ptxt_out 
) const

Adjust the level of plaintext.

Parameters
[in]ptxtInput plaintext
[in]target_levelTarget level
[out]ptxt_out
Exceptions
RuntimeExceptionif target_level exceeds context->getMaxLevel()

◆ relinearize()

void HEaaN::HomEvaluator::relinearize ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Mult relinearization key.

Parameters
[in]ctxt
[out]ctxt_out

This is the latter part of multWithoutRescale function.

◆ rescale() [1/2]

void HEaaN::HomEvaluator::rescale ( Ciphertext ctxt) const

Divide a Ciphertext by the scale factor.

Parameters
[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.

Exceptions
RuntimeExceptionif ctxt has nonzero rescale counter.

◆ rescale() [2/2]

void HEaaN::HomEvaluator::rescale ( Plaintext ptxt) const

Divide a Plaintext by the scale factor.

Parameters
[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.

Exceptions
RuntimeExceptionif ptxt has nonzero rescale counter.

◆ rightRotate() [1/3]

void HEaaN::HomEvaluator::rightRotate ( const Ciphertext ctxt,
u64  rot,
Ciphertext ctxt_out 
) const

Rotate components of the message which Ciphertext encrypts by rot.

Parameters
[in]ctxt
[in]rot
[out]ctxt_out

(m_0, m_1, ...) -> (..., m_0, m_1, ...)

◆ rightRotate() [2/3]

void HEaaN::HomEvaluator::rightRotate ( const Message msg,
u64  rot,
Message msg_out 
) const

Rotate components of Message by rot.

Parameters
[in]msg
[in]rot
[out]msg_out

(m_0, m_1, ...) -> (..., m_0, m_1, ...)

◆ rightRotate() [3/3]

void HEaaN::HomEvaluator::rightRotate ( const Plaintext ptxt,
u64  rot,
Plaintext ptxt_out 
) const

Rotate components of the message which Ciphertext encrypts by rot.

Parameters
[in]ptxt
[in]rot
[out]ptxt_out

(m_0, m_1, ...) -> (..., m_0, m_1, ...)

◆ rightRotateReduce() [1/2]

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.

Parameters
[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.

◆ rightRotateReduce() [2/2]

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.

Parameters
[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.

◆ rotSum()

void HEaaN::HomEvaluator::rotSum ( const std::vector< Ciphertext > &  ctxt,
const std::vector< u64 > &  rot_idx,
Ciphertext ctxt_out 
) const

Compute Σ rot_i (ctxt_i)

Parameters
[in]ctxt
[in]rot_idx
[out]ctxt_out

We suppose that all Ciphertext have the same level

◆ square() [1/3]

void HEaaN::HomEvaluator::square ( const Ciphertext ctxt,
Ciphertext ctxt_out 
) const

Compute the square of a Ciphertext.

Parameters
[in]ctxt
[out]ctxt_out

◆ square() [2/3]

void HEaaN::HomEvaluator::square ( const Message msg,
Message msg_out 
) const

Compute the square of a Message.

Parameters
[in]msg
[out]msg_out

◆ square() [3/3]

void HEaaN::HomEvaluator::square ( const Plaintext ptxt,
Plaintext ptxt_out 
) const

Compute the square of a Plaintext.

Parameters
[in]ptxt
[out]ptxt_out

◆ sub() [1/8]

void HEaaN::HomEvaluator::sub ( const Ciphertext ctxt1,
const Ciphertext ctxt2,
Ciphertext ctxt_out 
) const

Ciphertext - Ciphertext.

Parameters
[in]ctxt1
[in]ctxt2
[out]ctxt_out

Subtract two Ciphertext. If the levels of ctxt1 and ctxt2 are different, we adjust the level.

Exceptions
RuntimeExceptionif ctxt1 and ctxt2 have the different rescale counter

◆ sub() [2/8]

void HEaaN::HomEvaluator::sub ( const Ciphertext ctxt1,
const Complex cnst_complex,
Ciphertext ctxt_out 
) const

Ciphertext - Complex Constant.

Parameters
[in]ctxt1
[in]cnst_complex
[out]ctxt_out

Subtract cnst_complex from each slot of the message which Ciphertext encrypts

Exceptions
RuntimeExceptionif ctxt1 has nonzero rescale counter.

◆ sub() [3/8]

void HEaaN::HomEvaluator::sub ( const Ciphertext ctxt1,
const Message msg2,
Ciphertext ctxt_out 
) const

Ciphertext - Message.

Parameters
[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.

◆ sub() [4/8]

void HEaaN::HomEvaluator::sub ( const Ciphertext ctxt1,
const Plaintext ptxt2,
Ciphertext ctxt_out 
) const

Ciphertext - Plaintext.

Parameters
[in]ctxt1
[in]ptxt2
[out]ctxt_out

Subtract ptxt2 from ctxt1. If the levels of ctxt1 and ptxt2 are different, we adjust the level.

◆ sub() [5/8]

void HEaaN::HomEvaluator::sub ( const Message msg1,
const Complex cnst_complex,
Message msg_out 
) const

Message - Complex Constant.

Parameters
[in]msg1
[in]cnst_complex
[out]msg_out

Subtract cnst_complex from each component of Message

◆ sub() [6/8]

void HEaaN::HomEvaluator::sub ( const Message msg1,
const Message msg2,
Message msg_out 
) const

Message - Message.

Parameters
[in]msg1
[in]msg2
[out]msg_out

Subtract two Message component-wise

Exceptions
RuntimeExceptionif msg1 and msg2 have the different size

◆ sub() [7/8]

void HEaaN::HomEvaluator::sub ( const Plaintext ptxt1,
const Complex cnst_complex,
Plaintext ptxt_out 
) const

Plaintext - Complex Constant.

Parameters
[in]ptxt1
[in]cnst_complex
[out]ptxt_out

Sub cnst_complex to each component of the message which Plaintext encodes

Exceptions
RuntimeExceptionif ptxt1 has nonzero rescale counter.

◆ sub() [8/8]

void HEaaN::HomEvaluator::sub ( const Plaintext ptxt1,
const Plaintext ptxt2,
Plaintext ptxt_out 
) const

Plaintext - Plaintext.

Parameters
[in]ptxt1
[in]ptxt2
[out]ptxt_out
Exceptions
RuntimeExceptionif ptxt1 and ptxt2 have the different level or the different rescale counter

◆ tensor()

void HEaaN::HomEvaluator::tensor ( const Ciphertext ctxt1,
const Ciphertext ctxt2,
Ciphertext ctxt_out 
) const

Compute (a1b2 + a2b1, b1b2, a1a2)

Parameters
[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)

Exceptions
RuntimeExceptionif ctxt1 and ctxt2 have the different level
RuntimeExceptionif any of the input operands has nonzero rescale counter.

Friends And Related Function Documentation

◆ BootstrapperImpl

friend class BootstrapperImpl
friend

Member Data Documentation

◆ context_

const Context HEaaN::HomEvaluator::context_
private

A context with which HomEvaluator is associated.

◆ impl_

std::shared_ptr<HomEvaluatorImpl> HEaaN::HomEvaluator::impl_
private

Internal implementation object.


The documentation for this class was generated from the following file: