API reference
Note that most types and functions provided by OpenFHE.jl are generated automatically by CxxWrap.jl's @wrapmodule
macro. Therefore, docstrings are attached to just the respective symbol and not the actual code location. The goal of this reference is thus chiefly to save the user/developer the hassle of having to go to the (authoritative) OpenFHE documentation each time they need to use OpenFHE.jl in Julia. Note that the documented types for function arguments are not necessarily identical to those imposed by the Julia code, but chosen to be more descriptive. For example, functions expecting enum arguments often allow any Integer
value to be passed, but we document the function signature with the enum type instead.
If in doubt, please consult the official OpenFHE documentation.
Sometimes OpenFHE functions do not directly return wrapped C++ objects but (wrapped) shared pointers to those objects. This is indicated by a SharedPtr
or SharedPtrAllocated
in the type signature. To access the underlying object, use the dereferencing operator []
.
To avoid the hassle of having to dereference shared pointer objects when calling their member functions (which in Julia requires passing the object as the first argument), many functions have a method that automatically dereference the shared pointer, e.g., all CryptoContext
member functions such as GetRingDimension
or MakeCKKSPackedPlaintext
.
OpenFHE.ADVANCEDSHE
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.BV
— ConstantKeySwitchTechnique
Enum type for selecting the key switching technique in a set of CCParams
parameters using SetKeySwitchTechnique
.
Instances are:
INVALID_KS_TECH
BV
HYBRID
See also: SetKeySwitchTechnique
OpenFHE.FHE
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.FIXEDAUTO
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.FIXEDMANUAL
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.FLEXIBLEAUTO
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.FLEXIBLEAUTOEXT
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.GAUSSIAN
— ConstantSecretKeyDist
Enum type for selecting the distribution from which the secret key is generated. To be used in a set of CCParams
parameters using SetSecretKeyDist
.
Instances are:
GAUSSIAN
UNIFORM_TERNARY
SPARSE_TERNARY
See also: SetSecretKeyDist
OpenFHE.HEStd_128_classic
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_128_quantum
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_192_classic
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_192_quantum
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_256_classic
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_256_quantum
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HEStd_NotSet
— ConstantSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.HYBRID
— ConstantKeySwitchTechnique
Enum type for selecting the key switching technique in a set of CCParams
parameters using SetKeySwitchTechnique
.
Instances are:
INVALID_KS_TECH
BV
HYBRID
See also: SetKeySwitchTechnique
OpenFHE.INVALID_KS_TECH
— ConstantKeySwitchTechnique
Enum type for selecting the key switching technique in a set of CCParams
parameters using SetKeySwitchTechnique
.
Instances are:
INVALID_KS_TECH
BV
HYBRID
See also: SetKeySwitchTechnique
OpenFHE.INVALID_RS_TECHNIQUE
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.KEYSWITCH
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.LEVELEDSHE
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.MULTIPARTY
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.NORESCALE
— ConstantScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.PKE
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.PRE
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.SCHEMESWITCH
— ConstantPKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.SPARSE_TERNARY
— ConstantSecretKeyDist
Enum type for selecting the distribution from which the secret key is generated. To be used in a set of CCParams
parameters using SetSecretKeyDist
.
Instances are:
GAUSSIAN
UNIFORM_TERNARY
SPARSE_TERNARY
See also: SetSecretKeyDist
OpenFHE.UNIFORM_TERNARY
— ConstantSecretKeyDist
Enum type for selecting the distribution from which the secret key is generated. To be used in a set of CCParams
parameters using SetSecretKeyDist
.
Instances are:
GAUSSIAN
UNIFORM_TERNARY
SPARSE_TERNARY
See also: SetSecretKeyDist
OpenFHE.CCParams
— TypeCCParams{T}
Type to store parameters for a generating a cryptographic context in OpenFHE using GenCryptoContext
.
Use CCParams{CryptoContextBFVRNS}()
to create a parameter store that can be used to generate a cryptographic context for BFV-encrypted operations. Use CCParams{CryptoContextBGVRNS}()
to create a parameter store that can be used to generate a cryptographic context for BGV-encrypted operations. Use CCParams{CryptoContextCKKSRNS}()
to create a parameter store that can be used to generate a cryptographic context for CKKS-encrypted operations.
See also: CryptoContextBFVRNS
, CryptoContextBGVRNS
, CryptoContextCKKSRNS
, GenCryptoContext
OpenFHE.Ciphertext
— TypeCiphertext{T}
Type alias for CxxWrap.StdLib.SharedPtr{CiphertextImpl{T}}
.
The ciphertext object holds homomorphically encrypted data that can be used for encrypted computations. It is created either by encrypting a Plaintext
object or by performing arithmetic with existing ciphertexts.
OpenFHE.CryptoContext
— TypeCryptoContext{T}
Type alias for CxxWrap.StdLib.SharedPtr{CryptoContextImpl{T}}
.
The crypto context is the central object in OpenFHE that facilitates all essential cryptographic operations such as key generation, encryption/decryption, arithmetic operations on plaintexts and ciphertexts etc.
In OpenFHE, a crypto context is always created from a set of CCParams
parameters using GenCryptoContext
.
See also: CCParams
, GenCryptoContext
OpenFHE.CryptoContextBFVRNS
— TypeCryptoContextBFVRNS
A type used as a parameter to CCParams
to indicate that parameters for BFV-based encryptions are to be stored.
See also: CCParams
OpenFHE.CryptoContextBGVRNS
— TypeCryptoContextBGVRNS
A type used as a parameter to CCParams
to indicate that parameters for BGV-based encryptions are to be stored.
See also: CCParams
OpenFHE.CryptoContextCKKSRNS
— TypeCryptoContextCKKSRNS
A type used as a parameter to CCParams
to indicate that parameters for CKKS-based encryptions are to be stored.
See also: CCParams
OpenFHE.DCRTPoly
— TypeDCRTPoly
A type used as a parameter for many parametric data types (e.g., CryptoContext
or Ciphertext
) to indicate how some fundamental lattice operations are encoded in OpenFHE. Usually this type never needs to be constructed directly by a user.
See also: CryptoContext
OpenFHE.DecryptResult
— TypeOpenFHE.DecryptResult
Return type of the Decrypt
operation. This type does not actually hold any data but only information on whether the decryption succeeded. It is currently not used by OpenFHE.jl and no functions are implemented.
See also: Decrypt
OpenFHE.EncodingParams
— TypeEncodingParams
Type alias for CxxWrap.StdLib.SharedPtr{EncodingParamsImpl}
.
The EncodingParams
store the parameters for encoding. These parameters are kept with multiple OpenFHE objects and are continually reused during the encoding of new values.
OpenFHE.KeyPair
— TypeKeyPair{T}
Data type to hold a public/private key combination for encrypting/decrypting data. A key pair is usually generated by calling KeyGen
.
To extract the public or private key from a key pair, use OpenFHE.public_key
and OpenFHE.private_key
respectively. Since these are not functions provided by OpenFHE but only by OpenFHE.jl, they are not exported.
See also: KeyGen
, CryptoContext
, PublicKey
, PrivateKey
, OpenFHE.public_key
, OpenFHE.private_key
OpenFHE.KeySwitchTechnique
— TypeKeySwitchTechnique
Enum type for selecting the key switching technique in a set of CCParams
parameters using SetKeySwitchTechnique
.
Instances are:
INVALID_KS_TECH
BV
HYBRID
See also: SetKeySwitchTechnique
OpenFHE.PKESchemeFeature
— TypePKESchemeFeature
Enum type for selecting scheme features for public key encryption (PKE) in a crypto context using Enable
.
Instances are:
PKE
KEYSWITCH
PRE
LEVELDSHE
ADVANCEDSHE
MULTIPARTY
FHE
SCHEMESWITCH
See also: Enable
OpenFHE.Plaintext
— TypePlaintext
Type alias for CxxWrap.StdLib.SharedPtr{PlaintextImpl}
.
The plaintext object can hold unencrypted data. It is created either by encoding raw data (e.g., through MakeCKKSPackedPlaintext
) or by decrypting a Ciphertext
object using Decrypt
.
See also: Ciphertext
, Decrypt
OpenFHE.PrivateKey
— TypePrivateKey{T}
Type alias for CxxWrap.StdLib.SharedPtr{PrivateKeyImpl{T}}
.
Private keys can be used to decrypt Ciphertext
data into Plaintext
objects. They are part of a KeyPair
that contains both a public and a private key. Key pairs can be created from a CryptoContext
by calling KeyGen
.
OpenFHE.PublicKey
— TypePublicKey{T}
Type alias for CxxWrap.StdLib.SharedPtr{PublicKeyImpl{T}}
.
Public keys can be used to encrypt Plaintext
data into Ciphertext
objects. They are part of a KeyPair
that contains both a public and a private key. Key pairs can be created from a CryptoContext
by calling KeyGen
.
OpenFHE.ScalingTechnique
— TypeScalingTechnique
Enum type for selecting the scaling technique for ciphertext multiplication in a set of CCParams
parameters using SetScalingTechnique
.
Instances are:
FIXEDMANUAL
FIXEDAUTO
FLEXIBLEAUTO
FLEXIBLEAUTOEXT
NORESCALE
INVALID_RS_TECHNIQUE
See also: SetScalingTechnique
OpenFHE.SecretKeyDist
— TypeSecretKeyDist
Enum type for selecting the distribution from which the secret key is generated. To be used in a set of CCParams
parameters using SetSecretKeyDist
.
Instances are:
GAUSSIAN
UNIFORM_TERNARY
SPARSE_TERNARY
See also: SetSecretKeyDist
OpenFHE.SecurityLevel
— TypeSecurityLevel Enum type for specifying the security level according to the homomorphic encryption standard in a set of CCParams
parameters using SetSecurityLevel
.
Instances are:
HEStd_128_classic
HEStd_192_classic
HEStd_256_classic
HEStd_128_quantum
HEStd_192_quantum
HEStd_256_quantum
HEStd_NotSet
See also: SetSecurityLevel
OpenFHE.ClearEvalAutomorphismKeys
— FunctionClearEvalAutomorphismKeys()
ClearEvalAutomorphismKeys(id::String)
ClearEvalAutomorphismKeys(crypto_context::CryptoContext)
Clear EvalAutomorphismKey cache fully.
Clear EvalAutomorphismKey cache for a given key id
.
Clear EvalAutomorphismKey cache for a given crypto_context
See also: CryptoContext
, EvalBootstrapKeyGen
, EvalBootstrap
, EvalRotateKeyGen
, EvalRotate
, ClearEvalMultKeys
, ClearEvalSumKeys
OpenFHE.ClearEvalMultKeys
— FunctionClearEvalMultKeys()
ClearEvalMultKeys(id::String)
ClearEvalMultKeys(crypto_context::CryptoContext)
Clear EvalMultKey cache fully.
Clear EvalMultKey cache for a given key id
.
Clear EvalMultKey cache for a given crypto_context
See also: CryptoContext
, EvalMultKeyGen
, EvalMult
, ClearEvalSumKeys
, ClearEvalAutomorphismKeys
OpenFHE.ClearEvalSumKeys
— FunctionClearEvalSumKeys()
ClearEvalSumKeys(id::String)
ClearEvalSumKeys(crypto_context::CryptoContext)
Clear EvalSumKey cache fully.
Clear EvalSumKey cache for a given key id
.
Clear EvalSumKey cache for a given crypto_context
See also: CryptoContext
, EvalSumKeyGen
, EvalSum
, ClearEvalMultKeys
, ClearEvalAutomorphismKeys
OpenFHE.Clone
— FunctionClone(ciphertext::Ciphertext)
Clone the given ciphertext
including its encrypted data.
See also: Ciphertext
, CloneZero
OpenFHE.CloneZero
— FunctionCloneZero(ciphertext::Ciphertext)
Clone the given ciphertext
without its encrypted data.
See also: Ciphertext
, Clone
OpenFHE.ComposedEvalMult
— FunctionComposedEvalMult(crypto_context::CryptoContext, ciphertext1::Ciphertext, ciphertext2::Ciphertext)
Multiply ciphertext1
with ciphertext2
, perform relinearization and modulus switching/rescaling. Return the resulting Ciphertext
. Both input ciphertexts need to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
OpenFHE.Decrypt
— MethodDecrypt(crypto_context::CryptoContext, ciphertext::Ciphertext, private_key::PrivateKey, plaintext::Plaintext)
Decrypt(crypto_context::CryptoContext, private_key::PrivateKey, ciphertext::Ciphertext, plaintext::Plaintext)
Decrypt a ciphertext
with the given private_key
and store the result in plaintext
, using the parameters of the given crypto_context
.
See also: CryptoContext
, PrivateKey
, Ciphertext
, Plaintext
, Encrypt
OpenFHE.Enable
— FunctionEnable(crypto_context::CryptoContext, feature::PKESchemeFeature)
Enable a certain public key encryption feature
in the given crypto_context
.
See also: CryptoContext
, PKESchemeFeature
OpenFHE.Encrypt
— FunctionEncrypt(crypto_context::CryptoContext, public_key::PublicKey, plaintext::Plaintext)
Encrypt a given Plaintext
object into a Ciphertext
using the given public_key
and using the parameters of the crypto_context
.
See also: CryptoContext
, PublicKey
, Decrypt
OpenFHE.EvalAdd
— FunctionEvalAdd(crypto_context::CryptoContext, ciphertext1::Ciphertext, ciphertext2::Ciphertext)
EvalAdd(crypto_context::CryptoContext, ciphertext::Ciphertext, plaintext::Plaintext)
EvalAdd(crypto_context::CryptoContext, plaintext::Plaintext, ciphertext::Ciphertext)
EvalAdd(crypto_context::CryptoContext, ciphertext::Ciphertext, scalar::Real)
EvalAdd(crypto_context::CryptoContext, scalar::Real, ciphertext::Ciphertext)
Add ciphertext1
to ciphertext2
and return the resulting Ciphertext
. Both input ciphertexts need to be derived from the given crypto_context
.
Add plaintext
to the ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
, while the plaintext needs to be encoded in a compatible manner
Add the real-valued scalar
element-wise to ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, Plaintext
OpenFHE.EvalBootstrap
— MethodEvalBootstrap(crypto_context::CryptoContext, ciphertext::Ciphertext;
num_iterations = 1,
precision = 0)
Return a refreshed ciphertext
for a given crypto_context
. Supported for CKKS only. Please refer to the OpenFHE documentation for details on the remaining arguments.
See also: CryptoContext
, PrivateKey
, EvalBootstrapSetup
, EvalBootstrap
OpenFHE.EvalBootstrapKeyGen
— FunctionEvalBootstrapKeyGen(crypto_context::CryptoContext, private_key::PrivateKey, num_slots::Integer)
Generate the necessary keys from private_key
to enable bootstrapping for a given crypto_context
and num_slots
slots. Supported for CKKS only.
See also: CryptoContext
, PrivateKey
, EvalBootstrapSetup
, EvalBootstrap
OpenFHE.EvalBootstrapSetup
— MethodEvalBootstrapSetup(crypto_context::CryptoContext;
level_budget::Vector{<:Integer} = [5, 4],
dim1::Vector{<:Integer} = [0, 0],
slots = 0,
correction_factor = 0,
precompute = true)
Set up a given crypto_context
for bootstrapping. Supported for CKKS only. Please refer to the OpenFHE documentation for details on the remaining arguments.
See also: CryptoContext
, EvalBootstrapKeyGen
, EvalBootstrap
OpenFHE.EvalCos
— FunctionEvalCos(crypto_context::CryptoContext, ciphertext::Ciphertext, a::Float64, b::Float64,
degree::Integer)
Evaluate approximate cosine function on a given ciphertext
using the Chebyshev approximation over the range $[a,b]$. Return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
a
is a lower bound of elements contained in the given ciphertext
.
b
is an upper bound of elements contained in the given ciphertext
.
degree
is a desired degree of approximation.
Supported only in CKKS.
See also: CryptoContext
, Ciphertext
, EvalSin
OpenFHE.EvalDivide
— FunctionEvalDivide(crypto_context::CryptoContext, ciphertext::Ciphertext, a::Float64, b::Float64,
degree::Integer)
Evaluate approximate division function $\frac{1}{x}$ where $x >= 1$ on a given ciphertext
using the Chebyshev approximation over the range $[a,b]$. Return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
x
is an element contained in the given ciphertext
a
is a lower bound of elements contained in the given ciphertext
.
b
is an upper bound of elements contained in the given ciphertext
.
degree
is a desired degree of approximation.
Supported only in CKKS.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalLogistic
— FunctionEvalLogistic(crypto_context::CryptoContext, ciphertext::Ciphertext, a::Float64, b::Float64,
degree::Integer)
Evaluate approximate logistic function $\frac{1}{1 + \exp{-x}}$ on a given ciphertext
using the Chebyshev approximation over the range $[a,b]$. Return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
x
is an element contained in the given ciphertext
a
is a lower bound of elements contained in the given ciphertext
.
b
is an upper bound of elements contained in the given ciphertext
.
degree
is a desired degree of approximation.
Supported only in CKKS.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalMult
— FunctionEvalMult(crypto_context::CryptoContext, ciphertext1::Ciphertext, ciphertext2::Ciphertext)
EvalMult(crypto_context::CryptoContext, ciphertext::Ciphertext, plaintext::Plaintext)
EvalMult(crypto_context::CryptoContext, plaintext::Plaintext, ciphertext::Ciphertext)
EvalMult(crypto_context::CryptoContext, ciphertext::Ciphertext, scalar::Real)
EvalMult(crypto_context::CryptoContext, scalar::Real, ciphertext::Ciphertext)
Multiply ciphertext1
with ciphertext2
and return the resulting Ciphertext
. Both input ciphertexts need to be derived from the given crypto_context
.
Multiply ciphertext
with the plaintext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
, while the plaintext needs to be encoded in a compatible manner
Multiply ciphertext
with the real-valued scalar
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, Plaintext
OpenFHE.EvalMultKeyGen
— FunctionEvalMultKeyGen(crypto_context::CryptoContext, private_key::PrivateKey)
Generate relinearization key for use with EvalMult
using the private_key
, and store it in the given crypto_context
.
See also: CryptoContext
, PrivateKey
, EvalMult
OpenFHE.EvalMultNoRelin
— FunctionEvalMultNoRelin(crypto_context::CryptoContext, ciphertext1::Ciphertext, ciphertext2::Ciphertext)
Multiply ciphertext1
with ciphertext2
without relinearization and return the resulting Ciphertext
. Both input ciphertexts need to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalNegate
— FunctionEvalNegate(crypto_context::CryptoContext, ciphertext::Ciphertext)
Negate the ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalRotate
— FunctionEvalRotate(crypto_context::CryptoContext, ciphertext::Ciphertext, index::Integer)
Rotate the ciphertext
by the given index
. A positive index denotes a left shift, a negative index a right shift. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalRotateKeyGen
— MethodEvalRotateKeyGen(crypto_context::CryptoContext,
private_key::PrivateKey,
index_list::Vector{<:Integer};
public_key::PublicKey = C_NULL)
Generate rotation keys for use with EvalRotate
using the private_key
and for the rotation indices in index_list. The keys are stored in the given
crypto_context`. Please refer to the OpenFHE documentation for details on the remaining arguments.
See also: CryptoContext
, PrivateKey
, PublicKey
, EvalRotate
OpenFHE.EvalSin
— FunctionEvalSin(crypto_context::CryptoContext, ciphertext::Ciphertext, a::Float64, b::Float64,
degree::Integer)
Evaluate approximate sine function on a given ciphertext
using the Chebyshev approximation over the range $[a,b]$. Return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
a
is a lower bound of elements contained in the given ciphertext
.
b
is an upper bound of elements contained in the given ciphertext
.
degree
is a desired degree of approximation.
Supported only in CKKS.
See also: CryptoContext
, Ciphertext
, EvalCos
OpenFHE.EvalSquare
— FunctionEvalSquare(crypto_context::CryptoContext, ciphertext::Ciphertext)
Perform efficient homomorphic squaring of a ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
OpenFHE.EvalSub
— FunctionEvalSub(crypto_context::CryptoContext, ciphertext1::Ciphertext, ciphertext2::Ciphertext)
EvalSub(crypto_context::CryptoContext, ciphertext::Ciphertext, plaintext::Plaintext)
EvalSub(crypto_context::CryptoContext, plaintext::Plaintext, ciphertext::Ciphertext)
EvalSub(crypto_context::CryptoContext, ciphertext::Ciphertext, scalar::Real)
EvalSub(crypto_context::CryptoContext, scalar::Real, ciphertext::Ciphertext)
Subtract ciphertext2
from ciphertext1
and return the resulting Ciphertext
. Both input ciphertexts need to be derived from the given crypto_context
.
Subtract plaintext
from ciphertext
(or vice-versa) and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
, while the plaintext needs to be encoded in a compatible manner
Subtract the real-valued scalar
element-wise from ciphertext
(or vice-versa) and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, Plaintext
OpenFHE.EvalSum
— FunctionEvalSum(crypto_context::CryptoContext, ciphertext::Ciphertext, batch_size::Integer)
Calculate sum of all elements contained in the given ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, EvalSumKeyGen
OpenFHE.EvalSumKeyGen
— MethodEvalSumKeyGen(crypto_context::CryptoContext, private_key::PrivateKey;
public_key::PublicKey = C_NULL)
Generates the key map to be used by EvalSum
. public_key
has to be set for NTRU schemes.
Please refer to the OpenFHE documentation for more details.
See also: CryptoContext
, PrivateKey
, PublicKey
, EvalSum
OpenFHE.GenCryptoContext
— FunctionGenCryptoContext(parameters::CCParams)::CryptoContext
GenCryptoContext(parameters::CCParams{CryptoContextBFVRNS})::CryptoContext{DCRTYPoly}
GenCryptoContext(parameters::CCParams{CryptoContextBGVRNS})::CryptoContext{DCRTYPoly}
GenCryptoContext(parameters::CCParams{CryptoContextCKKSRNS})::CryptoContext{DCRTYPoly}
Generate a crypto context from a set of parameters
. The exact return type depends on the parameter set type.
See also: CryptoContext
, CCParams
OpenFHE.GetAllContexts
— FunctionGetAllContexts()
Return all CryptoContext
s stored in CryptoContextFactory
.
OpenFHE.GetBatchSize
— FunctionGetBatchSize(parameters::EncodingParams)::UInt32
Return the plaintext batch size used by the given parameters
.
See also: EncodingParams
, SetBatchSize
OpenFHE.GetBootstrapDepth
— MethodGetBootstrapDepth(level_budget::Vector{<:Integer}, secret_key_distribution::SecretKeyDist)
Compute and return the bootstrapping depth for a given level_budget
and a secret_key_distribution
.
See also: SecretKeyDist
OpenFHE.GetCoefPackedValue
— FunctionGetCoefPackedValue(plaintext::Plaintext)::Vector{Int64}
Return data as packed coefficients for a given plaintext
.
Note: Only supported for schemes that encode data as packed coefficients!
See also: Plaintext
OpenFHE.GetContextCount
— FunctionGetContextCount()
Return number of CryptoContext
s stored in CryptoContextFactory
.
See also: CryptoContext
OpenFHE.GetCryptoContext
— MethodGetCryptoContext(object::Union{Ciphertext})
Return a the crypto context for a an object
that is is a subtype of CryptoObject
.
Currently, this is only implemented for Ciphertext
.
See also: CryptoContext
, Ciphertext
OpenFHE.GetCyclotomicOrder
— FunctionGetCyclotomicOrder(crypto_context::CryptoContext)::UInt32
Return the cyclotomic order used for a given crypto_context
.
See also: CryptoContext
OpenFHE.GetElementRingDimension
— FunctionGetElementRingDimension(plaintext::Plaintext)::UInt32
Return the ring dimension on the underlying element for a given plaintext
.
See also: Plaintext
OpenFHE.GetEncodingParameters
— FunctionGetEncodingParameters(object::Union{Ciphertext})
Return the EncodingParams
used by the given object
that is is a subtype of CryptoObject
.
Currently, this is only implemented for Ciphertext
.
See also: EncodingParams
, Ciphertext
OpenFHE.GetEncodingParams
— FunctionGetEncodingParams(plaintext::Plaintext)
Return the EncodingParams
used by the given plaintext
.
See also: Plaintext
, EncodingParams
OpenFHE.GetFullContextByDeserializedContext
— FunctionGetFullContextByDeserializedContext(crypto_context::CryptoContext)
Return the full CryptoContext
based on partial information we usually get from a de-serialized crypto_context
.
See also: CryptoContext
OpenFHE.GetHopLevel
— FunctionGetHopLevel(ciphertext::Ciphertext)
Return the re-encryption level for the given ciphertext
.
See also: Ciphertext
, SetHopLevel
OpenFHE.GetKeyGenLevel
— FunctionGetKeyGenLevel(crypto_context::CryptoContext)::UInt32
For future use: Return level at which evaluation keys should be generated for the given crypto_context
.
See also: CryptoContext
, SetKeyGenLevel
OpenFHE.GetLevel
— FunctionGetLevel(ciphertext::Ciphertext)
GetLevel(plaintext::Plaintext)
Return the number of scalings performed for the given ciphertext
or plaintext
..
See also: Ciphertext
, Plaintext
, SetLevel
OpenFHE.GetLogError
— FunctionGetLogError(plaintext::Plaintext)
Return log2 of estimated standard deviation of approximation for a given plaintext
.
See also: Plaintext
OpenFHE.GetLogPrecision
— FunctionGetLogPrecision(plaintext::Plaintext)
Return log2 of estimated precision for a given plaintext
.
See also: Plaintext
OpenFHE.GetModulus
— FunctionGetModulus(crypto_context::CryptoContext)::UInt32
Return the ciphertext modulus used for a given crypto_context
.
See also: CryptoContext
OpenFHE.GetNoiseScaleDeg
— FunctionGetNoiseScaleDeg(ciphertext::Ciphertext)
GetNoiseScaleDeg(plaintext::Plaintext)
Get the degree of the scaling factor for the given ciphertext
or plaintext
..
See also: Ciphertext
, Plaintext
, SetNoiseScaleDeg
OpenFHE.GetPackedValue
— FunctionGetPackedValue(plaintext::Plaintext)::Vector{Int64}
Return data as packed value for a given plaintext
.
Note: Only supported for schemes that encode data as packed values!
See also: Plaintext
OpenFHE.GetPlaintextBigModulus
— FunctionGetPlaintextBigModulus(parameters::EncodingParams)
Return the big plaintext modulus used by the given parameters
.
See also: EncodingParams
, SetPlaintextBigModulus
OpenFHE.GetPlaintextBigRootOfUnity
— FunctionGetPlaintextBigRootOfUnity(parameters::EncodingParams)
Return the big plaintext modulus root of unity used by the given parameters
.
See also: EncodingParams
, SetPlaintextBigRootOfUnity
OpenFHE.GetPlaintextGenerator
— FunctionGetPlaintextGenerator(parameters::EncodingParams)::UInt32
Return the plaintext generator used by the given parameters
.
See also: EncodingParams
, SetPlaintextGenerator
OpenFHE.GetPlaintextModulus
— FunctionGetPlaintextModulus(parameters::EncodingParams)
Return the plaintext modulus used by the given parameters
.
See also: EncodingParams
, SetPlaintextModulus
OpenFHE.GetPlaintextRootOfUnity
— FunctionGetPlaintextRootOfUnity(parameters::EncodingParams)
Return the plaintext modulus root of unity used by the given parameters
.
See also: EncodingParams
, SetPlaintextRootOfUnity
OpenFHE.GetRealPackedValue
— FunctionGetRealPackedValue(plaintext::Plaintext)::Vector{Float64}
Return data as double precision values for a given plaintext
.
Note: Only supported for schemes that encode data as double precision values!
See also: Plaintext
OpenFHE.GetRingDimension
— FunctionGetRingDimension(crypto_context::CryptoContext)::UInt32
Return the polynomial ring dimension for a given crypto_context
.
See also: CryptoContext
OpenFHE.GetRootOfUnity
— FunctionGetRootOfUnity(crypto_context::CryptoContext)::UInt32
Return the root of unity used for a given crypto_context
.
See also: CryptoContext
OpenFHE.GetScalingFactor
— FunctionGetScalingFactor(ciphertext::Ciphertext)
GetScalingFactor(plaintext::Plaintext)
Return the scaling factor for the given ciphertext
or plaintext
.
See also: Ciphertext
, Plaintext
, SetScalingFactor
OpenFHE.GetSlots
— FunctionGetSlots(ciphertext::Ciphertext)
GetSlots(plaintext::Plaintext)
Return the number of slots for the given ciphertext
or plaintext
.
See also: Ciphertext
, Plaintext
, SetSlots
OpenFHE.GetStringValue
— FunctionGetStringValue(plaintext::Plaintext)::String
Return data as string for a given plaintext
.
Note: Only supported for schemes that encode data as string!
See also: Plaintext
OpenFHE.IsEncoded
— FunctionIsEncoded(plaintext::Plaintext)
Return true when encoding is done for a given plaintext
.
See also: Plaintext
OpenFHE.KeyGen
— FunctionKeyGen(crypto_context::CryptoContext)
Generate and return a key pair with a public and a private key for a given crypto_context
.
See also: CryptoContext
, KeyPair
, PublicKey
, PrivateKey
OpenFHE.MakeCKKSPackedPlaintext
— MethodMakeCKKSPackedPlaintext(crypto_context::CryptoContext, value::Vector{Float64};
scale_degree = 1,
level = 1,
params = C_NULL,
num_slots = 0)
Encode a vector of real numbers value
into a CKKS-packed Plaintext
using the given crypto_context
. Please refer to the OpenFHE documentation for details on the remaining arguments.
See also: CryptoContext
, Plaintext
OpenFHE.MakePackedPlaintext
— MethodMakePackedPlaintext(crypto_context::CryptoContext, value::Vector{<:Integer};
noise_scale_degree = 1,
level = 0)
Encode a vector of integers value
into a BFV/BGV-packed Plaintext
using the given crypto_context
. Please refer to the OpenFHE documentation for details on the remaining arguments.
See also: CryptoContext
, Plaintext
OpenFHE.ModReduce
— FunctionModReduce(crypto_context::CryptoContext, ciphertext::Ciphertext)
Scale down to the original scale of the ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, Rescale
, ModReduceInPlace
OpenFHE.ModReduceInPlace
— FunctionModReduceInPlace(crypto_context::CryptoContext, ciphertext::Ciphertext)
Scale down to the original scale of the ciphertext
in-place. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, RescaleInPlace
, ModReduce
OpenFHE.ReleaseAllContexts
— FunctionReleaseAllContexts()
Clear all generated CryptoContext
s from CryptoContextFactory
.
See also: CryptoContext
OpenFHE.Relinearize
— FunctionRelinearize(crypto_context::CryptoContext, ciphertext::Ciphertext)
Perform relinearization of the ciphertext
to the lowest level (with 2 polynomials per ciphertext) and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, RelinearizeInPlace
OpenFHE.RelinearizeInPlace
— FunctionRelinearizeInPlace(crypto_context::CryptoContext, ciphertext::Ciphertext)
Perform in-place relinearization of the ciphertext
to the lowest level (with 2 polynomials per ciphertext). The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, Relinearize
OpenFHE.Rescale
— FunctionRescale(crypto_context::CryptoContext, ciphertext::Ciphertext)
An alias for ModReduce
method. ModReduce
is called Rescale
in CKKS.
Scale down to the original scale of the ciphertext
and return the resulting Ciphertext
. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, ModReduce
, RescaleInPlace
OpenFHE.RescaleInPlace
— FunctionRescaleInPlace(crypto_context::CryptoContext, ciphertext::Ciphertext)
An alias for ModReduceInPlace
method. ModReduceInPlace
is called RescaleInPlace
in CKKS.
Scale down to the original scale of the ciphertext
in-place. The input ciphertext needs to be derived from the given crypto_context
.
See also: CryptoContext
, Ciphertext
, ModReduceInPlace
, Rescale
OpenFHE.SetBatchSize
— FunctionSetBatchSize(parameters::EncodingParams, batch_size::Integer)
Set the plaintext batch size for the given parameters
.
See also: EncodingParams
, GetBatchSize
OpenFHE.SetFirstModSize
— FunctionSetFirstModSize(parameters::CCParams, modulus::Integer)
Set the first modulus
for a set of parameters
.
See also: SetScalingModSize
OpenFHE.SetHopLevel
— FunctionSetHopLevel(ciphertext::Ciphertext, level::Integer)
Set the re-encryption level
for the given ciphertext
.
See also: Ciphertext
, GetHopLevel
OpenFHE.SetKeyGenLevel
— FunctionSetKeyGenLevel(crypto_context::CryptoContext, level::Integer)
For future use: Set level
at which evaluation keys should be generated for the given crypto_context
.
See also: CryptoContext
, GetKeyGenLevel
OpenFHE.SetKeySwitchTechnique
— FunctionSetKeySwitchTechnique(parameters::CCParams, technique::KeySwitchTechnique)
Set the key switching technique technique
for a set of parameters
.
See also: KeySwitchTechnique
OpenFHE.SetLevel
— FunctionSetLevel(ciphertext::Ciphertext, level::Integer)
SetLevel(plaintext::Plaintext, level::Integer)
Set the number of scalings level
for the given ciphertext
or plaintext
..
See also: Ciphertext
, Plaintext
, GetLevel
OpenFHE.SetMultiplicativeDepth
— FunctionSetMultiplicativeDepth(parameters::CCParams, depth::Integer)
Set the required multiplicative depth
for a set of parameters
.
OpenFHE.SetNoiseScaleDeg
— FunctionSetNoiseScaleDeg(ciphertext::Ciphertext, degree::Integer)
SetNoiseScaleDeg(plaintext::Plaintext, degree::Integer)
Set the degree
of the scaling factor for the given ciphertext
or plaintext
..
See also: Ciphertext
, Plaintext
, GetNoiseScaleDeg
OpenFHE.SetNumLargeDigits
— FunctionSetNumLargeDigits(parameters::CCParams, number::Integer)
Set the number
of large digits for a set of parameters
.
OpenFHE.SetPlaintextBigModulus
— FunctionSetPlaintextBigModulus(parameters::EncodingParams, plaintext_big_modulus::Integer)
Set the big plaintext modulus for the given parameters
.
See also: EncodingParams
, GetPlaintextBigModulus
OpenFHE.SetPlaintextBigRootOfUnity
— FunctionSetPlaintextBigRootOfUnity(parameters::EncodingParams, plaintext_big_root_of_unity::Integer)
Set the big plaintext modulus root of unity for the given parameters
.
See also: EncodingParams
, GetPlaintextBigRootOfUnity
OpenFHE.SetPlaintextGenerator
— FunctionSetPlaintextGenerator(parameters::EncodingParams, plaintext_generator::Integer)
Set the plaintext generator for the given parameters
.
See also: EncodingParams
, GetPlaintextGenerator
OpenFHE.SetPlaintextModulus
— FunctionSetPlaintextModulus(parameters::EncodingParams, plaintext_modulus::Integer)
Set the plaintext modulus for the given parameters
.
See also: EncodingParams
, GetPlaintextModulus
OpenFHE.SetPlaintextRootOfUnity
— FunctionSetPlaintextRootOfUnity(parameters::EncodingParams, plaintext_root_of_unity::Integer)
Set the plaintext modulus root of unity for the given parameters
.
See also: EncodingParams
, GetPlaintextRootOfUnity
OpenFHE.SetRingDim
— FunctionSetRingDim(parameters::CCParams, dimension::Integer)
Set the polynomial ring dimension
for a set of parameters
.
OpenFHE.SetScalingFactor
— FunctionSetScalingFactor(ciphertext::Ciphertext, factor::Real)
SetScalingFactor(plaintext::Plaintext, factor::Real)
Set the scaling factor
for the given ciphertext
or plaintext
.
See also: Ciphertext
, Plaintext
, GetScalingFactor
OpenFHE.SetScalingModSize
— FunctionSetScalingModSize(parameters::CCParams, modulus::Integer)
Set the scaling modulus
for a set of parameters
.
See also: SetFirstModSize
OpenFHE.SetScalingTechnique
— FunctionSetScalingTechnique(parameters::CCParams, technique::ScalingTechnique)
Set the ciphertext multiplication technique
for a set of parameters
.
See also: ScalingTechnique
OpenFHE.SetSecretKeyDist
— FunctionSetSecretKeyDist(parameters::CCParams, distribution::SecretKeyDist)
Set the distribution
from which the secret key is chosen for a set of parameters
.
See also: SecretKeyDist
OpenFHE.SetSecurityLevel
— FunctionSetSecurityLevel(parameters::CCParams, level::SecurityLevel)
Set the encryption security level
according to the homomogrphic encryption standard for a set of parameters
.
See also: SecurityLevel
OpenFHE.SetSlots
— FunctionSetSlots(ciphertext::Ciphertext, slots::Integer)
SetSlots(plaintext::Plaintext, slots::Integer)
Set the number of slots
for the given ciphertext
or plaintext
.
See also: Ciphertext
, Plaintext
, GetSlots
OpenFHE.get_native_int
— FunctionOpenFHE.get_native_int()
Return the native integer size for an OpenFHE-julia installation, it can be 64
or 128
bits.
See also: OpenFHE.set_native_int!
OpenFHE.library_path
— MethodOpenFHE.library_path()
Return the path of the OpenFHE-julia library that is used.
OpenFHE.private_key
— FunctionOpenFHE.private_key(key_pair::KeyPair)
Return the private key from a key_pair
.
See also: KeyPair
, public_key
OpenFHE.public_key
— FunctionOpenFHE.public_key(key_pair::KeyPair)
Return the public key from a key_pair
.
See also: KeyPair
, private_key
OpenFHE.set_library!
— FunctionOpenFHE.set_library!(path = nothing; force = true)
Set the absolute path
to a system-provided OpenFHE-julia installation, e.g., something like /path/to/libopenfhe_julia.<ext>
, where <ext>
is so
on Linux,
dylibon macOS, and
dllon Windows. Restart the Julia session after executing this function such that the changes take effect. Using
nothing` as the path will revert the library path to the default settings, i.e., the JLL-provided version of OpenFHE-julia will be used.
OpenFHE.set_native_int!
— FunctionOpenFHE.set_native_int!(native_int::Integer = 64)
Set the native integer size for an OpenFHE-julia installation, it can be 64
or 128
bits. Restart the Julia session after executing this function such that the changes take effect.
See also: OpenFHE.get_native_int