mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-09 15:41:30 +01:00
add non-standard FHE bool apis
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -352,6 +352,7 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_distr",
|
"rand_distr",
|
||||||
|
"rayon",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ num-bigint-dig = { version = "0.8.4", features = ["prime"] }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.5.1"
|
criterion = "0.5.1"
|
||||||
|
rayon = "1.10.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
interactive_mp = []
|
interactive_mp = []
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ mod impl_bool_frontend {
|
|||||||
/// Fhe Bool ciphertext
|
/// Fhe Bool ciphertext
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FheBool<C> {
|
pub struct FheBool<C> {
|
||||||
|
/// LWE bool ciphertext
|
||||||
pub(crate) data: C,
|
pub(crate) data: C,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +102,11 @@ mod impl_bool_frontend {
|
|||||||
c: &FheBool<C>,
|
c: &FheBool<C>,
|
||||||
shares: &[Self::DecryptionShare],
|
shares: &[Self::DecryptionShare],
|
||||||
) -> bool {
|
) -> 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 {
|
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),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user