mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-29 10:41:21 +00:00
feat(identity): remove deprecated items
Related: https://github.com/libp2p/rust-libp2p/issues/3647. Pull-Request: #3928.
This commit is contained in:
parent
856af16512
commit
3cc6c7e080
@ -11,10 +11,13 @@
|
|||||||
- Remove `identity::secp256k1::SecretKey::sign_hash` and make `identity::secp256k1::SecretKey::sign` infallible.
|
- Remove `identity::secp256k1::SecretKey::sign_hash` and make `identity::secp256k1::SecretKey::sign` infallible.
|
||||||
See [PR 3850].
|
See [PR 3850].
|
||||||
|
|
||||||
|
- Remove deprecated items. See [PR 3928].
|
||||||
|
|
||||||
[PR 3850]: https://github.com/libp2p/rust-libp2p/pull/3850
|
[PR 3850]: https://github.com/libp2p/rust-libp2p/pull/3850
|
||||||
[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715
|
[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715
|
||||||
[PR 3863]: https://github.com/libp2p/rust-libp2p/pull/3863
|
[PR 3863]: https://github.com/libp2p/rust-libp2p/pull/3863
|
||||||
[PR 3866]: https://github.com/libp2p/rust-libp2p/pull/3866
|
[PR 3866]: https://github.com/libp2p/rust-libp2p/pull/3866
|
||||||
|
[PR 3928]: https://github.com/libp2p/rust-libp2p/pull/3928
|
||||||
[protobuf format]: https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#keys
|
[protobuf format]: https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#keys
|
||||||
|
|
||||||
## 0.1.2
|
## 0.1.2
|
||||||
|
@ -109,15 +109,6 @@ impl SecretKey {
|
|||||||
self.0.to_bytes().to_vec()
|
self.0.to_bytes().to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a secret key from a byte buffer containing raw scalar of the key.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `SecretKey::try_from_bytes` instead"
|
|
||||||
)]
|
|
||||||
pub fn from_bytes(buf: &[u8]) -> Result<Self, DecodingError> {
|
|
||||||
Self::try_from_bytes(buf)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to parse a secret key from a byte buffer containing raw scalar of the key.
|
/// Try to parse a secret key from a byte buffer containing raw scalar of the key.
|
||||||
pub fn try_from_bytes(buf: impl AsRef<[u8]>) -> Result<SecretKey, DecodingError> {
|
pub fn try_from_bytes(buf: impl AsRef<[u8]>) -> Result<SecretKey, DecodingError> {
|
||||||
SigningKey::from_bytes(buf.as_ref().into())
|
SigningKey::from_bytes(buf.as_ref().into())
|
||||||
@ -166,15 +157,6 @@ impl PublicKey {
|
|||||||
self.0.verify(msg, &sig).is_ok()
|
self.0.verify(msg, &sig).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a public key from a byte buffer containing raw components of a key with or without compression.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
pub fn from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_from_bytes(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to parse a public key from a byte buffer containing raw components of a key with or without compression.
|
/// Try to parse a public key from a byte buffer containing raw components of a key with or without compression.
|
||||||
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
||||||
let enc_pt = EncodedPoint::from_bytes(k)
|
let enc_pt = EncodedPoint::from_bytes(k)
|
||||||
@ -196,15 +178,6 @@ impl PublicKey {
|
|||||||
Self::add_asn1_header(&buf)
|
Self::add_asn1_header(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a public key into a DER encoded byte buffer as defined by SEC1 standard.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_decode_der` instead."
|
|
||||||
)]
|
|
||||||
pub fn decode_der(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_decode_der(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to decode a public key from a DER encoded byte buffer as defined by SEC1 standard.
|
/// Try to decode a public key from a DER encoded byte buffer as defined by SEC1 standard.
|
||||||
pub fn try_decode_der(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
pub fn try_decode_der(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
||||||
let buf = Self::del_asn1_header(k).ok_or_else(|| {
|
let buf = Self::del_asn1_header(k).ok_or_else(|| {
|
||||||
|
@ -38,14 +38,6 @@ impl Keypair {
|
|||||||
Keypair::from(SecretKey::generate())
|
Keypair::from(SecretKey::generate())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode the keypair into a byte array by concatenating the bytes
|
|
||||||
/// of the secret scalar and the compressed public point,
|
|
||||||
/// an informal standard for encoding Ed25519 keypairs.
|
|
||||||
#[deprecated(since = "0.2.0", note = "Renamed to `Keypair::to_bytes`")]
|
|
||||||
pub fn encode(&self) -> [u8; 64] {
|
|
||||||
self.to_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert the keypair into a byte array by concatenating the bytes
|
/// Convert the keypair into a byte array by concatenating the bytes
|
||||||
/// of the secret scalar and the compressed public point,
|
/// of the secret scalar and the compressed public point,
|
||||||
/// an informal standard for encoding Ed25519 keypairs.
|
/// an informal standard for encoding Ed25519 keypairs.
|
||||||
@ -53,18 +45,6 @@ impl Keypair {
|
|||||||
self.0.to_bytes()
|
self.0.to_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a keypair from the [binary format](https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5)
|
|
||||||
/// produced by [`Keypair::to_bytes`], zeroing the input on success.
|
|
||||||
///
|
|
||||||
/// Note that this binary format is the same as `ed25519_dalek`'s and `ed25519_zebra`'s.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `Keypair::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
pub fn decode(kp: &mut [u8]) -> Result<Keypair, DecodingError> {
|
|
||||||
Self::try_from_bytes(kp)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to parse a keypair from the [binary format](https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5)
|
/// Try to parse a keypair from the [binary format](https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5)
|
||||||
/// produced by [`Keypair::to_bytes`], zeroing the input on success.
|
/// produced by [`Keypair::to_bytes`], zeroing the input on success.
|
||||||
///
|
///
|
||||||
@ -182,31 +162,12 @@ impl PublicKey {
|
|||||||
.is_ok()
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode the public key into a byte array in compressed form, i.e.
|
|
||||||
/// where one coordinate is represented by a single bit.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "Renamed to `PublicKey::to_bytes` to reflect actual behaviour."
|
|
||||||
)]
|
|
||||||
pub fn encode(&self) -> [u8; 32] {
|
|
||||||
self.to_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert the public key to a byte array in compressed form, i.e.
|
/// Convert the public key to a byte array in compressed form, i.e.
|
||||||
/// where one coordinate is represented by a single bit.
|
/// where one coordinate is represented by a single bit.
|
||||||
pub fn to_bytes(&self) -> [u8; 32] {
|
pub fn to_bytes(&self) -> [u8; 32] {
|
||||||
self.0.to_bytes()
|
self.0.to_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a public key from a byte array as produced by `to_bytes`.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
pub fn decode(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_from_bytes(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to parse a public key from a byte array containing the actual key as produced by `to_bytes`.
|
/// Try to parse a public key from a byte array containing the actual key as produced by `to_bytes`.
|
||||||
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
||||||
ed25519::PublicKey::from_bytes(k)
|
ed25519::PublicKey::from_bytes(k)
|
||||||
@ -251,18 +212,6 @@ impl SecretKey {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an Ed25519 secret key from a byte slice, zeroing the input on success.
|
|
||||||
/// If the bytes do not constitute a valid Ed25519 secret key, an error is
|
|
||||||
/// returned.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `SecretKey::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
#[allow(unused_mut)]
|
|
||||||
pub fn from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result<SecretKey, DecodingError> {
|
|
||||||
Self::try_from_bytes(sk_bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to parse an Ed25519 secret key from a byte slice
|
/// Try to parse an Ed25519 secret key from a byte slice
|
||||||
/// containing the actual key, zeroing the input on success.
|
/// containing the actual key, zeroing the input on success.
|
||||||
/// If the bytes do not constitute a valid Ed25519 secret key, an error is
|
/// If the bytes do not constitute a valid Ed25519 secret key, an error is
|
||||||
|
@ -106,53 +106,21 @@ impl Keypair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ed25519")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `Keypair::try_into_ed25519` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_ed25519(self) -> Option<ed25519::Keypair> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ed25519")]
|
#[cfg(feature = "ed25519")]
|
||||||
pub fn try_into_ed25519(self) -> Result<ed25519::Keypair, OtherVariantError> {
|
pub fn try_into_ed25519(self) -> Result<ed25519::Keypair, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "secp256k1")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `Keypair::try_into_secp256k1` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_secp256k1(self) -> Option<secp256k1::Keypair> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
pub fn try_into_secp256k1(self) -> Result<secp256k1::Keypair, OtherVariantError> {
|
pub fn try_into_secp256k1(self) -> Result<secp256k1::Keypair, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `Keypair::try_into_rsa` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_rsa(self) -> Option<rsa::Keypair> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||||
pub fn try_into_rsa(self) -> Result<rsa::Keypair, OtherVariantError> {
|
pub fn try_into_rsa(self) -> Result<rsa::Keypair, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ecdsa")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `Keypair::try_into_ecdsa` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_ecdsa(self) -> Option<ecdsa::Keypair> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ecdsa")]
|
#[cfg(feature = "ecdsa")]
|
||||||
pub fn try_into_ecdsa(self) -> Result<ecdsa::Keypair, OtherVariantError> {
|
pub fn try_into_ecdsa(self) -> Result<ecdsa::Keypair, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
@ -480,65 +448,26 @@ impl PublicKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ed25519")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_into_ed25519` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_ed25519(self) -> Option<ed25519::PublicKey> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ed25519")]
|
#[cfg(feature = "ed25519")]
|
||||||
pub fn try_into_ed25519(self) -> Result<ed25519::PublicKey, OtherVariantError> {
|
pub fn try_into_ed25519(self) -> Result<ed25519::PublicKey, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "secp256k1")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_into_secp256k1` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_secp256k1(self) -> Option<secp256k1::PublicKey> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
pub fn try_into_secp256k1(self) -> Result<secp256k1::PublicKey, OtherVariantError> {
|
pub fn try_into_secp256k1(self) -> Result<secp256k1::PublicKey, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_into_rsa` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_rsa(self) -> Option<rsa::PublicKey> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||||
pub fn try_into_rsa(self) -> Result<rsa::PublicKey, OtherVariantError> {
|
pub fn try_into_rsa(self) -> Result<rsa::PublicKey, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ecdsa")]
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_into_ecdsa` instead."
|
|
||||||
)]
|
|
||||||
pub fn into_ecdsa(self) -> Option<ecdsa::PublicKey> {
|
|
||||||
self.try_into().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ecdsa")]
|
#[cfg(feature = "ecdsa")]
|
||||||
pub fn try_into_ecdsa(self) -> Result<ecdsa::PublicKey, OtherVariantError> {
|
pub fn try_into_ecdsa(self) -> Result<ecdsa::PublicKey, OtherVariantError> {
|
||||||
self.try_into()
|
self.try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode the public key into a protobuf structure for storage or
|
|
||||||
/// exchange with other nodes.
|
|
||||||
#[deprecated(note = "Renamed to `PublicKey::encode_protobuf`.")]
|
|
||||||
pub fn to_protobuf_encoding(&self) -> Vec<u8> {
|
|
||||||
Self::encode_protobuf(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Encode the public key into a protobuf structure for storage or
|
/// Encode the public key into a protobuf structure for storage or
|
||||||
/// exchange with other nodes.
|
/// exchange with other nodes.
|
||||||
pub fn encode_protobuf(&self) -> Vec<u8> {
|
pub fn encode_protobuf(&self) -> Vec<u8> {
|
||||||
@ -570,15 +499,6 @@ impl PublicKey {
|
|||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a public key from a protobuf structure, e.g. read from storage
|
|
||||||
/// or received from another node.
|
|
||||||
#[deprecated(
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_decode_protobuf` instead."
|
|
||||||
)]
|
|
||||||
pub fn from_protobuf_encoding(bytes: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_decode_protobuf(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decode a public key from a protobuf structure, e.g. read from storage
|
/// Decode a public key from a protobuf structure, e.g. read from storage
|
||||||
/// or received from another node.
|
/// or received from another node.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
@ -42,15 +42,6 @@ impl std::fmt::Debug for Keypair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Keypair {
|
impl Keypair {
|
||||||
/// Decode an RSA keypair from a DER-encoded private key in PKCS#8 PrivateKeyInfo
|
|
||||||
/// format (i.e. unencrypted) as defined in [RFC5208].
|
|
||||||
///
|
|
||||||
/// [RFC5208]: https://tools.ietf.org/html/rfc5208#section-5
|
|
||||||
#[deprecated(since = "0.2.0", note = "Renamed to `Keypair::try_decode_pkcs8`.")]
|
|
||||||
pub fn from_pkcs8(der: &mut [u8]) -> Result<Keypair, DecodingError> {
|
|
||||||
Self::try_decode_pkcs8(der)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decode an RSA keypair from a DER-encoded private key in PKCS#8 PrivateKeyInfo
|
/// Decode an RSA keypair from a DER-encoded private key in PKCS#8 PrivateKeyInfo
|
||||||
/// format (i.e. unencrypted) as defined in [RFC5208].
|
/// format (i.e. unencrypted) as defined in [RFC5208].
|
||||||
///
|
///
|
||||||
@ -116,16 +107,6 @@ impl PublicKey {
|
|||||||
.expect("RSA X.509 public key encoding failed.")
|
.expect("RSA X.509 public key encoding failed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode an RSA public key from a DER-encoded X.509 SubjectPublicKeyInfo
|
|
||||||
/// structure. See also `encode_x509`.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_decode_x509` instead."
|
|
||||||
)]
|
|
||||||
pub fn decode_x509(pk: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_decode_x509(pk)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decode an RSA public key from a DER-encoded X.509 SubjectPublicKeyInfo
|
/// Decode an RSA public key from a DER-encoded X.509 SubjectPublicKeyInfo
|
||||||
/// structure. See also `encode_x509`.
|
/// structure. See also `encode_x509`.
|
||||||
pub fn try_decode_x509(pk: &[u8]) -> Result<PublicKey, DecodingError> {
|
pub fn try_decode_x509(pk: &[u8]) -> Result<PublicKey, DecodingError> {
|
||||||
|
@ -92,20 +92,6 @@ impl SecretKey {
|
|||||||
SecretKey(libsecp256k1::SecretKey::random(&mut rand::thread_rng()))
|
SecretKey(libsecp256k1::SecretKey::random(&mut rand::thread_rng()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a secret key from a byte slice, zeroing the slice on success.
|
|
||||||
/// If the bytes do not constitute a valid Secp256k1 secret key, an
|
|
||||||
/// error is returned.
|
|
||||||
///
|
|
||||||
/// Note that the expected binary format is the same as `libsecp256k1`'s.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `SecretKey::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
#[allow(unused_mut)]
|
|
||||||
pub fn from_bytes(mut sk: impl AsMut<[u8]>) -> Result<SecretKey, DecodingError> {
|
|
||||||
Self::try_from_bytes(sk)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a secret key from a byte slice, zeroing the slice on success.
|
/// Create a secret key from a byte slice, zeroing the slice on success.
|
||||||
/// If the bytes do not constitute a valid Secp256k1 secret key, an
|
/// If the bytes do not constitute a valid Secp256k1 secret key, an
|
||||||
/// error is returned.
|
/// error is returned.
|
||||||
@ -215,43 +201,17 @@ impl PublicKey {
|
|||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode the public key in compressed form, i.e. with one coordinate
|
|
||||||
/// represented by a single bit.
|
|
||||||
#[deprecated(since = "0.2.0", note = "Renamed to `PublicKey::to_bytes`.")]
|
|
||||||
pub fn encode(&self) -> [u8; 33] {
|
|
||||||
self.to_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert the public key to a byte buffer in compressed form, i.e. with one coordinate
|
/// Convert the public key to a byte buffer in compressed form, i.e. with one coordinate
|
||||||
/// represented by a single bit.
|
/// represented by a single bit.
|
||||||
pub fn to_bytes(&self) -> [u8; 33] {
|
pub fn to_bytes(&self) -> [u8; 33] {
|
||||||
self.0.serialize_compressed()
|
self.0.serialize_compressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode the public key in uncompressed form.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "Renamed to `PublicKey::to_bytes_uncompressed`."
|
|
||||||
)]
|
|
||||||
pub fn encode_uncompressed(&self) -> [u8; 65] {
|
|
||||||
self.to_bytes_uncompressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert the public key to a byte buffer in uncompressed form.
|
/// Convert the public key to a byte buffer in uncompressed form.
|
||||||
pub fn to_bytes_uncompressed(&self) -> [u8; 65] {
|
pub fn to_bytes_uncompressed(&self) -> [u8; 65] {
|
||||||
self.0.serialize()
|
self.0.serialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a public key from a byte slice in the the format produced
|
|
||||||
/// by `encode`.
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.2.0",
|
|
||||||
note = "This method name does not follow Rust naming conventions, use `PublicKey::try_from_bytes` instead."
|
|
||||||
)]
|
|
||||||
pub fn decode(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
|
||||||
Self::try_from_bytes(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decode a public key from a byte slice in the the format produced
|
/// Decode a public key from a byte slice in the the format produced
|
||||||
/// by `encode`.
|
/// by `encode`.
|
||||||
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
pub fn try_from_bytes(k: &[u8]) -> Result<PublicKey, DecodingError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user