From a879360a1bda05b9d4bcc0596b09f5886eda4525 Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Wed, 15 Jan 2025 11:09:53 -0300 Subject: [PATCH] all: fix issues related to features (#835) --- frost-core/src/round1.rs | 2 +- frost-core/src/round2.rs | 1 - frost-core/src/signature.rs | 8 ++++---- frost-core/src/signing_key.rs | 8 ++++++-- frost-core/src/tests/ciphersuite_generic.rs | 5 ++--- frost-core/src/tests/refresh.rs | 8 ++++---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/frost-core/src/round1.rs b/frost-core/src/round1.rs index 694043b2..88cdeac1 100644 --- a/frost-core/src/round1.rs +++ b/frost-core/src/round1.rs @@ -323,7 +323,6 @@ where /// Computes the [commitment share] from these round one signing commitments. /// /// [commitment share]: https://datatracker.ietf.org/doc/html/rfc9591#name-signature-share-aggregation - #[cfg(any(feature = "internals", feature = "cheater-detection"))] #[cfg_attr(feature = "internals", visibility::make(pub))] #[cfg_attr(docsrs, doc(cfg(feature = "internals")))] pub(super) fn to_group_commitment_share( @@ -367,6 +366,7 @@ pub struct GroupCommitmentShare(pub(super) Element); impl GroupCommitmentShare { /// Create from an element. #[cfg_attr(feature = "internals", visibility::make(pub))] + #[allow(unused)] pub(crate) fn from_element(element: Element) -> Self { Self(element) } diff --git a/frost-core/src/round2.rs b/frost-core/src/round2.rs index 3d863996..d3147dbf 100644 --- a/frost-core/src/round2.rs +++ b/frost-core/src/round2.rs @@ -59,7 +59,6 @@ where /// This is the final step of [`verify_signature_share`] from the spec. /// /// [`verify_signature_share`]: https://datatracker.ietf.org/doc/html/rfc9591#name-signature-share-aggregation - #[cfg(any(feature = "cheater-detection", feature = "internals"))] #[cfg_attr(feature = "internals", visibility::make(pub))] #[cfg_attr(docsrs, doc(cfg(feature = "internals")))] pub(crate) fn verify( diff --git a/frost-core/src/signature.rs b/frost-core/src/signature.rs index 91d3ade9..91527695 100644 --- a/frost-core/src/signature.rs +++ b/frost-core/src/signature.rs @@ -32,8 +32,8 @@ where /// Converts default-encoded bytes as /// [`Ciphersuite::SignatureSerialization`] into a `Signature`. - #[cfg(feature = "internals")] - pub fn default_deserialize(bytes: &[u8]) -> Result> { + #[cfg_attr(feature = "internals", visibility::make(pub))] + pub(crate) fn default_deserialize(bytes: &[u8]) -> Result> { // To compute the expected length of the encoded point, encode the generator // and get its length. Note that we can't use the identity because it can be encoded // shorter in some cases (e.g. P-256, which uses SEC1 encoding). @@ -75,8 +75,8 @@ where } /// Converts this signature to its default byte serialization. - #[cfg(feature = "internals")] - pub fn default_serialize(&self) -> Result, Error> { + #[cfg_attr(feature = "internals", visibility::make(pub))] + pub(crate) fn default_serialize(&self) -> Result, Error> { let mut bytes = Vec::::new(); bytes.extend(::serialize(&self.R)?.as_ref()); diff --git a/frost-core/src/signing_key.rs b/frost-core/src/signing_key.rs index 93a096c3..574bf969 100644 --- a/frost-core/src/signing_key.rs +++ b/frost-core/src/signing_key.rs @@ -46,8 +46,12 @@ where /// Create a signature `msg` using this `SigningKey` using the default /// signing. - #[cfg(feature = "internals")] - pub fn default_sign(&self, mut rng: R, message: &[u8]) -> Signature { + #[cfg_attr(feature = "internals", visibility::make(pub))] + pub(crate) fn default_sign( + &self, + mut rng: R, + message: &[u8], + ) -> Signature { let public = VerifyingKey::::from(*self); let (k, R) = ::generate_nonce(&mut rng); diff --git a/frost-core/src/tests/ciphersuite_generic.rs b/frost-core/src/tests/ciphersuite_generic.rs index 2cf01831..220bfb51 100644 --- a/frost-core/src/tests/ciphersuite_generic.rs +++ b/frost-core/src/tests/ciphersuite_generic.rs @@ -1,7 +1,8 @@ //! Ciphersuite-generic test functions. #![allow(clippy::type_complexity)] -use alloc::collections::BTreeMap; +use alloc::{borrow::ToOwned, collections::BTreeMap, vec::Vec}; +use rand_core::{CryptoRng, RngCore}; use crate as frost; use crate::keys::SigningShare; @@ -10,8 +11,6 @@ use crate::{ keys::PublicKeyPackage, Error, Field, Group, Identifier, Signature, SigningKey, SigningPackage, VerifyingKey, }; -use alloc::vec::Vec; -use rand_core::{CryptoRng, RngCore}; use crate::Ciphersuite; diff --git a/frost-core/src/tests/refresh.rs b/frost-core/src/tests/refresh.rs index ca017197..384924e5 100644 --- a/frost-core/src/tests/refresh.rs +++ b/frost-core/src/tests/refresh.rs @@ -6,11 +6,10 @@ use crate::keys::generate_with_dealer; use crate::keys::refresh::{ compute_refreshing_shares, refresh_dkg_part2, refresh_dkg_part_1, refresh_share, }; +#[cfg(feature = "serialization")] +use crate::keys::{PublicKeyPackage, SecretShare}; use crate::{self as frost}; -use crate::{ - keys::{KeyPackage, PublicKeyPackage, SecretShare}, - Ciphersuite, Error, Identifier, Signature, VerifyingKey, -}; +use crate::{keys::KeyPackage, Ciphersuite, Error, Identifier, Signature, VerifyingKey}; use crate::tests::ciphersuite_generic::check_part3_different_participants; @@ -175,6 +174,7 @@ pub fn check_refresh_shares_with_dealer_fails_with_invalid_public_key_package< } /// Check serialisation +#[cfg(feature = "serialization")] pub fn check_refresh_shares_with_dealer_serialisation( mut rng: R, ) {