mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-09 15:41:30 +01:00
add fhebool example + fix BatchedFheBool's SampleExtract infinite loop
This commit is contained in:
@@ -267,17 +267,19 @@ mod common_mp_enc_dec {
|
|||||||
{
|
{
|
||||||
fn extract_all(&self) -> Vec<FheBool<M::R>> {
|
fn extract_all(&self) -> Vec<FheBool<M::R>> {
|
||||||
if self.data.len() > 0 {
|
if self.data.len() > 0 {
|
||||||
let ring_size = self.data[0].dimension().0;
|
let ring_size = self.data[0].dimension().1;
|
||||||
|
|
||||||
let index = 0;
|
let mut index = 0;
|
||||||
let mut out = Vec::with_capacity(self.count);
|
let mut out = Vec::with_capacity(self.count);
|
||||||
|
|
||||||
while index < self.count {
|
while index < self.count {
|
||||||
let row = index % ring_size;
|
let row = index % ring_size;
|
||||||
let col = index / ring_size;
|
let col = index / ring_size;
|
||||||
|
|
||||||
out.push(FheBool {
|
out.push(FheBool {
|
||||||
data: SampleExtractor::extract_at(&self.data[col], row),
|
data: SampleExtractor::extract_at(&self.data[col], row),
|
||||||
});
|
});
|
||||||
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out
|
out
|
||||||
@@ -288,7 +290,7 @@ mod common_mp_enc_dec {
|
|||||||
fn extract_at(&self, index: usize) -> FheBool<M::R> {
|
fn extract_at(&self, index: usize) -> FheBool<M::R> {
|
||||||
assert!(self.count > index);
|
assert!(self.count > index);
|
||||||
|
|
||||||
let ring_size = self.data[0].dimension().0;
|
let ring_size = self.data[0].dimension().1;
|
||||||
let row = index % ring_size;
|
let row = index % ring_size;
|
||||||
let col = index / ring_size;
|
let col = index / ring_size;
|
||||||
|
|
||||||
@@ -299,9 +301,9 @@ mod common_mp_enc_dec {
|
|||||||
|
|
||||||
fn extract_many(&self, how_many: usize) -> Vec<FheBool<M::R>> {
|
fn extract_many(&self, how_many: usize) -> Vec<FheBool<M::R>> {
|
||||||
assert!(self.count >= how_many);
|
assert!(self.count >= how_many);
|
||||||
let ring_size = self.data[0].dimension().0;
|
let ring_size = self.data[0].dimension().1;
|
||||||
|
|
||||||
let index = 0;
|
let mut index = 0;
|
||||||
let mut out = Vec::with_capacity(self.count);
|
let mut out = Vec::with_capacity(self.count);
|
||||||
|
|
||||||
while index < how_many {
|
while index < how_many {
|
||||||
@@ -310,6 +312,7 @@ mod common_mp_enc_dec {
|
|||||||
out.push(FheBool {
|
out.push(FheBool {
|
||||||
data: SampleExtractor::extract_at(&self.data[col], row),
|
data: SampleExtractor::extract_at(&self.data[col], row),
|
||||||
});
|
});
|
||||||
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out
|
out
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ static BOOL_SERVER_KEY: OnceLock<ShoupNonInteractiveServerKeyEvaluationDomain<Ve
|
|||||||
|
|
||||||
static MULTI_PARTY_CRS: OnceLock<NonInteractiveMultiPartyCrs<[u8; 32]>> = OnceLock::new();
|
static MULTI_PARTY_CRS: OnceLock<NonInteractiveMultiPartyCrs<[u8; 32]>> = OnceLock::new();
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum ParameterSelector {
|
pub enum ParameterSelector {
|
||||||
NonInteractiveLTE2Party,
|
NonInteractiveLTE2Party,
|
||||||
NonInteractiveLTE4Party,
|
NonInteractiveLTE4Party,
|
||||||
|
|||||||
Reference in New Issue
Block a user