add non-standard FHE bool apis

This commit is contained in:
Janmajaya Mall
2024-07-23 11:02:33 -07:00
parent 06474f9cae
commit b3eb7e2109
3 changed files with 34 additions and 2 deletions

View File

@@ -77,6 +77,7 @@ mod impl_bool_frontend {
/// Fhe Bool ciphertext
#[derive(Clone)]
pub struct FheBool<C> {
/// LWE bool ciphertext
pub(crate) data: C,
}
@@ -101,11 +102,11 @@ mod impl_bool_frontend {
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())
}
}
@@ -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),
}
})
}
}
}
}