diff --git a/synedrion/src/cggmp21/interactive_signing.rs b/synedrion/src/cggmp21/interactive_signing.rs index adc147ab..f9fadff8 100644 --- a/synedrion/src/cggmp21/interactive_signing.rs +++ b/synedrion/src/cggmp21/interactive_signing.rs @@ -15,7 +15,6 @@ use manul::protocol::{ ReceiveError, Round, RoundId, Serializer, }; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::{ diff --git a/synedrion/src/cggmp21/key_refresh.rs b/synedrion/src/cggmp21/key_refresh.rs index 3bf950e7..a411878f 100644 --- a/synedrion/src/cggmp21/key_refresh.rs +++ b/synedrion/src/cggmp21/key_refresh.rs @@ -17,7 +17,6 @@ use manul::protocol::{ ReceiveError, Round, RoundId, Serializer, }; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::{ @@ -787,7 +786,6 @@ mod tests { session::signature::Keypair, }; use rand_core::OsRng; - use secrecy::ExposeSecret; use super::KeyRefresh; use crate::{cggmp21::TestParams, curve::Scalar}; diff --git a/synedrion/src/cggmp21/params.rs b/synedrion/src/cggmp21/params.rs index 18066614..4c8e4d6d 100644 --- a/synedrion/src/cggmp21/params.rs +++ b/synedrion/src/cggmp21/params.rs @@ -5,7 +5,6 @@ use core::fmt::Debug; // So as long as that is the case, `k256` `Uint` is separate // from the one used throughout the crate. use k256::elliptic_curve::bigint::Uint as K256Uint; -use secrecy::{ExposeSecret, ExposeSecretMut}; use serde::{Deserialize, Serialize}; use crate::{ diff --git a/synedrion/src/cggmp21/sigma/aff_g.rs b/synedrion/src/cggmp21/sigma/aff_g.rs index e86aee81..18de3809 100644 --- a/synedrion/src/cggmp21/sigma/aff_g.rs +++ b/synedrion/src/cggmp21/sigma/aff_g.rs @@ -1,7 +1,6 @@ //! Paillier Affine Operation with Group Commitment in Range ($\Pi^{aff-g}$, Section 6.2, Fig. 15) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::{ diff --git a/synedrion/src/cggmp21/sigma/dec.rs b/synedrion/src/cggmp21/sigma/dec.rs index 75b603f4..67d83be4 100644 --- a/synedrion/src/cggmp21/sigma/dec.rs +++ b/synedrion/src/cggmp21/sigma/dec.rs @@ -1,7 +1,6 @@ //! Paillier decryption modulo $q$ ($\Pi^{dec}$, Section C.6, Fig. 30) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::{ @@ -170,7 +169,6 @@ impl DecProof

{ #[cfg(test)] mod tests { use rand_core::OsRng; - use secrecy::ExposeSecret; use super::DecProof; use crate::{ diff --git a/synedrion/src/cggmp21/sigma/enc.rs b/synedrion/src/cggmp21/sigma/enc.rs index acf76c91..f072502d 100644 --- a/synedrion/src/cggmp21/sigma/enc.rs +++ b/synedrion/src/cggmp21/sigma/enc.rs @@ -1,7 +1,6 @@ //! Paillier encryption in range ($\Pi^{enc}$, Section 6.1, Fig. 14) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::SchemeParams; diff --git a/synedrion/src/cggmp21/sigma/fac.rs b/synedrion/src/cggmp21/sigma/fac.rs index 41f7a9f5..3f9806db 100644 --- a/synedrion/src/cggmp21/sigma/fac.rs +++ b/synedrion/src/cggmp21/sigma/fac.rs @@ -1,7 +1,6 @@ //! No small factor proof ($\Pi^{fac}$, Section C.5, Fig. 28) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::SchemeParams; diff --git a/synedrion/src/cggmp21/sigma/log_star.rs b/synedrion/src/cggmp21/sigma/log_star.rs index edfb0752..866a58a5 100644 --- a/synedrion/src/cggmp21/sigma/log_star.rs +++ b/synedrion/src/cggmp21/sigma/log_star.rs @@ -1,7 +1,6 @@ //! Knowledge of Exponent vs Paillier Encryption ($\Pi^{log*}$, Section C.2, Fig. 25) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::{ diff --git a/synedrion/src/cggmp21/sigma/mod_.rs b/synedrion/src/cggmp21/sigma/mod_.rs index d687ca6c..051fc552 100644 --- a/synedrion/src/cggmp21/sigma/mod_.rs +++ b/synedrion/src/cggmp21/sigma/mod_.rs @@ -4,7 +4,6 @@ use alloc::vec::Vec; use crypto_bigint::Square; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::SchemeParams; diff --git a/synedrion/src/cggmp21/sigma/mul.rs b/synedrion/src/cggmp21/sigma/mul.rs index 15852e44..b7dd1ae2 100644 --- a/synedrion/src/cggmp21/sigma/mul.rs +++ b/synedrion/src/cggmp21/sigma/mul.rs @@ -1,7 +1,6 @@ //! Paillier multiplication ($\Pi^{mul}$, Section C.6, Fig. 29) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::SchemeParams; diff --git a/synedrion/src/cggmp21/sigma/mul_star.rs b/synedrion/src/cggmp21/sigma/mul_star.rs index 507d4357..09b8abd5 100644 --- a/synedrion/src/cggmp21/sigma/mul_star.rs +++ b/synedrion/src/cggmp21/sigma/mul_star.rs @@ -1,7 +1,6 @@ //! Multiplication Paillier vs Group ($\Pi^{mul}$, Section C.6, Fig. 31) use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::{ diff --git a/synedrion/src/cggmp21/sigma/prm.rs b/synedrion/src/cggmp21/sigma/prm.rs index bf799dea..ac91dfe7 100644 --- a/synedrion/src/cggmp21/sigma/prm.rs +++ b/synedrion/src/cggmp21/sigma/prm.rs @@ -7,7 +7,6 @@ use alloc::{vec, vec::Vec}; use digest::XofReader; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::super::SchemeParams; diff --git a/synedrion/src/cggmp21/sigma/sch.rs b/synedrion/src/cggmp21/sigma/sch.rs index 3b8d6e94..08e3bfc7 100644 --- a/synedrion/src/cggmp21/sigma/sch.rs +++ b/synedrion/src/cggmp21/sigma/sch.rs @@ -4,9 +4,7 @@ //! where $g$ is a EC generator. use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; -use zeroize::ZeroizeOnDrop; use crate::{ curve::{Point, Scalar}, @@ -19,7 +17,7 @@ use crate::{ const HASH_TAG: &[u8] = b"P_sch"; /// Secret data the proof is based on (~ signing key) -#[derive(Debug, Clone, ZeroizeOnDrop)] +#[derive(Debug, Clone)] pub(crate) struct SchSecret( /// `\alpha` Secret, diff --git a/synedrion/src/curve/arithmetic.rs b/synedrion/src/curve/arithmetic.rs index b7cfe2a6..0831ef40 100644 --- a/synedrion/src/curve/arithmetic.rs +++ b/synedrion/src/curve/arithmetic.rs @@ -24,7 +24,6 @@ use k256::{ Secp256k1, }; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_encoded_bytes::{Hex, SliceLike}; use zeroize::Zeroize; diff --git a/synedrion/src/paillier/encryption.rs b/synedrion/src/paillier/encryption.rs index ae8ab2bf..7e5f3b04 100644 --- a/synedrion/src/paillier/encryption.rs +++ b/synedrion/src/paillier/encryption.rs @@ -5,7 +5,6 @@ use core::{ use crypto_bigint::{subtle::ConstantTimeGreater, Monty, ShrVartime}; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use zeroize::ZeroizeOnDrop; @@ -505,7 +504,6 @@ impl<'a, P: PaillierParams> Mul<&'a Secret>> for &Ciphertext

mod tests { use crypto_bigint::{Encoding, Integer, ShrVartime, WrappingSub}; use rand_core::OsRng; - use secrecy::ExposeSecret; use super::{ super::{params::PaillierTest, PaillierParams, SecretKeyPaillierWire}, diff --git a/synedrion/src/paillier/keys.rs b/synedrion/src/paillier/keys.rs index e6d62e82..3e19fc7c 100644 --- a/synedrion/src/paillier/keys.rs +++ b/synedrion/src/paillier/keys.rs @@ -5,7 +5,6 @@ use core::{ use crypto_bigint::{InvMod, Monty, Odd, ShrVartime, Square, WrappingAdd}; use rand_core::CryptoRngCore; -use secrecy::{ExposeSecret, ExposeSecretMut}; use serde::{Deserialize, Serialize}; use super::{ diff --git a/synedrion/src/paillier/ring_pedersen.rs b/synedrion/src/paillier/ring_pedersen.rs index 8770b848..2c78218e 100644 --- a/synedrion/src/paillier/ring_pedersen.rs +++ b/synedrion/src/paillier/ring_pedersen.rs @@ -3,7 +3,6 @@ use core::ops::Mul; use crypto_bigint::{Monty, NonZero, RandomMod, ShrVartime}; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::{ diff --git a/synedrion/src/paillier/rsa.rs b/synedrion/src/paillier/rsa.rs index 4acd65c3..1df2f85d 100644 --- a/synedrion/src/paillier/rsa.rs +++ b/synedrion/src/paillier/rsa.rs @@ -1,7 +1,6 @@ use crypto_bigint::{CheckedSub, Gcd, Integer, Monty, NonZero, Odd, RandomMod, Square}; use crypto_primes::RandomPrimeWithRng; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use super::params::PaillierParams; diff --git a/synedrion/src/tools/secret.rs b/synedrion/src/tools/secret.rs index 038fd9bf..d6b40baf 100644 --- a/synedrion/src/tools/secret.rs +++ b/synedrion/src/tools/secret.rs @@ -1,6 +1,6 @@ use core::{ fmt::Debug, - ops::{Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign}, + ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign}, }; use crypto_bigint::{ @@ -25,6 +25,16 @@ use crate::{ /// - Safe serialization/deserialization (down to `serde` API; what happens there we cannot control) pub(crate) struct Secret(SecretBox); +impl Secret { + pub fn expose_secret(&self) -> &T { + self.0.expose_secret() + } + + pub fn expose_secret_mut(&mut self) -> &mut T { + self.0.expose_secret_mut() + } +} + impl Secret { pub fn init_with(ctr: impl FnOnce() -> T) -> Self { Self(SecretBox::init_with(ctr)) @@ -112,20 +122,6 @@ where } } -impl Deref for Secret { - type Target = SecretBox; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for Secret { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - // Addition impl<'a, T: Zeroize + AddAssign<&'a T>> AddAssign<&'a T> for Secret { diff --git a/synedrion/src/tools/sss.rs b/synedrion/src/tools/sss.rs index 286ea452..9f2bd614 100644 --- a/synedrion/src/tools/sss.rs +++ b/synedrion/src/tools/sss.rs @@ -5,7 +5,6 @@ use alloc::{ use core::ops::{Add, Mul}; use rand_core::CryptoRngCore; -use secrecy::ExposeSecret; use serde::{Deserialize, Serialize}; use crate::{ @@ -137,7 +136,6 @@ pub(crate) fn shamir_join_points(pairs: &BTreeMap) -> Point { #[cfg(test)] mod tests { use rand_core::OsRng; - use secrecy::ExposeSecret; use super::{evaluate_polynomial, shamir_evaluation_points, shamir_join_scalars, shamir_split}; use crate::{curve::Scalar, tools::Secret}; diff --git a/synedrion/src/www02/entities.rs b/synedrion/src/www02/entities.rs index 4594ed77..49d3a803 100644 --- a/synedrion/src/www02/entities.rs +++ b/synedrion/src/www02/entities.rs @@ -274,7 +274,6 @@ mod tests { session::signature::Keypair, }; use rand_core::OsRng; - use secrecy::ExposeSecret; use super::ThresholdKeyShare; use crate::{cggmp21::TestParams, curve::Scalar};