helib::ContextBuilder< SCHEME > Class Template Reference

Builder to help construct a context. More...

#include <Context.h>

Classes

struct  default_values
 

Public Member Functions

ContextBuilderm (long m)
 Sets m the order of the cyclotomic polynomial. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderp (long p)
 Sets p the prime number of the ciphertext space. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderr (long r)
 Sets r the Hensel lifting parameter. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, CKKS >::value > * = nullptr>
ContextBuilderprecision (long precision)
 Sets precision the bit precision parameter. More...
 
ContextBuilderscale (double scale)
 Sets scale the scale parameter. More...
 
ContextBuilderstdev (double stdev)
 Sets stdev the standard deviation parameter. More...
 
ContextBuilderc (long c)
 Sets c the number of columns (a.k.a. digits) in the key switching matrices. More...
 
ContextBuildergens (const std::vector< long > &gens)
 Sets gens the generators of the ZMStar group. More...
 
ContextBuilderords (const std::vector< long > &ords)
 Sets ords the order of the corresponding generators in gens in ZmStar. More...
 
ContextBuilderbits (long bits)
 Sets the bit size of the primes in the modulus chain. More...
 
ContextBuilderskHwt (long skHwt)
 Sets the secret key Hamming weight. More...
 
ContextBuilderresolution (long bits)
 Sets the resolution for the modulus chain. More...
 
ContextBuilderbitsInSpecialPrimes (long bits)
 Sets the bit size of the special primes in the modulus chain. More...
 
ContextBuilderbuildModChain (bool yesno)
 Sets a flag determining whether the modulus chain will be built. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuildermvec (const NTL::Vec< long > &mvec)
 Sets mvec the unique primes which are factors of m. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuildermvec (const std::vector< long > &mvec)
 Sets mvec the unique primes which are factors of m. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderthinboot ()
 Sets boostrapping to be thin. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderthickboot ()
 Sets boostrapping to be thick. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderbuildCache (bool yesno)
 Sets flag to choose that the cache for boostrapping will be built. More...
 
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilderbootstrappable (bool yesno=true)
 Sets a flag determining if the context will be bootstrappable. More...
 
Context build () const
 Builds a Context object from the arguments stored in the ContextBuilder object. More...
 
ContextbuildPtr () const
 Builds a Context object from the arguments stored in the ContextBuilder object. More...
 

Static Public Attributes

static constexpr std::string_view typeName = "ContextBuilder"
 Class label to be added to JSON serialization as object type information. More...
 

Friends

std::ostream & operator (std::ostream &os, const ContextBuilder &cb)
 

Detailed Description

template<typename SCHEME>
class helib::ContextBuilder< SCHEME >

Builder to help construct a context.

Template Parameters
SCHEMEThe encryption scheme to be used, must be BGV or CKKS.

Member Function Documentation

◆ bits()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::bits ( long  bits)
inline

Sets the bit size of the primes in the modulus chain.

Parameters
bitsHow many bits to make the modulus chain.
Returns
Reference to the ContextBuilder object.
Note
The actual bit size that is set is typically higher than requested.

◆ bitsInSpecialPrimes()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::bitsInSpecialPrimes ( long  bits)
inline

Sets the bit size of the special primes in the modulus chain.

Parameters
bitsThe bit size of the special primes in the modulus chain.
Returns
Reference to this ContextBuilder object.

◆ bootstrappable()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::bootstrappable ( bool  yesno = true)
inline

Sets a flag determining if the context will be bootstrappable.

Parameters
yesnoA bool to determine whether the context will be bootstrappable.
Returns
Reference to this ContextBuilder object.
Note
ContextBuilder by default will not be bootstrappable.
Only exists when the SCHEME is BGV.

◆ build()

template<typename SCHEME >
Context helib::ContextBuilder< SCHEME >::build

Builds a Context object from the arguments stored in the ContextBuilder object.

Returns
A Context object.

◆ buildCache()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::buildCache ( bool  yesno)
inline

Sets flag to choose that the cache for boostrapping will be built.

Parameters
yesnoA bool to determine whether the cache is built.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ buildModChain()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::buildModChain ( bool  yesno)
inline

