arnaucube
arnaucube/phantom-zonePublic Self-hosted repository
add non-standard FHE bool apis
Janmajaya Mall janmajayamall@protonmail.com
Tue, 23 Jul 2024 11:02:33 -0700
commit

b3eb7e2109d439e0048960b63f0aa3182c0e8485

parent

06474f9caec48b9b97ac0630cf680e60f44bdd70

3 files changed, 34 insertions(+), 2 deletions(-)

jump to
M Cargo.lock → Cargo.lock

@@ -352,6 +352,7 @@ "num-traits",

"rand", "rand_chacha", "rand_distr", + "rayon", ] [[package]]
M Cargo.toml → 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 = []
M src/bool/mod.rs → src/bool/mod.rs

@@ -77,6 +77,7 @@

/// Fhe Bool ciphertext #[derive(Clone)] pub struct FheBool<C> { + /// LWE bool ciphertext pub(crate) data: C, }

@@ -101,11 +102,11 @@ &self,

c: &FheBool<C>, 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<C>) -> Self::DecryptionShare { - self.gen_decryption_share(&c.data) + self.gen_decryption_share(&c.data()) } }

@@ -189,6 +190,35 @@ type Output = FheBool;

fn not(self) -> Self::Output { BoolEvaluator::with_local(|e| FheBool { data: e.not(self.data()), + }) + } + } + + 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), + } }) } }