From 221c089f2b1e2923ed4b674c91a1e4a72eff1510 Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Mon, 20 Nov 2023 11:56:33 -0300 Subject: [PATCH] create new() methods for VerifirableSecretSharingCommitment and CoefficientCommitment (#580) --- frost-core/src/keys.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frost-core/src/keys.rs b/frost-core/src/keys.rs index ffcbc11..542d5c0 100644 --- a/frost-core/src/keys.rs +++ b/frost-core/src/keys.rs @@ -297,6 +297,12 @@ impl CoefficientCommitment where C: Ciphersuite, { + /// Create a new CoefficientCommitment. + #[cfg_attr(feature = "internals", visibility::make(pub))] + pub(crate) fn new(value: Element) -> Self { + Self(value) + } + /// returns serialized element pub fn serialize(&self) -> ::Serialization { ::serialize(&self.0) @@ -306,7 +312,7 @@ where pub fn deserialize( coefficient: ::Serialization, ) -> Result, Error> { - Ok(Self(::deserialize(&coefficient)?)) + Ok(Self::new(::deserialize(&coefficient)?)) } /// Returns inner element value @@ -371,6 +377,12 @@ impl VerifiableSecretSharingCommitment where C: Ciphersuite, { + /// Create a new VerifiableSecretSharingCommitment. + #[cfg_attr(feature = "internals", visibility::make(pub))] + pub(crate) fn new(coefficients: Vec>) -> Self { + Self(coefficients) + } + /// Returns serialized coefficent commitments pub fn serialize(&self) -> Vec<::Serialization> { self.0 @@ -388,7 +400,7 @@ where coefficient_commitments.push(CoefficientCommitment::::deserialize(cc)?); } - Ok(Self(coefficient_commitments)) + Ok(Self::new(coefficient_commitments)) } /// Get the VerifyingKey matching this commitment vector (which is the first