1use serde::{Deserialize, Serialize};
2use snafu::Whatever;
3
4use crate::{mpc::circuit::MpcCircuit, mpc::scheme::MpcScheme};
5
6#[derive(Debug, Serialize, Deserialize)]
7#[serde(bound = "S: MpcScheme")]
8pub struct MpcConfig<S: MpcScheme> {
9 my_id: usize,
10 n_parties: usize,
11 circuit: MpcCircuit<S>,
12}
13
14impl<S: MpcScheme> MpcConfig<S> {
15 pub fn new(my_id: usize, n_parties: usize, circuit: MpcCircuit<S>) -> Result<Self, Whatever> {
16 if my_id >= n_parties {
17 snafu::whatever!("`my_id` must be less than `n_parties`")
18 }
19 Ok(Self {
20 my_id,
21 n_parties,
22 circuit,
23 })
24 }
25
26 pub fn my_id(&self) -> usize {
27 self.my_id
28 }
29
30 pub fn circuit(&self) -> &MpcCircuit<S> {
31 &self.circuit
32 }
33
34 pub fn scheme(&self) -> &S {
35 self.circuit.scheme()
36 }
37
38 pub fn n_parties(&self) -> usize {
39 self.n_parties
40 }
41}