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

Method local_operation_handler

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

Local operation should propagate 3-out-of-3 sharing if at least one of the inputs is 3-out-of-3

(&mut self, node: Node)

Source from the content-addressed store, hash-verified

23
24 // Local operation should propagate 3-out-of-3 sharing if at least one of the inputs is 3-out-of-3
25 fn local_operation_handler(&mut self, node: Node) -> Result<()> {
26 let dependencies = node.get_node_dependencies();
27
28 if node.get_operation().is_broadcasting_called() {
29 // These operations might broadcast inputs.
30 // To avoid a blowup of PRFs, we compare the sizes of the input data to be reshared and the output data.
31 // If output data is larger, we perform resharing of inputs.
32
33 // Compute the size of unreshared data
34 let mut unreshared_input_size = 0;
35
36 for dep in &dependencies {
37 if self.unreshared_nodes.contains(dep) {
38 unreshared_input_size += get_size_in_bits(dep.get_type()?)?;
39 }
40 }
41
42 let output_size = get_size_in_bits(node.get_type()?)?;
43
44 if output_size > unreshared_input_size {
45 self.ensure_dependencies_are_reshared(&node);
46 } else if unreshared_input_size > 0 {
47 // This means that there is at least one 3-out-of-3 input.
48 // Thus, output should be 3-out-of-3 as well.
49 self.unreshared_nodes.insert(node);
50 }
51 } else {
52 let mut is_one_input_unreshared = false;
53 for dep in &dependencies {
54 if self.unreshared_nodes.contains(dep) {
55 is_one_input_unreshared = true;
56 }
57 }
58
59 if is_one_input_unreshared {
60 self.unreshared_nodes.insert(node);
61 }
62 }
63
64 Ok(())
65 }
66
67 fn ensure_dependencies_are_reshared(&mut self, node: &Node) {
68 for dep_node in node.get_node_dependencies() {

Callers 1

Calls 7

get_size_in_bitsFunction · 0.85
get_node_dependenciesMethod · 0.80
get_operationMethod · 0.45
get_typeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected