BinFHEContext
- class openfhe.BinFHEContext
Bases:
pybind11_object- BTKeyGen(self: openfhe.openfhe.BinFHEContext, sk: openfhe.openfhe.LWEPrivateKey, keygenMode: openfhe.openfhe.KEYGEN_MODE = <KEYGEN_MODE.SYM_ENCRYPT: 0>) None
Generates bootstrapping keys.
- Parameters:
sk (LWEPrivateKey) – The secret key.
- Bootstrap(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext, extended: bool = False) openfhe.openfhe.LWECiphertext
- ClearBTKeys(self: openfhe.openfhe.BinFHEContext) None
- Decrypt(self: openfhe.openfhe.BinFHEContext, sk: openfhe.openfhe.LWEPrivateKey, ct: openfhe.openfhe.LWECiphertext, p: SupportsInt | SupportsIndex = 4) int
Decrypts a ciphertext using a secret key.
- Parameters:
sk (LWEPrivateKey) – The secret key.
ct (LWECiphertext) – The ciphertext.
p (int) – Plaintext modulus (default 4).
- Returns:
The plaintext.
- Return type:
int
- Encrypt(self: openfhe.openfhe.BinFHEContext, sk: openfhe.openfhe.LWEPrivateKey, m: typing.SupportsInt | typing.SupportsIndex, output: openfhe.openfhe.BINFHE_OUTPUT = <BINFHE_OUTPUT.BOOTSTRAPPED: 2>, p: typing.SupportsInt | typing.SupportsIndex = 4, mod: typing.SupportsInt | typing.SupportsIndex = 0) openfhe.openfhe.LWECiphertext
Encrypts a bit or integer using a secret key (symmetric key encryption).
- Parameters:
sk (LWEPrivateKey) – The secret key.
m (int) – The plaintext.
output (BINFHE_OUTPUT) – FRESH to generate a fresh ciphertext, BOOTSTRAPPED to generate a refreshed ciphertext (default).
p (int) – Plaintext modulus (default 4).
mod (int) – Encrypt according to mod instead of m_q if mod != 0.
- Returns:
The ciphertext.
- Return type:
- EvalBinGate(*args, **kwargs)
Overloaded function.
EvalBinGate(self: openfhe.openfhe.BinFHEContext, gate: openfhe.openfhe.BINGATE, ct1: openfhe.openfhe.LWECiphertext, ct2: openfhe.openfhe.LWECiphertext, extended: bool = False) -> openfhe.openfhe.LWECiphertext
Evaluates a binary gate (calls bootstrapping as a subroutine).
- param gate:
The gate; can be AND, OR, NAND, NOR, XOR, or XNOR.
- type gate:
BINGATE
- param ct1:
First ciphertext.
- type ct1:
LWECiphertext
- param ct2:
Second ciphertext.
- type ct2:
LWECiphertext
- return:
The resulting ciphertext.
- rtype:
LWECiphertext
EvalBinGate(self: openfhe.openfhe.BinFHEContext, gate: openfhe.openfhe.BINGATE, ctvector: collections.abc.Sequence[openfhe.openfhe.LWECiphertext], extended: bool = False) -> openfhe.openfhe.LWECiphertext
- EvalConstant(self: openfhe.openfhe.BinFHEContext, arg0: bool) openfhe.openfhe.LWECiphertext
- EvalDecomp(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext) list[openfhe.openfhe.LWECiphertext]
Evaluate ciphertext decomposition
- Parameters:
ct (LWECiphertext) – ciphertext to be bootstrapped
- Returns:
a list with the resulting ciphertexts
- Return type:
List[LWECiphertext]
- EvalFloor(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext, roundbits: SupportsInt | SupportsIndex = 0) openfhe.openfhe.LWECiphertext
Evaluate a round down function
- Parameters:
ct (LWECiphertext) – ciphertext to be bootstrapped
roundbits (int) – number of bits to be rounded
- Returns:
the resulting ciphertext
- Return type:
- EvalFunc(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext, LUT: collections.abc.Sequence[SupportsInt | SupportsIndex]) openfhe.openfhe.LWECiphertext
Evaluate an arbitrary function
- Parameters:
ct (LWECiphertext) – ciphertext to be bootstrapped
LUT (List[int]) – the look-up table of the to-be-evaluated function
- Returns:
the resulting ciphertext
- Return type:
- EvalNOT(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext) openfhe.openfhe.LWECiphertext
Evaluates the NOT gate.
- Parameters:
ct (LWECiphertext) – The input ciphertext.
- Returns:
The resulting ciphertext.
- Return type:
- EvalSign(self: openfhe.openfhe.BinFHEContext, ct: openfhe.openfhe.LWECiphertext, schemeSwitch: bool = False) openfhe.openfhe.LWECiphertext
Evaluate a sign function over large precisions
- Parameters:
ct (LWECiphertext) – ciphertext to be bootstrapped
schemeSwitch (bool) – flag that indicates if it should be compatible to scheme switching
- Returns:
the resulting ciphertext
- Return type:
- GenerateBinFHEContext(*args, **kwargs)
Overloaded function.
GenerateBinFHEContext(self: openfhe.openfhe.BinFHEContext, set: openfhe.openfhe.BINFHE_PARAMSET, method: openfhe.openfhe.BINFHE_METHOD = <BINFHE_METHOD.GINX: 2>) -> None
Creates a crypto context using predefined parameters sets. Recommended for most users.
- param set:
the parameter set: TOY, MEDIUM, STD128, STD192, STD256 with variants
- type set:
BINFHE_PARAMSET
- param method:
the bootstrapping method (DM or CGGI or LMKCDEY)
- type method:
BINFHE_METHOD
- return:
The created crypto context.
- rtype:
BinFHEContext
GenerateBinFHEContext(self: openfhe.openfhe.BinFHEContext, set: openfhe.openfhe.BINFHE_PARAMSET, arbFunc: bool, logQ: typing.SupportsInt | typing.SupportsIndex = 11, N: typing.SupportsInt | typing.SupportsIndex = 0, method: openfhe.openfhe.BINFHE_METHOD = <BINFHE_METHOD.GINX: 2>, timeOptimization: bool = False) -> None
Creates a crypto context using custom parameters. Should be used with care (only for advanced users familiar with LWE parameter selection).
- param set:
The parameter set: TOY, MEDIUM, STD128, STD192, STD256 with variants.
- type set:
BINFHE_PARAMSET
- param arbFunc:
whether need to evaluate an arbitrary function using functional bootstrapping
- type arbFunc:
bool
- param logQ:
log(input ciphertext modulus)
- type logQ:
int
- param N:
ring dimension for RingGSW/RLWE used in bootstrapping
- type N:
int
- param method:
the bootstrapping method (DM or CGGI or LMKCDEY)
- type method:
BINFHE_METHOD
- param timeOptimization:
whether to use dynamic bootstrapping technique
- type timeOptimization:
bool
- return:
creates the cryptocontext.
- rtype:
BinFHEContext
- GenerateLUTviaFunction(self: openfhe.openfhe.BinFHEContext, f: collections.abc.Callable, p: SupportsInt | SupportsIndex) list[int]
Generate the LUT for the to-be-evaluated function
- Parameters:
f (function(int, int) -> int) – the to-be-evaluated function on an integer message and a plaintext modulus
p (int) – plaintext modulus
- Returns:
the resulting ciphertext
- Return type:
List[int]
- GetBeta(self: openfhe.openfhe.BinFHEContext) int
- GetBinFHEScheme(self: openfhe.openfhe.BinFHEContext) lbcrypto::BinFHEScheme
- GetLWEScheme(self: openfhe.openfhe.BinFHEContext) lbcrypto::LWEEncryptionScheme
- GetMaxPlaintextSpace(self: openfhe.openfhe.BinFHEContext) int
- GetParams(self: openfhe.openfhe.BinFHEContext) lbcrypto::BinFHECryptoParams
- GetPublicKey(self: openfhe.openfhe.BinFHEContext) lbcrypto::LWEPublicKeyImpl
- GetRefreshKey(self: openfhe.openfhe.BinFHEContext) lbcrypto::RingGSWACCKeyImpl
- GetSwitchKey(self: openfhe.openfhe.BinFHEContext) lbcrypto::LWESwitchingKeyImpl
- Getn(self: openfhe.openfhe.BinFHEContext) int
- Getq(self: openfhe.openfhe.BinFHEContext) int
- KeyGen(self: openfhe.openfhe.BinFHEContext) openfhe.openfhe.LWEPrivateKey
Generates a secret key for the main LWE scheme.
- Returns:
The secret key.
- Return type:
- KeyGenN(self: openfhe.openfhe.BinFHEContext) openfhe.openfhe.LWEPrivateKey
- KeyGenPair(self: openfhe.openfhe.BinFHEContext) lbcrypto::LWEKeyPairImpl
- LoadBinary(self: openfhe.openfhe.BinFHEContext, arg0: cereal::BinaryInputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- LoadJSON(self: openfhe.openfhe.BinFHEContext, arg0: cereal::JSONInputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- LoadPortableBinary(self: openfhe.openfhe.BinFHEContext, arg0: cereal::PortableBinaryInputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- SaveBinary(self: openfhe.openfhe.BinFHEContext, arg0: cereal::BinaryOutputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- SaveJSON(self: openfhe.openfhe.BinFHEContext, arg0: cereal::JSONOutputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- SavePortableBinary(self: openfhe.openfhe.BinFHEContext, arg0: cereal::PortableBinaryOutputArchive, arg1: typing.SupportsInt | typing.SupportsIndex) None
- SerializedObjectName(self: openfhe.openfhe.BinFHEContext) str
Return the serialized object name
- Returns:
object name
- Return type:
std::string
- SerializedVersion() int
Return the serialized version number in use.
- Returns:
the version number
- Return type:
uint32_t
LWECiphertext
- class openfhe.LWECiphertext
Bases:
pybind11_object- GetLength(self: openfhe.openfhe.LWECiphertext) int
- GetModulus(self: openfhe.openfhe.LWECiphertext) int
LWEPrivateKey
- class openfhe.LWEPrivateKey
Bases:
pybind11_object- GetLength(self: openfhe.openfhe.LWEPrivateKey) int