Skip to content

Commit

Permalink
Update LBB
Browse files Browse the repository at this point in the history
Co-authored-by: Dimitris Mouris <[email protected]>
  • Loading branch information
cgouert and jimouris committed Sep 7, 2023
1 parent c1da8f6 commit 8bf09ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ impl<'a> EvalCircuit<CtxtShortInt> for LutCircuit<'a> {
{
// Evaluate all the gates in the level in parallel
gates.par_iter_mut().for_each(|gate| {
let input_values: Vec<CtxtShortInt> = gate
let mut input_values: Vec<CtxtShortInt> = gate
.get_input_wires()
.iter()
.map(|input| {
Expand All @@ -637,7 +637,7 @@ impl<'a> EvalCircuit<CtxtShortInt> for LutCircuit<'a> {
.collect();
let output_value = {
if gate.get_gate_type() == GateType::Lut {
gate.evaluate_encrypted_lut(&self.server_key, &input_values, cycle)
gate.evaluate_encrypted_lut(&self.server_key, &mut input_values, cycle)
} else {
gate.evaluate_encrypted_dff(&input_values, cycle)
}
Expand Down
9 changes: 5 additions & 4 deletions src/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl Gate {
pub fn evaluate_encrypted_lut(
&mut self,
server_key: &ServerKeyShortInt,
input_values: &Vec<CiphertextBase>,
input_values: &mut Vec<CiphertextBase>,
cycle: usize,
) -> CiphertextBase {
if let Some(encrypted_lut_output) = self.encrypted_lut_output.clone() {
Expand Down Expand Up @@ -744,13 +744,14 @@ fn eval_luts(x: u64, lut_table: &Vec<u64>) -> u64 {
pub fn lut(
sks: &ServerKeyShortInt,
lut_const: &Vec<u64>,
ctxts: &Vec<CiphertextBase>,
ctxts: &mut Vec<CiphertextBase>,
) -> CiphertextBase {
// Σ ctxts[i] * 2^i
let ctxts_len = (ctxts.len() - 1) as u8;
let ct_sum = ctxts
.iter()
.iter_mut()
.enumerate()
.map(|(i, ct)| sks.scalar_mul(ct, 1 << (ctxts.len() - 1 - i)))
.map(|(i, ct)| sks.smart_scalar_left_shift(ct, ctxts_len - i as u8))
.fold(sks.create_trivial(0), |acc, ct| sks.add(&acc, &ct));

// Generate LUT entries from lut_const
Expand Down

0 comments on commit 8bf09ba

Please sign in to comment.