Sets a flag determining whether the modulus chain will be built.

Parameters
<tt>yesno</tt>A bool to determine whether the modulus chain should be built.
Returns
Reference to the ContextBuilder object.
Note
ContextBuilder by default will build the modulus chain.

◆ buildPtr()

template<typename SCHEME >
Context * helib::ContextBuilder< SCHEME >::buildPtr

Builds a Context object from the arguments stored in the ContextBuilder object.

Returns
A raw pointer to a Context object.

◆ c()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::c ( long  c)
inline

Sets c the number of columns (a.k.a. digits) in the key switching matrices.

Parameters
cThe number of columns in the key switching matrix.
Returns
Reference to the ContextBuilder object.

◆ gens()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::gens ( const std::vector< long > &  gens)
inline

Sets gens the generators of the ZMStar group.

Parameters
gensA std::vector containing the generators.
Returns
Reference to the ContextBuilder object.

◆ m()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::m ( long  m)
inline

Sets m the order of the cyclotomic polynomial.

Parameters
mThe order of the cyclotomic polynomial.
Returns
Reference to this ContextBuilder object.

◆ mvec() [1/2]

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::mvec ( const NTL::Vec< long > &  mvec)
inline

Sets mvec the unique primes which are factors of m.

Parameters
mvecAn NTL::Vec of primes factors.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ mvec() [2/2]

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::mvec ( const std::vector< long > &  mvec)
inline

Sets mvec the unique primes which are factors of m.

Parameters
mvecA std::vector of primes factors.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ ords()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::ords ( const std::vector< long > &  ords)
inline

Sets ords the order of the corresponding generators in gens in ZmStar.

Parameters
ordsA std::vector containing the orders of gens. The order taken is the absolute value; a negative in ords represents a bad dimension.
Returns
Reference to the ContextBuilder object.

◆ p()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::p ( long  p)
inline

Sets p the prime number of the ciphertext space.

Parameters
pThe prime number of the plaintext space.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ precision()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, CKKS >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::precision ( long  precision)
inline

Sets precision the bit precision parameter.

Parameters
precisionThe bit precision parameter.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is CKKS.

◆ r()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::r ( long  r)
inline

Sets r the Hensel lifting parameter.

Parameters
rThe Hensel lifting parameter.
Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ resolution()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::resolution ( long  bits)
inline

Sets the resolution for the modulus chain.

Parameters
bitsHow many bit size of resolution.
Returns
Reference to the ContextBuilder object.

◆ scale()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::scale ( double  scale)
inline

Sets scale the scale parameter.

Parameters
scaleThe bit scale parameter.
Returns
Reference to the ContextBuilder object.

◆ skHwt()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::skHwt ( long  skHwt)
inline

Sets the secret key Hamming weight.

Parameters
bitsThe secret key Hamming weight.
Returns
Reference to the ContextBuilder object.
Note
If the Hamming weight is 0 (default) then a "dense" key will be generated.

◆ stdev()

template<typename SCHEME >
ContextBuilder& helib::ContextBuilder< SCHEME >::stdev ( double  stdev)
inline

Sets stdev the standard deviation parameter.

Parameters
stdevThe standard deviation parameter.
Returns
Reference to the ContextBuilder object.

◆ thickboot()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::thickboot ( )
inline

Sets boostrapping to be thick.

Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

◆ thinboot()

template<typename SCHEME >
template<typename S = SCHEME, std::enable_if_t< std::is_same< S, BGV >::value > * = nullptr>
ContextBuilder& helib::ContextBuilder< SCHEME >::thinboot ( )
inline

Sets boostrapping to be thin.

Returns
Reference to the ContextBuilder object.
Note
Only exists when the SCHEME is BGV.

Friends And Related Function Documentation

◆ operator

template<typename SCHEME >
std::ostream& operator ( std::ostream &  os,
const ContextBuilder< SCHEME > &  cb 
)
friend

Member Data Documentation

◆ typeName

template<typename SCHEME >
constexpr std::string_view helib::ContextBuilder< SCHEME >::typeName = "ContextBuilder"
staticconstexpr

Class label to be added to JSON serialization as object type information.