From 7bcec991aec8dedb5a7cc98f6bb8d8a9be9308b5 Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr Date: Thu, 20 Nov 2025 23:24:34 +0100 Subject: [PATCH] BFV API design --- include/bfv.hpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/include/bfv.hpp b/include/bfv.hpp index 7ecd0cf..10488b8 100644 --- a/include/bfv.hpp +++ b/include/bfv.hpp @@ -3,21 +3,35 @@ namespace homcert::bfv { /* -Note -> Ciphertexts track what parts of them are actually utilized! +TODO +Device handles pluggability of implementations (e.g. SEAL vs. GPU) +Operations are queued on device so the device can parallelize ops */ -class handle { - // handles reference counting and garbage collection -}; - -class device { - // ... -public: - virtual handle make_context() = 0; - virtual handle allocate_plaintext() = 0; - virtual handle allocate_ciphertext() = 0; - virtual void enqueue_op() = 0; - virtual void process_queue() = 0; -}; +/* +No device class at all, just the context class which is handed to system as shared_ptr +activate_context(std::shared_ptr ctx) -> thread local pointer is set +Raw ciphertext and plaintext classes always have the full 8192 coefficients (defined in context as static constexpr) +bfv::vector<...> + -> can be plaintext or ciphertext + -> can be base (owns plain-/ciphertext) or component (view to part of base) + -> can be local or remote + -> can be a single vector or multiple vectors/components (variadic) + -> arithmetic with component masks it out + -> arithmetic with base does operation on all components + -> tracks multiplicative depth + -> warning/error if multiplicative depth exceeds limit + -> use bootstrap member function to handle the warnings/errors + -> callbacks to reach peer in context + -> bootstrap_client (unchecked, just raw bootstrap, checks happen at an upper layer using other callbacks) + -> bootstrap_server_await (waits for client to make request) + -> bootstrap_server_serve (called immediately after request received with value to be returned) + -> automatically does secure reveal when cipher is transformed to plain + -> queues operations until used (cast to plaintext, communication with peer) +Programs are defined TWICE + -> local stuff is executed + -> remote stuff is hosted (e.g. bootstrapping server) + -> defined once from each side (differ e.g. in the plaintext inputs etc.) +*/ }