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.

Dereferencing shared pointer objects

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.ADVANCEDSHEConstant
PKESchemeFeature

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

source
OpenFHE.FHEConstant
PKESchemeFeature

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

source
OpenFHE.HEStd_128_classicConstant

SecurityLevel 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

source
OpenFHE.HEStd_128_quantumConstant

SecurityLevel 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

source
OpenFHE.HEStd_192_classicConstant

SecurityLevel 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

source
OpenFHE.HEStd_192_quantumConstant

SecurityLevel 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

source
OpenFHE.HEStd_256_classicConstant

SecurityLevel 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

source
OpenFHE.HEStd_256_quantumConstant

SecurityLevel 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

source
OpenFHE.HEStd_NotSetConstant

SecurityLevel 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

source
OpenFHE.KEYSWITCHConstant
PKESchemeFeature

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

source
OpenFHE.LEVELEDSHEConstant
PKESchemeFeature

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

source
OpenFHE.MULTIPARTYConstant
PKESchemeFeature

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

source
OpenFHE.PKEConstant
PKESchemeFeature

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

source
OpenFHE.PREConstant
PKESchemeFeature

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

source
OpenFHE.SCHEMESWITCHConstant
PKESchemeFeature

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

source
OpenFHE.CCParamsType
CCParams{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

source
OpenFHE.CiphertextType
Ciphertext{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.

See also: Plaintext, Encrypt

source
OpenFHE.CryptoContextType
CryptoContext{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

source
OpenFHE.DCRTPolyType
DCRTPoly

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

source
OpenFHE.DecryptResultType
OpenFHE.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

source
OpenFHE.EncodingParamsType
EncodingParams

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.

source
OpenFHE.PKESchemeFeatureType
PKESchemeFeature

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

source
OpenFHE.SecurityLevelType

SecurityLevel 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

source
OpenFHE.ComposedEvalMultFunction
ComposedEvalMult(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

source
OpenFHE.DecryptMethod
Decrypt(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

source
OpenFHE.EvalAddFunction
EvalAdd(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

source
OpenFHE.EvalBootstrapSetupMethod
EvalBootstrapSetup(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

source
OpenFHE.EvalCosFunction
EvalCos(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

source
OpenFHE.EvalDivideFunction
EvalDivide(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

source
OpenFHE.EvalLogisticFunction
EvalLogistic(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

source
OpenFHE.EvalMultFunction
EvalMult(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

source
OpenFHE.EvalMultNoRelinFunction
EvalMultNoRelin(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

source
OpenFHE.EvalRotateFunction
EvalRotate(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

source
OpenFHE.EvalRotateKeyGenMethod
EvalRotateKeyGen(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 givencrypto_context`. Please refer to the OpenFHE documentation for details on the remaining arguments.

See also: CryptoContext, PrivateKey, PublicKey, EvalRotate

source
OpenFHE.EvalSinFunction
EvalSin(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

source
OpenFHE.EvalSquareFunction
EvalSquare(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

source
OpenFHE.EvalSubFunction
EvalSub(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

source
OpenFHE.EvalSumFunction
EvalSum(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

source
OpenFHE.GenCryptoContextFunction
GenCryptoContext(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

source
OpenFHE.GetBootstrapDepthMethod
GetBootstrapDepth(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

source
OpenFHE.GetCoefPackedValueFunction
GetCoefPackedValue(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

source
OpenFHE.GetLogErrorFunction
GetLogError(plaintext::Plaintext)

Return log2 of estimated standard deviation of approximation for a given plaintext.

See also: Plaintext

source
OpenFHE.GetPackedValueFunction
GetPackedValue(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

source
OpenFHE.GetRealPackedValueFunction
GetRealPackedValue(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

source
OpenFHE.GetStringValueFunction
GetStringValue(plaintext::Plaintext)::String

Return data as string for a given plaintext.

Note: Only supported for schemes that encode data as string!

See also: Plaintext

source
OpenFHE.MakeCKKSPackedPlaintextMethod
MakeCKKSPackedPlaintext(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

source
OpenFHE.MakePackedPlaintextMethod
MakePackedPlaintext(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

source
OpenFHE.RelinearizeInPlaceFunction
RelinearizeInPlace(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

source
OpenFHE.SetNumLargeDigitsFunction
SetNumLargeDigits(parameters::CCParams, number::Integer)

Set the number of large digits for a set of parameters.

source
OpenFHE.SetRingDimFunction
SetRingDim(parameters::CCParams, dimension::Integer)

Set the polynomial ring dimension for a set of parameters.

source
OpenFHE.SetSecurityLevelFunction
SetSecurityLevel(parameters::CCParams, level::SecurityLevel)

Set the encryption security level according to the homomogrphic encryption standard for a set of parameters.

See also: SecurityLevel

source
OpenFHE.set_library!Function
OpenFHE.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, anddllon Windows. Restart the Julia session after executing this function such that the changes take effect. Usingnothing` as the path will revert the library path to the default settings, i.e., the JLL-provided version of OpenFHE-julia will be used.

source
OpenFHE.set_native_int!Function
OpenFHE.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

source