Add feature-gated serde support for Participant/ThresholdParams

These don't have secret data yet sometimes have value to be communicated.
This commit is contained in:
Luke Parker 2023-03-07 03:13:55 -05:00
parent b1ea2dfba6
commit 1a99629a4a
No known key found for this signature in database
3 changed files with 6 additions and 0 deletions

1
Cargo.lock generated
View file

@ -1699,6 +1699,7 @@ dependencies = [
"multiexp", "multiexp",
"rand_core 0.6.4", "rand_core 0.6.4",
"schnorr-signatures", "schnorr-signatures",
"serde",
"thiserror", "thiserror",
"zeroize", "zeroize",
] ]

View file

@ -19,6 +19,8 @@ rand_core = "0.6"
zeroize = { version = "^1.5", features = ["zeroize_derive"] } zeroize = { version = "^1.5", features = ["zeroize_derive"] }
serde = { version = "1", features = ["derive"], optional = true }
transcript = { package = "flexible-transcript", path = "../transcript", version = "0.2", features = ["recommended"] } transcript = { package = "flexible-transcript", path = "../transcript", version = "0.2", features = ["recommended"] }
chacha20 = { version = "0.9", features = ["zeroize"] } chacha20 = { version = "0.9", features = ["zeroize"] }
@ -33,4 +35,5 @@ dleq = { path = "../dleq", version = "0.2", features = ["serialize"] }
ciphersuite = { path = "../ciphersuite", version = "0.1", features = ["std", "ristretto"] } ciphersuite = { path = "../ciphersuite", version = "0.1", features = ["std", "ristretto"] }
[features] [features]
serde = ["dep:serde"]
tests = [] tests = []

View file

@ -38,6 +38,7 @@ pub mod tests;
/// The ID of a participant, defined as a non-zero u16. /// The ID of a participant, defined as a non-zero u16.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroize)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Participant(pub(crate) u16); pub struct Participant(pub(crate) u16);
impl Participant { impl Participant {
pub fn new(i: u16) -> Option<Participant> { pub fn new(i: u16) -> Option<Participant> {
@ -123,6 +124,7 @@ pub(crate) fn validate_map<T, B: Clone + PartialEq + Eq + Debug>(
/// Parameters for a multisig. /// Parameters for a multisig.
// These fields should not be made public as they should be static // These fields should not be made public as they should be static
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ThresholdParams { pub struct ThresholdParams {
/// Participants needed to sign on behalf of the group. /// Participants needed to sign on behalf of the group.
t: u16, t: u16,