API reference

Base.circshiftMethod
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!

source
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!

source
SecureArithmetic.enable_multithreadingFunction
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

source
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

source
SecureArithmetic.levelMethod
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

source
SecureArithmetic.release_context_memoryMethod
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!

source
Serialization.deserializeMethod
Serialization.deserialize(s::Serialization.AbstractSerializer,
                          ::Type{<:PrivateKey{<:OpenFHEBackend}})

Deserialize a PrivateKey. Reads the SecureContext followed by the JSON-encoded private key from the stream.

Experimental

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

source
Serialization.deserializeMethod
Serialization.deserialize(s::Serialization.AbstractSerializer,
                          ::Type{<:PublicKey{<:OpenFHEBackend}})

Deserialize a PublicKey. Reads the SecureContext followed by the JSON-encoded public key from the stream.

Experimental

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

source
Serialization.deserializeMethod
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.

Experimental

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

source
Serialization.deserializeMethod
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.

Experimental

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

source
Serialization.serializeMethod
Serialization.serialize(s::Serialization.AbstractSerializer,
                        key::PrivateKey{<:OpenFHEBackend})

Serialize a PrivateKey. The associated SecureContext is serialized first, followed by the JSON-encoded private key.

Experimental

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

source
Serialization.serializeMethod
Serialization.serialize(s::Serialization.AbstractSerializer,
                        key::PublicKey{<:OpenFHEBackend})

Serialize a PublicKey. The associated SecureContext is serialized first, followed by the JSON-encoded public key.

Experimental

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

source
Serialization.serializeMethod
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.

Experimental

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

source
Serialization.serializeMethod
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.

Experimental

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

source