Add Julian API for SEAL.jl #8
Labels
discussion
An open-ended discussion (as opposed to concrete problem/feature/fix etc.)
help wanted
Extra attention is needed
question
Further information is requested
Right now, the SEAL.jl API intentionally follows the SEAL C++ API very closely. The motivation for this is to make it easy to convert an example written for the SEAL C++ to SEAL.jl without having to look up different function names etc. However, this approach comes with the huge downside that it SEAL.jl is not as intuitive to use as other Julia packages. Therefore, I propose to add a Julian API on top of the C++-style API and only expose the C++ API through, e.g., a submodule. This way, it is still possible to translate C++ to Julia code almost verbatim, but anyone starting directly with SEAL.jl (without prior experience with SEAL) can have a much more user-friendly API. The downside, of course, would be that two APIs have to be kept up-to-date and that translating all operations from the "raw" C++ API is probably hard to achieve. Therefore, I think it would be sufficient to support the most common operations in the high-level API, accepting that not all functionality is exposed.
Note: This issue could also be a good starting point to discuss a possible common API for all Julia HE packages.
Note: This issue description with the proposed API will be updated frequently as work progresses.
Types
To start with, let's define some types. The idea is that all types may carry enough information (and references to other types) such that virtually all operations do not require to think about the underlying HE scheme, except where explicitly desired or where it is unavoidable. This may, of course, incur some performance penalties, which we will accept for now.
EncryptionContext
is to be a container for multiple, lower-level objects that hold all required information about encoding and encryption.Ciphertext
andPlaintext
hold references to the correspondingEncryptionContext
such that all operations are supported.Functions
Limitations
As stated above, the API might not support all possible operations directly and would also prioritize convenience over performance where it makes sense. For example, it is preferable to return new
Ciphertext
s instead of modifying them in-place, even if that increases memory requirements. Furthermore, while it should be open enough to be extensible in the future, for now only the BFV and CKKS schemes have to be supported.Open question: Encoding/encryption parameters as Julia type parameters?
Should we augment all instances of
Ciphertext
(andPlaintext
?) with parameters that encode their current encryption/encoding state? That would make them much uglier when used on the REPL (or when understanding error messages), but could allow to catch implementation errors already at compile time and add a lot of type stability to the code using the API.For example, if
Ciphertext
would carry the encodingBFV
orCKKS
, we could haveSimilarly, we could prevent operations on ciphertext of different lengths (i.e., after multiplication) or prevent users from applying operations that are only supported by one encoding (e.g., CKKS) to BFV-encoded data.
The text was updated successfully, but these errors were encountered: