Browse Source

add fhebool example + fix BatchedFheBool's SampleExtract infinite loop

par-agg-key-shares
Janmajaya Mall 8 months ago
parent
commit
3587c563dc
2 changed files with 9 additions and 5 deletions
  1. +8
    -5
      src/bool/mod.rs
  2. +1
    -0
      src/bool/ni_mp_api.rs

+ 8
- 5
src/bool/mod.rs

@ -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

+ 1
- 0
src/bool/ni_mp_api.rs

@ -36,6 +36,7 @@ static BOOL_SERVER_KEY: OnceLock
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,

Loading…
Cancel
Save