| 570 | } |
| 571 | |
| 572 | fn conversion_test(op: Operation, st: ScalarType) -> Result<()> { |
| 573 | let helper = |input: Vec<u128>, |
| 574 | input_status: IOStatus, |
| 575 | output_parties: Vec<IOStatus>, |
| 576 | inline_config: InlineConfig, |
| 577 | t: Type| |
| 578 | -> Result<()> { |
| 579 | if let Operation::B2A(st_b2a) = op.clone() { |
| 580 | if st_b2a != st { |
| 581 | panic!("The scalar type of B2A should be equal to the input scalar type"); |
| 582 | } |
| 583 | } |
| 584 | let mpc_context = prepare_context( |
| 585 | op.clone(), |
| 586 | input_status.clone(), |
| 587 | output_parties.clone(), |
| 588 | t.clone(), |
| 589 | inline_config, |
| 590 | )?; |
| 591 | let mpc_graph = mpc_context.get_main_graph()?; |
| 592 | |
| 593 | let inputs = prepare_input(op.clone(), input.clone(), input_status.clone(), t.clone())?; |
| 594 | |
| 595 | check_output( |
| 596 | op.clone(), |
| 597 | mpc_graph, |
| 598 | inputs, |
| 599 | input.clone(), |
| 600 | output_parties, |
| 601 | t.clone(), |
| 602 | )?; |
| 603 | |
| 604 | Ok(()) |
| 605 | }; |
| 606 | let inline_config_simple = InlineConfig { |
| 607 | default_mode: InlineMode::Simple, |
| 608 | ..Default::default() |
| 609 | }; |
| 610 | let helper_runs = |inputs: Vec<u128>, t: Type| -> Result<()> { |
| 611 | helper( |
| 612 | inputs.clone(), |
| 613 | IOStatus::Party(2), |
| 614 | vec![IOStatus::Party(0), IOStatus::Party(1), IOStatus::Party(2)], |
| 615 | inline_config_simple.clone(), |
| 616 | t.clone(), |
| 617 | )?; |
| 618 | helper( |
| 619 | inputs.clone(), |
| 620 | IOStatus::Party(2), |
| 621 | vec![IOStatus::Party(0), IOStatus::Party(1)], |
| 622 | inline_config_simple.clone(), |
| 623 | t.clone(), |
| 624 | )?; |
| 625 | helper( |
| 626 | inputs.clone(), |
| 627 | IOStatus::Party(2), |
| 628 | vec![IOStatus::Party(0)], |
| 629 | inline_config_simple.clone(), |