1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ThresholdShare {
11 pub algorithm: String,
13 pub party_index: u32,
15 pub bytes: Vec<u8>,
17}
18
19impl ThresholdShare {
20 pub fn new(algorithm: impl Into<String>, party_index: u32, bytes: Vec<u8>) -> Self {
22 Self {
23 algorithm: algorithm.into(),
24 party_index,
25 bytes,
26 }
27 }
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33
34 #[test]
35 fn share_construct() {
36 let s = ThresholdShare::new("ElGamal-P256-threshold", 0, vec![1, 2, 3]);
37 assert_eq!(s.algorithm, "ElGamal-P256-threshold");
38 assert_eq!(s.party_index, 0);
39 assert_eq!(s.bytes, vec![1, 2, 3]);
40 }
41}