in protocol/src/cross_psi/partner.rs [247:303]
fn reveal<T: AsRef<Path>>(&self, path: T) {
if let (Ok(indices), Ok(company_key), Ok(mut self_shares), Ok(mut additive_mask)) = (
self.company_intersection_indices.clone().read(),
self.company_he_public_key.clone().read(),
self.self_shares.clone().write(),
self.additive_mask.clone().write(),
) {
let output_mod: BigUint = BigUint::one() << 64;
let mut filtered_shares: Vec<BigUint> = Vec::with_capacity(indices.len());
for index in indices.iter() {
filtered_shares.push(additive_mask[*index].clone());
}
additive_mask.clear();
let company_shares = filtered_shares
.into_par_iter()
.map(|item| {
let o_mod = output_mod.to_bigint().unwrap();
let t1 = item.to_bigint().unwrap() % &o_mod;
let t2 = company_key.n.to_bigint().unwrap() % &o_mod;
let s = (t1 - t2 + &o_mod) % o_mod;
assert!(!s.is_negative());
let (_, v) = s.to_u64_digits();
assert_eq!(v.len(), 1);
v[0]
})
.collect::<Vec<u64>>();
let partner_key = self.get_he_public_key();
let partner_shares = self_shares
.remove(&0)
.unwrap()
.into_par_iter()
.map(|item| {
let o_mod = output_mod.to_bigint().unwrap();
let t1 = item.to_bigint().unwrap() % &o_mod;
let t2 = partner_key.n.to_bigint().unwrap() % &o_mod;
let s = (t1 - t2 + &o_mod) % o_mod;
assert!(!s.is_negative());
let (_, v) = s.to_u64_digits();
assert_eq!(v.len(), 1);
v[0]
})
.collect::<Vec<u64>>();
let mut out: Vec<Vec<u64>> =
Vec::with_capacity(self.get_self_num_features() + self.get_company_num_features());
out.push(partner_shares);
out.push(company_shares);
info!("revealing columns to output file");
common::files::write_u64cols_to_file(&mut out, path).unwrap();
}
}