Skip to content

Commit

Permalink
Simplify macint generation in fabitn
Browse files Browse the repository at this point in the history
  • Loading branch information
kisakishy committed Sep 10, 2024
1 parent 76b2a92 commit fe4e09e
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/faand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,31 +224,26 @@ pub(crate) async fn fabitn(
}

// Step 3 including verification of macs and keys.
let mut rbits: Vec<Vec<bool>> = Vec::with_capacity(two_rho);
let mut xjs = Vec::with_capacity(two_rho);
let mut macint: Vec<Vec<u128>> = vec![vec![0; two_rho]; p_max];
for i in 0..two_rho {
let (rbits, xjs): (Vec<_>, Vec<_>) = (0..two_rho)
.map(|_| {
let r: Vec<bool> = (0..len_abit).map(|_| shared_rng.gen()).collect();
let xj = x
.iter()
let xj = x.iter()
.zip(&r)
.map(|(&xb, &rb)| xb & rb)
.fold(false, |acc, val| acc ^ val);
for p in (0..p_max).filter(|&p| p != p_own) {
.fold(false, |acc, (&xb, &rb)| acc ^ (xb & rb));
(r, xj)
})
.unzip();

for p in (0..p_max).filter(|p| *p != p_own) {
let mut msg = Vec::with_capacity(two_rho);
for (r, xj) in rbits.iter().zip(xjs.iter()) {
let mut macint = 0;
for (j, &rbit) in r.iter().enumerate() {
if rbit {
macint[p][i] ^= xmacs[p][j];
macint ^= xmacs[p][j];
}
}
}
rbits.push(r);
xjs.push(xj);
}

for p in (0..p_max).filter(|p| *p != p_own) {
let mut msg = Vec::with_capacity(two_rho);
for (j, xj) in xjs.iter().copied().enumerate() {
msg.push((xj, macint[p][j]));
msg.push((*xj, macint));
}
channel.send_to(p, "fabitn", &msg).await?;
}
Expand Down

0 comments on commit fe4e09e

Please sign in to comment.