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,
)
| 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. |
| 1201 | pub 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> |
| 1208 | where |
| 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)] |
| 1245 | mod tests { |
no test coverage detected