diff --git a/Cargo.lock b/Cargo.lock index 47e2125..02b425f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -352,6 +352,7 @@ dependencies = [ "rand", "rand_chacha", "rand_distr", + "rayon", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f899433..ea467f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ num-bigint-dig = { version = "0.8.4", features = ["prime"] } [dev-dependencies] criterion = "0.5.1" +rayon = "1.10.0" [features] interactive_mp = [] diff --git a/src/bool/mod.rs b/src/bool/mod.rs index 9567b09..e5e90bc 100644 --- a/src/bool/mod.rs +++ b/src/bool/mod.rs @@ -77,6 +77,7 @@ mod impl_bool_frontend { /// Fhe Bool ciphertext #[derive(Clone)] pub struct FheBool { + /// LWE bool ciphertext pub(crate) data: C, } @@ -101,11 +102,11 @@ mod impl_bool_frontend { c: &FheBool, shares: &[Self::DecryptionShare], ) -> bool { - self.aggregate_decryption_shares(&c.data, shares) + self.aggregate_decryption_shares(&c.data(), shares) } fn gen_decryption_share(&self, c: &FheBool) -> Self::DecryptionShare { - self.gen_decryption_share(&c.data) + self.gen_decryption_share(&c.data()) } } @@ -192,6 +193,35 @@ mod impl_bool_frontend { }) } } + + impl FheBool { + pub fn nand(&self, rhs: &Self) -> Self { + BoolEvaluator::with_local_mut(|e| { + let key = RuntimeServerKey::global(); + FheBool { + data: e.nand(self.data(), rhs.data(), key), + } + }) + } + + pub fn xnor(&self, rhs: &Self) -> Self { + BoolEvaluator::with_local_mut(|e| { + let key = RuntimeServerKey::global(); + FheBool { + data: e.xnor(self.data(), rhs.data(), key), + } + }) + } + + pub fn nor(&self, rhs: &Self) -> Self { + BoolEvaluator::with_local_mut(|e| { + let key = RuntimeServerKey::global(); + FheBool { + data: e.nor(self.data(), rhs.data(), key), + } + }) + } + } } }