Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated FromStr/TryFrom impls for Secret #495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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