Bfv API update
This commit is contained in:
parent
5ad59651bc
commit
36c9ab36cf
@ -42,33 +42,37 @@ struct plaintext {
|
||||
|
||||
using ciphertext = int;
|
||||
|
||||
// TODO -> Exception with enum that differentiates reason (e.g. CONTEXT_NO_PRIVATE)
|
||||
|
||||
// Inheriting from context class allows pluggability of implementations (e.g. SEAL vs. GPU)
|
||||
|
||||
class context {
|
||||
public:
|
||||
context(const context& other) = delete;
|
||||
context(context&& other) noexcept;
|
||||
context& operator=(const context& other) = delete;
|
||||
context& operator=(context&& other) noexcept;
|
||||
struct context {
|
||||
static constexpr int PUBLIC_COMPONENT = 1;
|
||||
static constexpr int PRIVATE_COMPONENT = 2;
|
||||
|
||||
context();
|
||||
virtual ~context();
|
||||
|
||||
virtual bool allocate(ciphertext& ct) = 0;
|
||||
virtual bool free(ciphertext ct) = 0;
|
||||
virtual bool serialize(ciphertext ct, void* buf, std::size_t& n) = 0;
|
||||
virtual bool deserialize(ciphertext ct, const void* buf, std::size_t n) = 0;
|
||||
virtual bool encrypt(const plaintext& pt, ciphertext ct) = 0;
|
||||
virtual bool decrypt(ciphertext ct, plaintext& pt) = 0;
|
||||
virtual bool add_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) = 0;
|
||||
virtual bool add_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) = 0;
|
||||
virtual bool sub_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) = 0;
|
||||
virtual bool sub_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) = 0;
|
||||
virtual bool mul_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) = 0;
|
||||
virtual bool mul_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) = 0;
|
||||
virtual bool rot_cipher_rows(ciphertext ct, int r, ciphertext res) = 0;
|
||||
virtual bool swap_cipher_rows(ciphertext ct, ciphertext res) = 0;
|
||||
virtual bool noise_budget(ciphertext ct, std::size_t& budget) = 0;
|
||||
virtual void new_components(int components) = 0; // context default constructs empty
|
||||
virtual void has_components(int components) const = 0;
|
||||
virtual void clone_components(int components, std::shared_ptr<context>& ptr) const = 0;
|
||||
// virtual void dump_components(int components, void* buf, std::size_t& n) const = 0;
|
||||
// virtual void load_components(int components, const void* buf, std::size_t n) = 0;
|
||||
|
||||
virtual void allocate(ciphertext& ct) = 0;
|
||||
virtual void free(ciphertext ct) = 0;
|
||||
virtual void serialize(ciphertext ct, void* buf, std::size_t& n) const = 0;
|
||||
virtual void deserialize(ciphertext ct, const void* buf, std::size_t n) const = 0;
|
||||
virtual void encrypt(const plaintext& pt, ciphertext ct) const = 0;
|
||||
virtual void decrypt(ciphertext ct, plaintext& pt) const = 0; // private
|
||||
virtual void add_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) const = 0;
|
||||
virtual void add_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) const = 0;
|
||||
virtual void sub_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) const = 0;
|
||||
virtual void sub_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) const = 0;
|
||||
virtual void mul_cipher_plain(ciphertext a, const plaintext& b, ciphertext res) const = 0;
|
||||
virtual void mul_cipher_cipher(ciphertext a, ciphertext b, ciphertext res) const = 0;
|
||||
virtual void rot_cipher_rows(ciphertext ct, int r, ciphertext res) const = 0;
|
||||
virtual void swap_cipher_rows(ciphertext ct, ciphertext res) const = 0;
|
||||
virtual void noise_budget(ciphertext ct, std::size_t& budget) const = 0; // private
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user