1#![allow(non_snake_case)]
6
7use num_bigint::BigInt;
8use num_traits::identities::Zero;
9use std::collections::BTreeMap;
10use std::vec::Vec;
11
12#[derive(Debug, Clone, Default)]
13pub struct ShareBox {
14 pub publickey: BigInt,
15 pub share: BigInt,
16 pub challenge: BigInt,
17 pub response: BigInt,
18}
19
20impl ShareBox {
21 pub fn new() -> Self {
22 ShareBox {
23 publickey: BigInt::zero(),
24 share: BigInt::zero(),
25 challenge: BigInt::zero(),
26 response: BigInt::zero(),
27 }
28 }
29
30 pub fn init(
31 &mut self,
32 publickey: BigInt,
33 share: BigInt,
34 challenge: BigInt,
35 response: BigInt,
36 ) {
37 self.publickey = publickey;
38 self.share = share;
39 self.challenge = challenge;
40 self.response = response;
41 }
42}
43
44#[derive(Debug, Clone, Default)]
47pub struct DistributionSharesBox {
48 pub commitments: Vec<BigInt>,
49 pub positions: BTreeMap<BigInt, i64>,
50 pub shares: BTreeMap<BigInt, BigInt>,
51 pub publickeys: Vec<BigInt>,
52 pub challenge: BigInt,
53 pub responses: BTreeMap<BigInt, BigInt>,
54 pub U: BigInt,
55}
56
57impl DistributionSharesBox {
58 pub fn new() -> Self {
59 DistributionSharesBox {
60 commitments: Vec::new(),
61 positions: BTreeMap::new(),
62 shares: BTreeMap::new(),
63 publickeys: Vec::new(),
64 challenge: BigInt::zero(),
65 responses: BTreeMap::new(),
66 U: BigInt::zero(),
67 }
68 }
69
70 #[allow(clippy::too_many_arguments)]
71 pub fn init(
72 &mut self,
73 commitments: &[BigInt],
74 positions: BTreeMap<BigInt, i64>,
75 shares: BTreeMap<BigInt, BigInt>,
76 publickeys: &[BigInt],
77 challenge: &BigInt,
78 responses: BTreeMap<BigInt, BigInt>,
79 U: &BigInt,
80 ) {
81 self.commitments = commitments.to_vec();
82 self.positions = positions;
83 self.shares = shares;
84 self.publickeys = publickeys.to_vec();
85 self.challenge = challenge.clone();
86 self.responses = responses;
87 self.U = U.clone();
88 }
89}