MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / reshare

Function reshare

ciphercore-base/src/mpc/resharing.rs:246–269  ·  view source on GitHub ↗

Convert 3-out-of-3 to 2-out-of-3 shares

(input_shares: &Node, prf_keys: &Node)

Source from the content-addressed store, hash-verified

244
245// Convert 3-out-of-3 to 2-out-of-3 shares
246pub(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)]
272mod tests {

Callers 3

add_3_bitstringsFunction · 0.85
compile_to_mpc_graphFunction · 0.85
general_multiply_mpcFunction · 0.85

Calls 10

get_zero_sharesFunction · 0.85
recursively_sum_sharesFunction · 0.85
cloneMethod · 0.80
add_annotationMethod · 0.80
get_graphMethod · 0.45
tuple_getMethod · 0.45
get_typeMethod · 0.45
nopMethod · 0.45
pushMethod · 0.45
create_tupleMethod · 0.45

Tested by

no test coverage detected