create new() methods for VerifirableSecretSharingCommitment and CoefficientCommitment (#580)

This commit is contained in:
Conrado Gouvea 2023-11-20 11:56:33 -03:00 committed by GitHub
parent 4406e01afc
commit 221c089f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -297,6 +297,12 @@ impl<C> CoefficientCommitment<C>
where
C: Ciphersuite,
{
/// Create a new CoefficientCommitment.
#[cfg_attr(feature = "internals", visibility::make(pub))]
pub(crate) fn new(value: Element<C>) -> Self {
Self(value)
}
/// returns serialized element
pub fn serialize(&self) -> <C::Group as Group>::Serialization {
<C::Group>::serialize(&self.0)
@ -306,7 +312,7 @@ where
pub fn deserialize(
coefficient: <C::Group as Group>::Serialization,
) -> Result<CoefficientCommitment<C>, Error<C>> {
Ok(Self(<C::Group as Group>::deserialize(&coefficient)?))
Ok(Self::new(<C::Group as Group>::deserialize(&coefficient)?))
}
/// Returns inner element value
@ -371,6 +377,12 @@ impl<C> VerifiableSecretSharingCommitment<C>
where
C: Ciphersuite,
{
/// Create a new VerifiableSecretSharingCommitment.
#[cfg_attr(feature = "internals", visibility::make(pub))]
pub(crate) fn new(coefficients: Vec<CoefficientCommitment<C>>) -> Self {
Self(coefficients)
}
/// Returns serialized coefficent commitments
pub fn serialize(&self) -> Vec<<C::Group as Group>::Serialization> {
self.0
@ -388,7 +400,7 @@ where
coefficient_commitments.push(CoefficientCommitment::<C>::deserialize(cc)?);
}
Ok(Self(coefficient_commitments))
Ok(Self::new(coefficient_commitments))
}
/// Get the VerifyingKey matching this commitment vector (which is the first