in protocol/src/private_id_multi_key/company.rs [80:120]
fn set_encrypted_company(
&self,
name: String,
data: TPayload,
psum: Vec<usize>,
) -> Result<(), ProtocolError> {
// This is an array of exclusive-inclusive prefix sum - hence number of keys
// is one less than length
let num_keys = psum.len() - 1;
// Unflatten
let mut x = {
let t = self.ec_cipher.to_points(&data);
psum.get(0..num_keys)
.unwrap()
.iter()
.zip_eq(psum.get(1..num_keys + 1).unwrap().iter())
.map(|(&x1, &x2)| t.get(x1..x2).unwrap().to_vec())
.collect::<Vec<Vec<_>>>()
};
assert_eq!(x.len(), num_keys);
match name.as_str() {
"e_company" => self
.e_company
.clone()
.write()
.map(|mut d| {
let t = timer::Timer::new_silent("Load e_company");
d.clear();
d.extend(x.drain(..));
t.qps("deserialize", data.len());
})
.map_err(|_| {
ProtocolError::ErrorDeserialization("Cannot load e_company".to_string())
}),
_ => panic!("wrong name"),
}
}