Convert 3-out-of-3 to 2-out-of-3 shares
(input_shares: &Node, prf_keys: &Node)
| 244 | |
| 245 | // Convert 3-out-of-3 to 2-out-of-3 shares |
| 246 | pub(super) fn reshare(input_shares: &Node, prf_keys: &Node) -> Result<Node> { |
| 247 | let g = input_shares.get_graph(); |
| 248 | |
| 249 | let input_shares_vec: Vec<Node> = (0..PARTIES) |
| 250 | .map(|i| input_shares.tuple_get(i as u64).unwrap()) |
| 251 | .collect(); |
| 252 | let zero_shares = |
| 253 | get_zero_shares(g.clone(), prf_keys.clone(), input_shares_vec[0].get_type()?)?; |
| 254 | |
| 255 | let mut output_shares_vec = vec![]; |
| 256 | for i in 0..PARTIES { |
| 257 | // Party i masks its 3-out-of-3 share: input_i + zero_share_i |
| 258 | let masked_share = recursively_sum_shares( |
| 259 | g.clone(), |
| 260 | vec![input_shares_vec[i].clone(), zero_shares[i].clone()], |
| 261 | )?; |
| 262 | // Party i sends output share to party (i-1) |
| 263 | let sent_share = g.nop(masked_share)?; |
| 264 | let im1 = ((i + PARTIES - 1) % PARTIES) as u64; |
| 265 | sent_share.add_annotation(NodeAnnotation::Send(i as u64, im1))?; |
| 266 | output_shares_vec.push(sent_share); |
| 267 | } |
| 268 | g.create_tuple(output_shares_vec) |
| 269 | } |
| 270 | |
| 271 | #[cfg(test)] |
| 272 | mod tests { |
no test coverage detected