From 9bc8fcce530ea5a29b2def0554a6e2821f6e28b6 Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Thu, 16 Nov 2023 14:23:07 -0300 Subject: [PATCH] create new() methods for VerifirableSecretSharingCommitment and CoefficientCommitment --- 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 ffcbc116..542d5c0d 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