PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
Public Member Functions | Static Public Member Functions | List of all members
lbcrypto::BinFHEContext Class Reference

BinFHEContext. More...

#include <binfhecontext.h>

Inheritance diagram for lbcrypto::BinFHEContext:
Inheritance graph
[legend]
Collaboration diagram for lbcrypto::BinFHEContext:
Collaboration graph
[legend]

Public Member Functions

void GenerateBinFHEContext (uint32_t n, uint32_t N, const NativeInteger &q, const NativeInteger &Q, const NativeInteger &qKS, double std, uint32_t baseKS, uint32_t baseG, uint32_t baseR, BINFHEMETHOD method=GINX)
 
void GenerateBinFHEContext (BINFHEPARAMSET set, BINFHEMETHOD method=GINX)
 
const std::shared_ptr< RingGSWBTKeyGetRefreshKey () const
 
const std::shared_ptr< LWESwitchingKeyGetSwitchKey () const
 
LWEPrivateKey KeyGen () const
 
LWEPrivateKey KeyGenN () const
 
LWECiphertext Encrypt (ConstLWEPrivateKey sk, const LWEPlaintext &m, BINFHEOUTPUT output=BOOTSTRAPPED) const
 
void Decrypt (ConstLWEPrivateKey sk, ConstLWECiphertext ct, LWEPlaintext *result) const
 
std::shared_ptr< LWESwitchingKeyKeySwitchGen (ConstLWEPrivateKey sk, ConstLWEPrivateKey skN) const
 
void BTKeyGen (ConstLWEPrivateKey sk)
 
void BTKeyLoad (const RingGSWEvalKey &key)
 
void ClearBTKeys ()
 
LWECiphertext EvalBinGate (const BINGATE gate, ConstLWECiphertext ct1, ConstLWECiphertext ct2) const
 
LWECiphertext Bootstrap (ConstLWECiphertext ct1) const
 
LWECiphertext EvalNOT (ConstLWECiphertext ct1) const
 
LWECiphertext EvalConstant (bool value) const
 
const std::shared_ptr< RingGSWCryptoParamsGetParams ()
 
const std::shared_ptr< LWEEncryptionSchemeGetLWEScheme ()
 
const std::shared_ptr< RingGSWAccumulatorSchemeGetRingGSWScheme ()
 
template<class Archive >
void save (Archive &ar, std::uint32_t const version) const
 
template<class Archive >
void load (Archive &ar, std::uint32_t const version)
 
std::string SerializedObjectName () const
 

Static Public Member Functions

static uint32_t SerializedVersion ()
 

Detailed Description

BinFHEContext.

The wrapper class for Boolean circuit FHE

Member Function Documentation

◆ Bootstrap()

LWECiphertext lbcrypto::BinFHEContext::Bootstrap ( ConstLWECiphertext  ct1) const

Bootstraps a ciphertext (without peforming any operation)

Parameters
ct1ciphertext to be bootstrapped
Returns
a shared pointer to the resulting ciphertext

◆ BTKeyGen()

void lbcrypto::BinFHEContext::BTKeyGen ( ConstLWEPrivateKey  sk)

Generates boostrapping keys

Parameters
sksecret key

◆ BTKeyLoad()

void lbcrypto::BinFHEContext::BTKeyLoad ( const RingGSWEvalKey key)
inline

Loads bootstrapping keys in the context (typically after deserializing)

Parameters
keystruct with the bootstrapping keys

◆ ClearBTKeys()

void lbcrypto::BinFHEContext::ClearBTKeys ( )
inline

Clear the bootstrapping keys in the current context

◆ Decrypt()

void lbcrypto::BinFHEContext::Decrypt ( ConstLWEPrivateKey  sk,
ConstLWECiphertext  ct,
LWEPlaintext *  result 
) const

Decrypts a ciphertext using a secret key

Parameters
skthe secret key
ctthe ciphertext
*resultplaintext result

◆ Encrypt()

LWECiphertext lbcrypto::BinFHEContext::Encrypt ( ConstLWEPrivateKey  sk,
const LWEPlaintext &  m,
BINFHEOUTPUT  output = BOOTSTRAPPED 
) const

