Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/cargo/secp256k1-0.20.0
Browse files Browse the repository at this point in the history
* master:
  Remove deprecated FromStr/TryFrom impls for Secret (#495)
  • Loading branch information
ordian committed Jan 4, 2021
2 parents 692b4be + f98a93d commit 57b2da4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
1 change: 1 addition & 0 deletions parity-crypto/CHANGELOG.md
Expand Up @@ -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)
Expand Down
31 changes: 1 addition & 30 deletions parity-crypto/src/publickey/secret_key.rs
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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<Self, Self::Err> {
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 {
Expand All @@ -239,27 +231,6 @@ impl From<H256> 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<Self, Error> {
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<Self, Error> {
if b.len() != SECP256K1_SECRET_KEY_SIZE {
return Err(Error::InvalidSecretKey);
}
Ok(Self { inner: Box::new(H256::from_slice(b)) })
}
}

impl From<key::SecretKey> for Secret {
#[inline(always)]
fn from(key: key::SecretKey) -> Self {
Expand Down

0 comments on commit 57b2da4

Please sign in to comment.