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

Function select_node

ciphercore-base/src/mpc/utils.rs:219–226  ·  view source on GitHub ↗

Selects elements of node 0 if bits of node b are zero and elements of node 1 otherwise. Broadcasting is applied # Arguments - `a0` - node 0 containing an array - `a1` - node 1 containing an array of the same type as `a` - `b` - node containing selection bits # Returns Node containing an array with selected elements of `a0` or `a1`

(b: Node, a1: Node, a0: Node)

Source from the content-addressed store, hash-verified

217///
218/// Node containing an array with selected elements of `a0` or `a1`
219pub fn select_node(b: Node, a1: Node, a0: Node) -> Result<Node> {
220 let dif = a1.subtract(a0.clone())?;
221 if dif.get_type()?.get_scalar_type() == BIT {
222 dif.multiply(b)?.add(a0)
223 } else {
224 dif.mixed_multiply(b)?.add(a0)
225 }
226}
227
228pub(super) fn convert_main_graph_to_mpc(
229 in_context: Context,

Callers 1

instantiateMethod · 0.85

Calls 7

cloneMethod · 0.80
subtractMethod · 0.45
get_scalar_typeMethod · 0.45
get_typeMethod · 0.45
addMethod · 0.45
multiplyMethod · 0.45
mixed_multiplyMethod · 0.45

Tested by

no test coverage detected