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.ADVANCEDSHE — Constant
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.FHE — Constant
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_classic — Constant

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_quantum — Constant

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_classic — Constant

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_quantum — Constant

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_classic — Constant

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_quantum — Constant

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_NotSet — Constant

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.KEYSWITCH — Constant
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.LEVELEDSHE — Constant
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.MULTIPARTY — Constant
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.PKE — Constant
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.PRE — Constant
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.SCHEMESWITCH — Constant
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.CCParams — Type
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.Ciphertext — Type
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.CryptoContext — Type
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.DCRTPoly — Type
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.DecryptResult — Type
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.EncodingParams — Type
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.PKESchemeFeature — Type
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.SecurityLevel — Type

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.CloneZero — Function
CloneZero(ciphertext::Ciphertext)
Deprecated since OpenFHE v1.3.1

CloneZero has been renamed to CloneEmpty in OpenFHE v1.3.1. See https://github.com/openfheorg/openfhe-development/pull/1005. Use CloneEmpty instead. See also https://github.com/hpsc-lab/OpenFHE.jl/issues/153. CloneZero is only an alias for CloneEmpty now and will get removed in the future.

Clone the given ciphertext without its encrypted data.

See also: CloneEmpty, Ciphertext, Clone

source
OpenFHE.ComposedEvalMult — Function
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.Compress — Method
Compress(crypto_context::CryptoContext, ciphertext::Ciphertext; levels_left = 1, noise_scale_deg = 1)

Return a compressed ciphertext with modulus reduced to a number of multiplicative levels levels_left and noise scale degree noise_scale_deg.

See also: CryptoContext, Ciphertext

source
OpenFHE.Decrypt — Method
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.EvalAdd — Function
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.EvalBootstrapSetup — Method
EvalBootstrapSetup(crypto_context::CryptoContext;
                   level_budget::Vector{<:Integer} = [5, 4],
                   dim1::Vector{<:Integer} = [0, 0],
                   slots = 0,
                   correction_factor = 0,
                   precompute = true,
                   bt_slots_encoding = false)

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.EvalCos — Function
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.EvalDivide — Function
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.EvalLogistic — Function
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.EvalMult — Function
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.EvalMultNoRelin — Function
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.EvalRotate — Function
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.EvalRotateKeyGen — Method
EvalRotateKeyGen(crypto_context::CryptoContext,
                 private_key::PrivateKey,
                 index_list::Vector{<:Integer})

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, EvalRotate

source
OpenFHE.EvalSin — Function
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.EvalSquare — Function
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.EvalSub — Function
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.EvalSum — Function
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.GenCryptoContext — Function
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.GetBootstrapDepth — Method
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.GetCoefPackedValue — Function
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.GetLogError — Function
GetLogError(plaintext::Plaintext)

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

See also: Plaintext

source
OpenFHE.GetPackedValue — Function
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.GetRealPackedValue — Function
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.GetStringValue — Function
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.MakeCKKSPackedPlaintext — Method
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.MakePackedPlaintext — Method
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.RelinearizeInPlace — Function
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.SetNumLargeDigits — Function
SetNumLargeDigits(parameters::CCParams, number::Integer)

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

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

Set the polynomial ring dimension for a set of parameters.

source
OpenFHE.SetSecurityLevel — Function
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