API reference
SecureArithmetic.OpenFHEBackend — Type
OpenFHEBackendCryptography backend for use with the homomorphic encryption library OpenFHE (https://github.com/openfheorg/openfhe-development).
See also: SecureContext, Unencrypted
SecureArithmetic.PlainArray — Type
PlainArray{Backend, N, DataT}Holds an encoded - but not encrypted - N-dimensional array for arithmetic operations. Can be converted to a SecureArray using encrypt.
See also: SecureArray, encrypt
SecureArithmetic.PlainArray — Method
PlainArray(data::Array{<:Real}, context::SecureContext{<:OpenFHEBackend})Constructor for data type PlainArray takes an unencrypted data array and a context object of type SecureContext{<:OpenFHEBackend}. Return PlainArray with encoded but not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureArray.
See also: PlainArray, SecureArray, encrypt, decrypt OpenFHEBackend
SecureArithmetic.PlainArray — Method
PlainArray(data::Array{<:Real}, context::SecureContext{<:Unencrypted})Constructor for data type PlainArray takes an unencrypted data array and a context object of type SecureContext{<:Unencrypted}. Returns PlainArray with not encoded and not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureArray.
See also: PlainArray, SecureArray, encrypt, decrypt
SecureArithmetic.PlainMatrix — Type
PlainMatrix{Backend, DataT}Alias for PlainArray{Backend, 2, DataT}. Holds encoded - but not encrypted - matrix data for arithmetic operations. Can be converted to a SecureMatrix using encrypt.
See also: SecureMatrix, PlainArray, encrypt
SecureArithmetic.PlainMatrix — Method
PlainMatrix(data::Matrix{<:Real}, context::SecureContext{<:OpenFHEBackend})Constructor for data type PlainMatrix takes an unencrypted data matrix and a context object of type SecureContext{<:OpenFHEBackend}. Return PlainMatrix with encoded but not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureMatrix.
See also: PlainMatrix, SecureMatrix, encrypt, decrypt OpenFHEBackend
SecureArithmetic.PlainMatrix — Method
PlainMatrix(data::Matrix{<:Real}, context::SecureContext{<:Unencrypted})Constructor for data type PlainMatrix takes an unencrypted data matrix and a context object of type SecureContext{<:Unencrypted}. Returns PlainMatrix with not encoded and not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureMatrix.
See also: PlainMatrix, SecureMatrix, encrypt, decrypt
SecureArithmetic.PlainVector — Type
PlainVector{Backend, DataT}Alias for PlainArray{Backend, 1, DataT}. Holds encoded - but not encrypted - vector data for arithmetic operations. Can be converted to a SecureVector using encrypt.
See also: SecureVector, PlainArray, encrypt
SecureArithmetic.PlainVector — Method
PlainVector(data::Vector{<:Real}, context::SecureContext{<:OpenFHEBackend})Constructor for data type PlainVector takes an unencrypted data vector and a context object of type SecureContext{<:OpenFHEBackend}. Return PlainVector with encoded but not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureVector.
See also: PlainVector, SecureVector, encrypt, decrypt OpenFHEBackend
SecureArithmetic.PlainVector — Method
PlainVector(data::Vector{<:Real}, context::SecureContext{<:Unencrypted})Constructor for data type PlainVector takes an unencrypted data vector and a context object of type SecureContext{<:Unencrypted}. Returns PlainVector with not encoded and not encrypted data. The context can be utilized later for encryption using encrypt, resulting in SecureVector.
See also: PlainVector, SecureVector, encrypt, decrypt
SecureArithmetic.PrivateKey — Type
PrivateKeyHolds a private key that is used for decryption in decrypt.
See also: PlainVector, SecureVector, decrypt
SecureArithmetic.PublicKey — Type
PublicKeyHolds a public key that is used for encryption in encrypt.
See also: PlainVector, SecureVector, encrypt
SecureArithmetic.SecureArray — Type
SecureArray{Backend, N, DataT}Holds an encrypted N-dimensional array for arithmetic operations. Can be converted to a PlainArray using decrypt.
See also: PlainArray, decrypt
SecureArithmetic.SecureContext — Type
SecureContextA structure used to generalize CryptoContext defined in OpenFHE.jl for unencrypted data, to maximize utilization of the same code for both plaintext and ciphertext.
See also: OpenFHEBackend, Unencrypted
SecureArithmetic.SecureMatrix — Type
SecureMatrix{Backend, DataT}Alias for SecureArray{Backend, 2, DataT}. Holds encrypted matrix data for arithmetic operations. Can be converted to a PlainMatrix using decrypt.
See also: PlainMatrix, SecureArray, decrypt
SecureArithmetic.SecureVector — Type
SecureVector{Backend, DataT}Alias for SecureArray{Backend, 1, DataT}. Holds encrypted vector data for arithmetic operations. Can be converted to a PlainVector using decrypt.
See also: PlainVector, SecureArray, decrypt
SecureArithmetic.Unencrypted — Type
UnencryptedAn alternative backend to use instead of OpenFHEBackend to experiment with algorithms on unencrypted data.
See also: SecureContext, OpenFHEBackend
Base.circshift — Method
circshift(sa::SecureArray, shifts)Circularly shift, i.e., rotate the data in sa by shifts positions, similarly to Julia's circshift for regular arrays.
Note: If N is greater than one, this operation increases the multiplicative level by two, otherwise by one.
Note: To precompute all required rotation indexes, use init_rotation!.
See also: SecureArray, init_rotation!
Base.collect — Method
collect(plain_array::PlainArray{<:OpenFHEBackend})Decode and return the real-valued data contained in plain_array.
See also: PlainArray, OpenFHEBackend
Base.collect — Method
collect(pa::PlainArray{<:Unencrypted})Return the real-valued data contained in pa.
See also: PlainArray
Base.length — Method
length(a::Union{PlainArray, SecureArray})Return the current length of a, i.e., the number of container elements in use. Note that this might be less than its maximum capacity.
See also: capacity, SecureArray, PlainArray
Base.ndims — Method
ndims(a::Union{PlainArray, SecureArray})Return the number of dimensions of a.
See also: SecureArray, PlainArray
Base.size — Method
size(a::Union{PlainArray, SecureArray}, d::Int)Return the current length of dth dimension of a.
See also: SecureArray, PlainArray
Base.size — Method
size(a::Union{PlainArray, SecureArray})Return the current shape of a.
See also: SecureArray, PlainArray
SecureArithmetic.bootstrap! — Function
bootstrap!(secure_array::SecureArray{<:OpenFHEBackend}, num_iterations = 1,
precision = 0)Refresh a given secure_array to increase the multiplication depth. Supported for CKKS only. Please refer to the OpenFHE documentation for details on the arguments num_iterations and precision.
See also: SecureArray, OpenFHEBackend, init_bootstrapping!
SecureArithmetic.bootstrap! — Function
bootstrap!(secure_array::SecureArray{<:Unencrypted}, num_iterations = 1,
precision = 0)An empty duplicate of bootstrap! for unencrypted data.
See also: SecureArray, Unencrypted, bootstrap!, init_bootstrapping!
SecureArithmetic.capacity — Method
capacity(a::Union{PlainArray, SecureArray})Return the current capacity of a, i.e., the maximum number of elements the container may hold. Note that this might be more than its current length.
See also: length, SecureArray, PlainArray
SecureArithmetic.decrypt! — Method
decrypt!(plain_array::PlainArray, secure_array::SecureArray, private_key::PrivateKey)Decrypt secure_array using the private_key and store the result in the given plain_array.
See also: PlainArray, SecureArray, PrivateKey, decrypt
SecureArithmetic.decrypt — Method
decrypt(secure_array::SecureArray, private_key::PrivateKey)Decrypt secure_array using the private_key and return the resulting PlainArray.
See also: PlainArray, SecureArray, PrivateKey, decrypt!
SecureArithmetic.disable_multithreading — Method
disable_multithreading()Disable multithreaded execution. To enable multithreading, use enable_multithreading.
See also: enable_multithreading
SecureArithmetic.enable_multithreading — Function
enable_multithreading(enabled=true)Enable multithreaded execution when enabled is set to true. To disable multithreading, use disable_multithreading.
This multithreading capability takes place entirely on the Julia side and parallelizes operations over multiple ciphertexts within a single SecureArray. That is, it will have no effect if only one ciphertext is sufficient to hold all data. Please be aware that mixing Julia's multithreading with OpenFHE's builtin OpenMP-based multithreading might cause troubles. Thus if in doubt, set the environment variable OMP_NUM_THREADS=1 to avoid potential issues.
Note: By default multithreading is disabled.
See also: disable_multithreading
SecureArithmetic.encrypt — Method
encrypt(data::Array{<:Real}, public_key::PublicKey, context::SecureContext)Encrypt data into a SecureArray using the public_key derived for the given context.
See also: SecureArray, PublicKey, SecureContext, decrypt
SecureArithmetic.encrypt — Method
encrypt(plain_array::PlainArray, public_key::PublicKey)Encrypt plain_array into a SecureArray using the public_key.
See also: PlainArray, SecureArray, PublicKey, decrypt
SecureArithmetic.generate_keys — Method
generate_keys(context::SecureContext{<:OpenFHEBackend})Generate and return public and private keys.
See also: PublicKey, PrivateKey, SecureContext, OpenFHEBackend
SecureArithmetic.generate_keys — Method
generate_keys(context::SecureContext{<:Unencrypted})Return public and private keys for use with unencrypted data.
See also: PublicKey, PrivateKey, SecureContext, Unencrypted
SecureArithmetic.get_crypto_context — Method
get_crypto_context(context::SecureContext{<:OpenFHEBackend})Return a OpenFHE.CryptoContext object stored in a given context.
See also: SecureContext, OpenFHEBackend
SecureArithmetic.get_crypto_context — Method
get_crypto_context(a::Union{SecureArray{<:OpenFHEBackend},
PlainArray{<:OpenFHEBackend}})Return a OpenFHE.CryptoContext object stored in a.
See also: SecureContext, SecureArray, PlainArray, OpenFHEBackend
SecureArithmetic.init_bootstrapping! — Method
init_bootstrapping!(context::SecureContext{<:OpenFHEBackend},
private_key::PrivateKey)Generate the necessary keys from private_key to enable bootstrapping for a given context. Supported for CKKS only.
See also: SecureContext, OpenFHEBackend, PrivateKey, bootstrap!
SecureArithmetic.init_bootstrapping! — Method
init_bootstrapping!(context::SecureContext{<:Unencrypted}, private_key::PrivateKey)An empty duplicate of init_bootstrapping! for unencrypted data.
See also: SecureContext, Unencrypted, PrivateKey, init_bootstrapping!
SecureArithmetic.init_multiplication! — Method
init_multiplication!(context::SecureContext{<:OpenFHEBackend},
private_key::PrivateKey)Generate relinearization key for use with OpenFHE.EvalMult using the private_key, and store it in the given context.
See also: SecureContext, OpenFHEBackend, PrivateKey
SecureArithmetic.init_multiplication! — Method
init_multiplication!(context::SecureContext{<:Unencrypted}, private_key::PrivateKey)An empty duplicate of init_multiplication! for unencrypted data.
See also: SecureContext, Unencrypted, PrivateKey, init_multiplication!
SecureArithmetic.init_rotation! — Method
init_rotation!(context::SecureContext{<:Unencrypted}, private_key::PrivateKey,
shape, shifts...)An empty duplicate of init_rotation! for unencrypted data.
See also: SecureContext, Unencrypted, PrivateKey, init_rotation!
SecureArithmetic.init_rotation! — Method
init_rotation!(context::SecureContext{<:OpenFHEBackend}, private_key::PrivateKey,
shape::Union{Integer, NTuple{N, Integer}}, shifts...)Generate all required rotation keys for applying shifts with circshift for arrays of the given shape using the private_key. The keys are stored in the given context.
See also: SecureContext, OpenFHEBackend, PrivateKey
SecureArithmetic.level — Method
level(a::Union{SecureArray{<:OpenFHEBackend}, PlainArray{<:OpenFHEBackend}})Return the number of scalings, referred to as the level, performed over a.
See also: PlainArray, SecureArray, OpenFHEBackend
SecureArithmetic.level — Method
level(a::Union{SecureArray{<:Unencrypted}, PlainArray{<:Unencrypted}})Return the number of scalings, referred to as the level, performed over a. For data type derived from Unencrypted, the level is always equal to 0.
See also: PlainArray, SecureArray
SecureArithmetic.release_context_memory — Method
release_context_memory()Release all OpenFHE.CryptoContexts and keys for multiplication, rotation, bootstrapping and OpenFHE.EvalSum generated in the functions init_multiplication!, init_rotation!, init_bootstrapping! and OpenFHE.EvalSumKeyGen.
In the source code of OpenFHE C++, all CryptoContexts and keys are stored in static objects. Without using release_context_memory, the memory allocated for these contexts and keys will only be freed after restarting the Julia REPL. It is also advisable to call GC.gc() after a call to release_context_memory to clean up all memory on the Julia side.
See also: init_multiplication!, init_rotation!, init_bootstrapping!
Serialization.deserialize — Method
Serialization.deserialize(s::Serialization.AbstractSerializer,
::Type{<:PrivateKey{<:OpenFHEBackend}})Deserialize a PrivateKey. Reads the SecureContext followed by the JSON-encoded private key from the stream.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: PrivateKey, SecureContext, OpenFHEBackend
Serialization.deserialize — Method
Serialization.deserialize(s::Serialization.AbstractSerializer,
::Type{<:PublicKey{<:OpenFHEBackend}})Deserialize a PublicKey. Reads the SecureContext followed by the JSON-encoded public key from the stream.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: PublicKey, SecureContext, OpenFHEBackend
Serialization.deserialize — Method
Serialization.deserialize(s::Serialization.AbstractSerializer,
::Type{<:SecureArray{<:OpenFHEBackend}})Deserialize a SecureArray. Reads the SecureContext, array shape, capacity, and each JSON-encoded ciphertext from the stream, then reconstructs the SecureArray.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: SecureArray, SecureContext, OpenFHEBackend
Serialization.deserialize — Method
Serialization.deserialize(s::Serialization.AbstractSerializer,
::Type{<:SecureContext{<:OpenFHEBackend}})Deserialize a SecureContext. Reads a JSON string from the stream and reconstructs the OpenFHE.CryptoContext via OpenFHE.DeserializeFromString. Any serialized eval keys (multiplication and automorphism/rotation) are loaded into the OpenFHE key cache.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: SecureContext, OpenFHEBackend
Serialization.serialize — Method
Serialization.serialize(s::Serialization.AbstractSerializer,
key::PrivateKey{<:OpenFHEBackend})Serialize a PrivateKey. The associated SecureContext is serialized first, followed by the JSON-encoded private key.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: PrivateKey, SecureContext, OpenFHEBackend
Serialization.serialize — Method
Serialization.serialize(s::Serialization.AbstractSerializer,
key::PublicKey{<:OpenFHEBackend})Serialize a PublicKey. The associated SecureContext is serialized first, followed by the JSON-encoded public key.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: PublicKey, SecureContext, OpenFHEBackend
Serialization.serialize — Method
Serialization.serialize(s::Serialization.AbstractSerializer,
sa::SecureArray{<:OpenFHEBackend})Serialize a SecureArray. The associated SecureContext, array shape, capacity, and each ciphertext (as JSON strings) are written into the stream in order.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: SecureArray, SecureContext, OpenFHEBackend
Serialization.serialize — Method
Serialization.serialize(s::Serialization.AbstractSerializer,
ctx::SecureContext{<:OpenFHEBackend})Serialize a SecureContext. The underlying OpenFHE.CryptoContext is converted to a JSON string via OpenFHE.SerializeToString and written into the Julia serialization stream, followed by any eval keys (multiplication and automorphism/rotation) present in the OpenFHE key cache for this context.
This serialization interface is experimental and may change or be removed in non-breaking releases. Julia's Serialization format is not stable across Julia versions, so serialized data may not be readable after a Julia upgrade.
See also: SecureContext, OpenFHEBackend