diff --git a/parity-crypto/CHANGELOG.md b/parity-crypto/CHANGELOG.md index 42a24d6a5..2d8a372c0 100644 --- a/parity-crypto/CHANGELOG.md +++ b/parity-crypto/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog]. ### Breaking - Bump `rust-secp256k1` to v0.19, always allow zero signatures. [#438](https://github.com/paritytech/parity-common/pull/438) - Updated `rlp` to 0.5. [#463](https://github.com/paritytech/parity-common/pull/463) +- Remove deprecated trait impls `FromStr`/`TryFrom` for `Secret` [#495](https://github.com/paritytech/parity-common/pull/495) ## [0.6.2] - 2020-06-19 - Put `Secret` memory on heap. [#400](https://github.com/paritytech/parity-common/pull/400) diff --git a/parity-crypto/src/publickey/secret_key.rs b/parity-crypto/src/publickey/secret_key.rs index 269afdf3e..80a37a590 100644 --- a/parity-crypto/src/publickey/secret_key.rs +++ b/parity-crypto/src/publickey/secret_key.rs @@ -138,7 +138,7 @@ impl Secret { pub fn dec(&mut self) -> Result<(), Error> { match self.is_zero() { true => { - *self = Secret::try_from(super::MINUS_ONE_KEY) + *self = Self::copy_from_slice(&super::MINUS_ONE_KEY) .expect("Constructing a secret key from a known-good constant works; qed."); Ok(()) } @@ -213,14 +213,6 @@ impl Secret { } } -#[deprecated(since = "0.6.2", note = "please use `copy_from_str` instead, input is not zeroized")] -impl FromStr for Secret { - type Err = Error; - fn from_str(s: &str) -> Result { - Ok(H256::from_str(s).map_err(|e| Error::Custom(format!("{:?}", e)))?.into()) - } -} - impl From<[u8; 32]> for Secret { #[inline(always)] fn from(mut k: [u8; 32]) -> Self { @@ -239,27 +231,6 @@ impl From for Secret { } } -#[deprecated(since = "0.6.2", note = "please use `copy_from_str` instead, input is not zeroized")] -impl TryFrom<&str> for Secret { - type Error = Error; - - fn try_from(s: &str) -> Result { - s.parse().map_err(|e| Error::Custom(format!("{:?}", e))) - } -} - -#[deprecated(since = "0.6.2", note = "please use `copy_from_slice` instead, input is not zeroized")] -impl TryFrom<&[u8]> for Secret { - type Error = Error; - - fn try_from(b: &[u8]) -> Result { - if b.len() != SECP256K1_SECRET_KEY_SIZE { - return Err(Error::InvalidSecretKey); - } - Ok(Self { inner: Box::new(H256::from_slice(b)) }) - } -} - impl From for Secret { #[inline(always)] fn from(key: key::SecretKey) -> Self {