Encrypts a bit using a secret key (symmetric key encryption)

Parameters
sk- the secret key
&m- the plaintext
output- FRESH to generate fresh ciphertext, BOOTSTRAPPED to generate a refreshed ciphertext (default)
Returns
a shared pointer to the ciphertext

◆ EvalBinGate()

LWECiphertext lbcrypto::BinFHEContext::EvalBinGate ( const BINGATE  gate,
ConstLWECiphertext  ct1,
ConstLWECiphertext  ct2 
) const

Evaluates a binary gate (calls bootstrapping as a subroutine)

Parameters
gatethe gate; can be AND, OR, NAND, NOR, XOR, or XNOR
ct1first ciphertext
ct2second ciphertext
Returns
a shared pointer to the resulting ciphertext

◆ EvalConstant()

LWECiphertext lbcrypto::BinFHEContext::EvalConstant ( bool  value) const

Evaluates constant gate

Parameters
valuethe Boolean value to output
Returns
a shared pointer to the resulting ciphertext

◆ EvalNOT()

LWECiphertext lbcrypto::BinFHEContext::EvalNOT ( ConstLWECiphertext  ct1) const

Evaluates NOT gate

Parameters
ct1the input ciphertext
Returns
a shared pointer to the resulting ciphertext

◆ GenerateBinFHEContext() [1/2]

void lbcrypto::BinFHEContext::GenerateBinFHEContext ( uint32_t  n,
uint32_t  N,
const NativeInteger q,
const NativeInteger Q,
const NativeInteger qKS,
double  std,
uint32_t  baseKS,
uint32_t  baseG,
uint32_t  baseR,
BINFHEMETHOD  method = GINX 
)

Creates a crypto context using custom parameters. Should be used with care (only for advanced users familiar with LWE parameter selection).

Parameters
nlattice parameter for additive LWE scheme
Nring dimension for RingGSW/RLWE used in bootstrapping
&qmodulus for additive LWE
&Qmodulus for RingGSW/RLWE used in bootstrapping
&qKSmodulus for key switching
stdstandard deviation
baseKSthe base used for key switching
baseGthe gadget base used in bootstrapping
baseRthe base used for refreshing
methodthe bootstrapping method (AP or GINX)
Returns
creates the cryptocontext

◆ GenerateBinFHEContext() [2/2]

void lbcrypto::BinFHEContext::GenerateBinFHEContext ( BINFHEPARAMSET  set,
BINFHEMETHOD  method = GINX 
)

Creates a crypto context using predefined parameters sets. Recommended for most users.

Parameters
setthe parameter set: TOY, MEDIUM, STD128, STD192, STD256
methodthe bootstrapping method (AP or GINX)
Returns
create the cryptocontext

◆ GetRefreshKey()

const std::shared_ptr<RingGSWBTKey> lbcrypto::BinFHEContext::GetRefreshKey ( ) const
inline

Gets the refreshing key (used for serialization).

Returns
a shared pointer to the refreshing key

◆ GetSwitchKey()

const std::shared_ptr<LWESwitchingKey> lbcrypto::BinFHEContext::GetSwitchKey ( ) const
inline

Gets the switching key (used for serialization).

Returns
a shared pointer to the switching key

◆ KeyGen()

LWEPrivateKey lbcrypto::BinFHEContext::KeyGen ( ) const

Generates a secret key for the main LWE scheme

Returns
a shared pointer to the secret key

◆ KeyGenN()

LWEPrivateKey lbcrypto::BinFHEContext::KeyGenN ( ) const

Generates a secret key used in bootstrapping

Returns
a shared pointer to the secret key

◆ KeySwitchGen()

std::shared_ptr< LWESwitchingKey > lbcrypto::BinFHEContext::KeySwitchGen ( ConstLWEPrivateKey  sk,
ConstLWEPrivateKey  skN 
) const

Generates a switching key to go from a secret key with (Q,N) to a secret key with (q,n)

Parameters
sknew secret key
skNold secret key
Returns
a shared pointer to the switching key

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