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

Function compile_context

ciphercore-base/src/mpc/mpc_compiler.rs:1201–1242  ·  view source on GitHub ↗

Takes raw context (no inlining, etc.), and runs the whole pipeline (instantiation+inlining+MPC) on it, to prepare to be used in runtime.

(
    context: Context,
    input_parties: Vec<IOStatus>,
    output_parties: Vec<IOStatus>,
    inline_config: InlineConfig,
    get_evaluator: T,
)

Source from the content-addressed store, hash-verified

1199/// Takes raw context (no inlining, etc.), and runs the whole pipeline (instantiation+inlining+MPC) on it,
1200/// to prepare to be used in runtime.
1201pub fn compile_context<T, E>(
1202 context: Context,
1203 input_parties: Vec<IOStatus>,
1204 output_parties: Vec<IOStatus>,
1205 inline_config: InlineConfig,
1206 get_evaluator: T,
1207) -> Result<Context>
1208where
1209 T: Fn() -> Result<E>,
1210 E: Evaluator + Sized,
1211{
1212 let evaluator0 = get_evaluator()?;
1213 let context4 = prepare_context(context, inline_config.clone(), evaluator0, true)?;
1214 print_stats(context4.get_main_graph()?)?;
1215 let mut number_of_inputs = 0;
1216 for node in context4.get_main_graph()?.get_nodes() {
1217 if node.get_operation().is_input() {
1218 number_of_inputs += 1;
1219 }
1220 }
1221 if input_parties.len() != number_of_inputs {
1222 return Err(runtime_error!(
1223 "Invalid number of input parties: {} expected, but {} found",
1224 number_of_inputs,
1225 input_parties.len()
1226 ));
1227 }
1228 eprintln!("input_parties = {input_parties:?}");
1229 eprintln!("output_parties = {output_parties:?}");
1230 let compiled_context0 = prepare_for_mpc_evaluation(
1231 context4,
1232 vec![input_parties],
1233 vec![output_parties],
1234 inline_config,
1235 )?;
1236 print_stats(compiled_context0.get_main_graph()?)?;
1237
1238 let evaluator1 = get_evaluator()?;
1239 let compiled_context = optimize_context(compiled_context0, evaluator1)?;
1240 print_stats(compiled_context.get_main_graph()?)?;
1241 Ok(compiled_context)
1242}
1243
1244#[cfg(test)]
1245mod tests {

Callers 1

mainFunction · 0.85

Calls 10

cloneMethod · 0.80
is_inputMethod · 0.80
prepare_contextFunction · 0.70
print_statsFunction · 0.70
get_evaluatorFunction · 0.50
optimize_contextFunction · 0.50
get_main_graphMethod · 0.45
get_nodesMethod · 0.45
get_operationMethod · 0.45

Tested by

no test coverage detected