(input: Vec<u128>, input_status: IOStatus, t: Type)
| 480 | } |
| 481 | |
| 482 | fn prepare_input(input: Vec<u128>, input_status: IOStatus, t: Type) -> Result<Vec<Value>> { |
| 483 | let mpc_input = match t { |
| 484 | Type::Scalar(st) => { |
| 485 | if input_status == IOStatus::Public || matches!(input_status, IOStatus::Party(_)) { |
| 486 | return Ok(vec![Value::from_scalar(input[0], st)?]); |
| 487 | } |
| 488 | |
| 489 | // shares of input = (input - 3, 1, 2) |
| 490 | let mut shares_vec = vec![]; |
| 491 | shares_vec.push(Value::from_scalar( |
| 492 | subtract_vectors_u128(&input, &[3], st.get_modulus())?[0], |
| 493 | st, |
| 494 | )?); |
| 495 | |
| 496 | for i in 1..PARTIES as u64 { |
| 497 | shares_vec.push(Value::from_scalar(i, st)?); |
| 498 | } |
| 499 | shares_vec |
| 500 | } |
| 501 | Type::Array(_, st) => { |
| 502 | if input_status == IOStatus::Public || matches!(input_status, IOStatus::Party(_)) { |
| 503 | return Ok(vec![Value::from_flattened_array(&input, st)?]); |
| 504 | } |
| 505 | |
| 506 | // shares of input = (input - 3, 1, 2) |
| 507 | let mut shares_vec = vec![]; |
| 508 | let threes = vec![3; input.len()]; |
| 509 | let first_share = subtract_vectors_u128(&input, &threes, st.get_modulus())?; |
| 510 | shares_vec.push(Value::from_flattened_array(&first_share, st)?); |
| 511 | |
| 512 | for i in 1..PARTIES { |
| 513 | let share = vec![i; input.len()]; |
| 514 | shares_vec.push(Value::from_flattened_array(&share, st)?); |
| 515 | } |
| 516 | shares_vec |
| 517 | } |
| 518 | _ => { |
| 519 | panic!("Shouldn't be here"); |
| 520 | } |
| 521 | }; |
| 522 | |
| 523 | Ok(vec![Value::from_vector(mpc_input)]) |
| 524 | } |
| 525 | |
| 526 | // output and expected are assumed to be small enough to be converted to i64 slices |
| 527 | fn compare_truncate_output( |
no test coverage detected