primitives/sharing/
mod.rs1pub mod authenticated;
3pub mod reconstructible;
4pub mod threat_model;
5pub mod unauthenticated;
6
7use std::{
8 fmt::Debug,
9 ops::{Add, Neg, Sub},
10};
11
12pub use authenticated::*;
13pub use reconstructible::Reconstructible;
14use serde::{de::DeserializeOwned, Serialize};
15pub use threat_model::*;
16pub use unauthenticated::*;
17use wincode::{SchemaRead, SchemaWrite};
18
19pub trait SecretShare:
22 Reconstructible
23 + PlaintextOps<<Self as Reconstructible>::Value>
24 + Clone
25 + Debug
26 + Send
27 + Sync
28 + 'static
29 + PartialEq
30 + Serialize
31 + DeserializeOwned
32 + SchemaWrite<Src = Self>
33 + for<'de> SchemaRead<'de, Dst = Self>
34 + for<'a> Add<&'a Self, Output = Self>
35 + for<'s> Sub<&'s Self, Output = Self>
36 + Neg<Output = Self>
37{
38}
39
40impl<T> SecretShare for T where
41 T: Reconstructible
42 + PlaintextOps<<Self as Reconstructible>::Value>
43 + Clone
44 + Debug
45 + Send
46 + Sync
47 + 'static
48 + PartialEq
49 + Serialize
50 + DeserializeOwned
51 + SchemaWrite<Src = Self>
52 + for<'de> SchemaRead<'de, Dst = Self>
53 + for<'a> Add<&'a Self, Output = Self>
54 + for<'a> Sub<&'a Self, Output = Self>
55 + Neg<Output = Self>
56{
57}
58
59pub trait PlaintextOps<Plaintext = <Self as Reconstructible>::Value>: Reconstructible {
64 fn add_plaintext(self, ptx: &Plaintext, is_first_peer: bool) -> Self;
66
67 fn sub_plaintext(self, ptx: &Plaintext, is_first_peer: bool) -> Self;
69}