Rename CompressedPublicKey to FullPublicKey
What changed, and why it matters
This commit is a simple rename of a Rust type from CompressedPublicKey to FullPublicKey, with the old name kept as a deprecated alias. It does not change any behavior, cryptographic logic, or security properties. It is an API cleanup, not a security fix or vulnerability.
No security action needed. Users may migrate from CompressedPublicKey to FullPublicKey at their convenience before the deprecated alias is removed in a future release.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames the struct CompressedPublicKey to FullPublicKey throughout the rust-bitcoin crate, updates all internal call sites, and adds a deprecated type alias CompressedPublicKey = FullPublicKey for backward compatibility. No functional code, validation, serialization, or key-handling logic was modified. The change is purely cosmetic/naming.
Changed components
bitcoin/src/crypto/key.rsbitcoin/src/lib.rsbitcoin/src/address/mod.rsbitcoin/src/bip32.rsbitcoin/src/blockdata/script/witness_program.rsbitcoin/src/blockdata/witness.rsbitcoin/src/sign_message.rsbitcoin/examples/bip32.rsbitcoin/examples/create-p2wpkh-address.rsbitcoin/examples/ecdsa-psbt.rsbitcoin/examples/sighash.rsInspect captured patch +73 / −72
diff --git a/bitcoin/examples/bip32.rs b/bitcoin/examples/bip32.rs
index ee569547..5741aefd 100644
--- a/bitcoin/examples/bip32.rs
+++ b/bitcoin/examples/bip32.rs
@@ -2,7 +2,7 @@ use std::env;
use bitcoin::address::{Address, KnownHrp};
use bitcoin::bip32::{ChildNumber, DerivationPath, Xpriv, Xpub};
-use bitcoin::{hex, CompressedPublicKey, NetworkKind};
+use bitcoin::{hex, FullPublicKey, NetworkKind};
fn main() {
// This example derives root xprv from a 32-byte seed,
@@ -39,6 +39,6 @@ fn main() {
// manually creating indexes this time
let zero = ChildNumber::ZERO_NORMAL;
let public_key = xpub.derive_xpub([zero, zero]).unwrap().public_key;
- let address = Address::p2wpkh(CompressedPublicKey::from_secp(public_key), KnownHrp::Mainnet);
+ let address = Address::p2wpkh(FullPublicKey::from_secp(public_key), KnownHrp::Mainnet);
println!("First receiving address: {address}");
}
diff --git a/bitcoin/examples/create-p2wpkh-address.rs b/bitcoin/examples/create-p2wpkh-address.rs
index bb81c1df..38820e41 100644
--- a/bitcoin/examples/create-p2wpkh-address.rs
+++ b/bitcoin/examples/create-p2wpkh-address.rs
@@ -1,5 +1,5 @@
use bitcoin::secp256k1::rand;
-use bitcoin::{Address, CompressedPublicKey, Network};
+use bitcoin::{Address, FullPublicKey, Network};
/// Generate a P2WPKH (pay-to-witness-public-key-hash) address and print it.
fn main() {
@@ -7,7 +7,7 @@ fn main() {
let (_secret_key, public_key) = secp256k1::generate_keypair(&mut rand::rng());
// Create a compressed Bitcoin public key from the secp256k1 public key.
- let public_key = CompressedPublicKey::from_secp(public_key);
+ let public_key = FullPublicKey::from_secp(public_key);
// Create a Bitcoin P2WPKH address.
let address = Address::p2wpkh(public_key, Network::Bitcoin);
diff --git a/bitcoin/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs
index 2097557a..9a43d1ff 100644
--- a/bitcoin/examples/ecdsa-psbt.rs
+++ b/bitcoin/examples/ecdsa-psbt.rs
@@ -37,7 +37,7 @@ use bitcoin::ext::*;
use bitcoin::locktime::absolute;
use bitcoin::psbt::{self, Input, Psbt, PsbtSighashType};
use bitcoin::{
- transaction, Address, Amount, CompressedPublicKey, Network, OutPoint, RedeemScriptBuf,
+ transaction, Address, Amount, FullPublicKey, Network, OutPoint, RedeemScriptBuf,
ScriptPubKeyBuf, ScriptSigBuf, Sequence, Transaction, TxIn, TxOut, Witness,
};
@@ -245,7 +245,7 @@ impl WatchOnly {
/// "m/84h/0h/0h/1/0"). A real wallet would have access to the chain so could determine if an
/// address has been used or not. We ignore this detail and just re-use the first change address
/// without loss of generality.
- fn change_address(&self) -> Result<(CompressedPublicKey, Address, DerivationPath)> {
+ fn change_address(&self) -> Result<(FullPublicKey, Address, DerivationPath)> {
let path = [ChildNumber::ONE_NORMAL, ChildNumber::ZERO_NORMAL];
let derived = self.account_0_xpub.derive_xpub(path)?;
diff --git a/bitcoin/examples/sighash.rs b/bitcoin/examples/sighash.rs
index 3088d159..92be84bc 100644
--- a/bitcoin/examples/sighash.rs
+++ b/bitcoin/examples/sighash.rs
@@ -1,7 +1,7 @@
use bitcoin::ext::*;
use bitcoin::{
- consensus, ecdsa, sighash, Amount, CompressedPublicKey, ScriptPubKey, ScriptPubKeyBuf,
- Transaction, WitnessScript,
+ consensus, ecdsa, sighash, Amount, FullPublicKey, ScriptPubKey, ScriptPubKeyBuf, Transaction,
+ WitnessScript,
};
use hex_unstable::hex;
@@ -37,7 +37,7 @@ fn compute_sighash_p2wpkh(raw_tx: &[u8], inp_idx: usize, amount: Amount) {
//BIP-0143: "The item 5 : For P2WPKH witness program, the scriptCode is 0x1976a914{20-byte-pubkey-hash}88ac"
//this is nothing but a standard P2PKH script OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG:
let pk_byte_arr = pk_bytes.try_into().expect("there should be 33 bytes for a compressed key");
- let pk = CompressedPublicKey::from_bytes(pk_byte_arr).expect("failed to parse pubkey");
+ let pk = FullPublicKey::from_bytes(pk_byte_arr).expect("failed to parse pubkey");
let wpkh = pk.wpubkey_hash();
println!("Script pubkey hash: {wpkh:x}");
let spk = ScriptPubKeyBuf::new_p2wpkh(wpkh);
diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs
index 4cf58116..9294f797 100644
--- a/bitcoin/src/address/mod.rs
+++ b/bitcoin/src/address/mod.rs
@@ -56,8 +56,7 @@ use crate::constants::{
SCRIPT_ADDRESS_PREFIX_TEST,
};
use crate::crypto::key::{
- CompressedPublicKey, PubkeyHash, PublicKey, TweakedPublicKey, UntweakedPublicKey,
- XOnlyPublicKey,
+ FullPublicKey, PubkeyHash, PublicKey, TweakedPublicKey, UntweakedPublicKey, XOnlyPublicKey,
};
use crate::network::{Network, NetworkKind, Params};
use crate::prelude::{String, ToOwned};
@@ -532,7 +531,7 @@ impl Address {
/// Constructs a new pay-to-witness-public-key-hash (P2WPKH) [`Address`] from a public key.
///
/// This is the native SegWit address type for an output redeemable with a single signature.
- pub fn p2wpkh(pk: CompressedPublicKey, hrp: impl Into<KnownHrp>) -> Self {
+ pub fn p2wpkh(pk: FullPublicKey, hrp: impl Into<KnownHrp>) -> Self {
let program = WitnessProgram::p2wpkh(pk);
Self::from_witness_program(program, hrp)
}
@@ -541,7 +540,7 @@ impl Address {
/// pay-to-witness-public-key-hash (P2WPKH).
///
/// This is a SegWit address type that looks familiar (as p2sh) to legacy clients.
- pub fn p2shwpkh(pk: CompressedPublicKey, network: impl Into<NetworkKind>) -> Self {
+ pub fn p2shwpkh(pk: FullPublicKey, network: impl Into<NetworkKind>) -> Self {
let builder = ScriptPubKey::builder().push_int_unchecked(0).push_slice(pk.wpubkey_hash());
let script_hash = builder.as_script().script_hash().expect("script is less than 520 bytes");
Self::p2sh_from_hash(script_hash, network)
@@ -1128,7 +1127,7 @@ mod tests {
fn p2wpkh() {
// stolen from Bitcoin transaction: b3c8c2b6cfc335abbcb2c7823a8453f55d64b2b5125a9a61e8737230cdb8ce20
let key = "033bc8c83c52df5712229a2f72206d90192366c36428cb0c12b6af98324d97bfbc"
- .parse::<CompressedPublicKey>()
+ .parse::<FullPublicKey>()
.unwrap();
let addr = Address::p2wpkh(key, KnownHrp::Mainnet);
assert_eq!(&addr.to_string(), "bc1qvzvkjn4q3nszqxrv3nraga2r822xjty3ykvkuw");
@@ -1153,7 +1152,7 @@ mod tests {
fn p2shwpkh() {
// stolen from Bitcoin transaction: ad3fd9c6b52e752ba21425435ff3dd361d6ac271531fc1d2144843a9f550ad01
let key = "026c468be64d22761c30cd2f12cbc7de255d592d7904b1bab07236897cc4c2e766"
- .parse::<CompressedPublicKey>()
+ .parse::<FullPublicKey>()
.unwrap();
let addr = Address::p2shwpkh(key, NetworkKind::Main);
assert_eq!(&addr.to_string(), "3QBRmWNqqBGme9er7fMkGqtZtp4gjMFxhE");
diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs
index fc0b718c..8482dd0a 100644
--- a/bitcoin/src/bip32.rs
+++ b/bitcoin/src/bip32.rs
@@ -16,7 +16,7 @@ use hashes::{hash160, hash_newtype, sha512, Hash, HashEngine, Hmac, HmacEngine};
use internals::array::ArrayExt;
use internals::write_err;
-use crate::crypto::key::{CompressedPublicKey, Keypair, PrivateKey, XOnlyPublicKey};
+use crate::crypto::key::{FullPublicKey, Keypair, PrivateKey, XOnlyPublicKey};
use crate::internal_macros;
use crate::network::NetworkKind;
use crate::prelude::{String, Vec};
@@ -869,12 +869,10 @@ impl Xpub {
/// Constructs a new ECDSA compressed public key matching internal public key representation.
#[deprecated(since = "TBD", note = "use `to_public_key()` instead")]
- pub fn to_pub(self) -> CompressedPublicKey { self.to_public_key() }
+ pub fn to_pub(self) -> FullPublicKey { self.to_public_key() }
/// Constructs a new ECDSA compressed public key matching internal public key representation.
- pub fn to_public_key(self) -> CompressedPublicKey {
- CompressedPublicKey::from_secp(self.public_key)
- }
+ pub fn to_public_key(self) -> FullPublicKey { FullPublicKey::from_secp(self.public_key) }
/// Constructs a new BIP-0340 x-only public key for BIP-0340 signatures and Taproot use matching
/// the internal public key representation.
diff --git a/bitcoin/src/blockdata/script/witness_program.rs b/bitcoin/src/blockdata/script/witness_program.rs
index 39be3e7d..422bdaca 100644
--- a/bitcoin/src/blockdata/script/witness_program.rs
+++ b/bitcoin/src/blockdata/script/witness_program.rs
@@ -14,7 +14,7 @@ use internals::array_vec::ArrayVec;
use super::witness_version::WitnessVersion;
use super::{PushBytes, WScriptHash, WitnessScript, WitnessScriptSizeError};
-use crate::crypto::key::{CompressedPublicKey, TapTweak, TweakedPublicKey, UntweakedPublicKey};
+use crate::crypto::key::{FullPublicKey, TapTweak, TweakedPublicKey, UntweakedPublicKey};
use crate::script::WitnessScriptExt as _;
use crate::taproot::TapNodeHash;
@@ -73,7 +73,7 @@ impl WitnessProgram {
}
/// Constructs a new [`WitnessProgram`] from `pk` for a P2WPKH output.
- pub fn p2wpkh(pk: CompressedPublicKey) -> Self {
+ pub fn p2wpkh(pk: FullPublicKey) -> Self {
let hash = pk.wpubkey_hash();
Self::new_p2wpkh(hash.to_byte_array())
}
diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs
index 93d5395f..e433b2f1 100644
--- a/bitcoin/src/blockdata/witness.rs
+++ b/bitcoin/src/blockdata/witness.rs
@@ -9,7 +9,7 @@ use io::{BufRead, Write};
use crate::consensus::encode::{self, Error, ParseError, WriteExt};
use crate::consensus::{Decodable, Encodable};
use crate::crypto::ecdsa;
-use crate::crypto::key::{CompressedPublicKey, SerializedXOnlyPublicKey};
+use crate::crypto::key::{FullPublicKey, SerializedXOnlyPublicKey};
use crate::taproot::{self, ControlBlock, LeafScript, TaprootMerkleBranch, TAPROOT_ANNEX_PREFIX};
use crate::{internal_macros, TapScript, WitnessScript};
@@ -49,7 +49,7 @@ internal_macros::define_extension_trait! {
/// serialized public key. Also useful for spending a P2SH-P2WPKH output.
///
/// It is expected that `pubkey` is related to the secret key used to create `signature`.
- fn p2wpkh(signature: ecdsa::Signature, pubkey: CompressedPublicKey) -> Self {
+ fn p2wpkh(signature: ecdsa::Signature, pubkey: FullPublicKey) -> Self {
let mut witness = Witness::new();
witness.push(signature.serialize());
witness.push(pubkey.to_bytes());
diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs
index 2a975537..86621372 100644
--- a/bitcoin/src/crypto/key.rs
+++ b/bitcoin/src/crypto/key.rs
@@ -32,7 +32,7 @@ use crate::taproot::{TapNodeHash, TapTweakHash};
#[rustfmt::skip] // Keep public re-exports separate.
pub use secp256k1::{constants, Parity, Verification};
pub use encapsulate::{
- CompressedPublicKey, Keypair, PrivateKey, PublicKey, SerializedXOnlyPublicKey, TweakedKeypair,
+ FullPublicKey, Keypair, PrivateKey, PublicKey, SerializedXOnlyPublicKey, TweakedKeypair,
TweakedPublicKey, XOnlyPublicKey,
};
#[cfg(feature = "rand")]
@@ -131,9 +131,9 @@ mod encapsulate {
/// An always-compressed Bitcoin ECDSA public key.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
- pub struct CompressedPublicKey(secp256k1::PublicKey);
+ pub struct FullPublicKey(secp256k1::PublicKey);
- impl CompressedPublicKey {
+ impl FullPublicKey {
/// Constructs a new compressed public key from the provided secp public key.
#[inline]
pub fn from_secp(inner: secp256k1::PublicKey) -> Self { Self(inner) }
@@ -584,17 +584,15 @@ impl PublicKey {
///
/// Errors if this key is not compressed.
pub fn p2wpkh_script_code(&self) -> Result<WitnessScriptBuf, UncompressedPublicKeyError> {
- let key = CompressedPublicKey::try_from(*self)?;
+ let key = FullPublicKey::try_from(*self)?;
Ok(key.p2wpkh_script_code())
}
- /// Converts this [`PublicKey`] into a [`CompressedPublicKey`] infallibly.
+ /// Converts this [`PublicKey`] into a [`FullPublicKey`] infallibly.
///
/// Unlike the `TryFrom` implementation, this function will discard compressedness
/// information on the [`PublicKey`].
- pub fn force_compressed(self) -> CompressedPublicKey {
- CompressedPublicKey::from_secp(self.to_inner())
- }
+ pub fn force_compressed(self) -> FullPublicKey { FullPublicKey::from_secp(self.to_inner()) }
/// Writes the public key into a writer.
///
@@ -734,7 +732,7 @@ impl PublicKey {
pub fn from_private_key(sk: &PrivateKey) -> Self { sk.to_public_key() }
/// Extracts the public key from a Keypair
- pub fn from_keypair(pair: &Keypair) -> Self { CompressedPublicKey::from_keypair(pair).into() }
+ pub fn from_keypair(pair: &Keypair) -> Self { FullPublicKey::from_keypair(pair).into() }
/// Checks that `sig` is a valid ECDSA signature for `msg` using this public key.
///
@@ -822,7 +820,11 @@ impl From<&PublicKey> for PubkeyHash {
fn from(key: &PublicKey) -> Self { key.pubkey_hash() }
}
-impl CompressedPublicKey {
+#[deprecated(since = "TBD", note = "use `FullPublicKey` instead")]
+#[doc(hidden)]
+pub type CompressedPublicKey = FullPublicKey;
+
+impl FullPublicKey {
/// Returns bitcoin 160-bit hash of the public key.
pub fn pubkey_hash(&self) -> PubkeyHash { PubkeyHash(hash160::Hash::hash(&self.to_bytes())) }
@@ -931,27 +933,27 @@ impl CompressedPublicKey {
}
}
-impl fmt::Display for CompressedPublicKey {
+impl fmt::Display for FullPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.to_bytes().as_hex(), f)
}
}
-impl fmt::Debug for CompressedPublicKey {
+impl fmt::Debug for FullPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_fmt(format_args!("CompressedPublicKey({})", self))
+ f.write_fmt(format_args!("FullPublicKey({})", self))
}
}
-impl FromStr for CompressedPublicKey {
- type Err = ParseCompressedPublicKeyError;
+impl FromStr for FullPublicKey {
+ type Err = ParseFullPublicKeyError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::from_bytes(hex::decode_to_array::<33>(s)?).map_err(Into::into)
}
}
-impl TryFrom<PublicKey> for CompressedPublicKey {
+impl TryFrom<PublicKey> for FullPublicKey {
type Error = UncompressedPublicKeyError;
fn try_from(value: PublicKey) -> Result<Self, Self::Error> {
@@ -963,32 +965,32 @@ impl TryFrom<PublicKey> for CompressedPublicKey {
}
}
-impl From<secp256k1::PublicKey> for CompressedPublicKey {
+impl From<secp256k1::PublicKey> for FullPublicKey {
fn from(pk: secp256k1::PublicKey) -> Self { Self::from_secp(pk) }
}
-impl From<CompressedPublicKey> for PublicKey {
- fn from(value: CompressedPublicKey) -> Self { Self::from_secp(value.to_inner()) }
+impl From<FullPublicKey> for PublicKey {
+ fn from(value: FullPublicKey) -> Self { Self::from_secp(value.to_inner()) }
}
-impl From<CompressedPublicKey> for XOnlyPublicKey {
- fn from(pk: CompressedPublicKey) -> Self { pk.to_inner().into() }
+impl From<FullPublicKey> for XOnlyPublicKey {
+ fn from(pk: FullPublicKey) -> Self { pk.to_inner().into() }
}
-impl From<CompressedPublicKey> for PubkeyHash {
- fn from(key: CompressedPublicKey) -> Self { key.pubkey_hash() }
+impl From<FullPublicKey> for PubkeyHash {
+ fn from(key: FullPublicKey) -> Self { key.pubkey_hash() }
}
-impl From<&CompressedPublicKey> for PubkeyHash {
- fn from(key: &CompressedPublicKey) -> Self { key.pubkey_hash() }
+impl From<&FullPublicKey> for PubkeyHash {
+ fn from(key: &FullPublicKey) -> Self { key.pubkey_hash() }
}
-impl From<CompressedPublicKey> for WPubkeyHash {
- fn from(key: CompressedPublicKey) -> Self { key.wpubkey_hash() }
+impl From<FullPublicKey> for WPubkeyHash {
+ fn from(key: FullPublicKey) -> Self { key.wpubkey_hash() }
}
-impl From<&CompressedPublicKey> for WPubkeyHash {
- fn from(key: &CompressedPublicKey) -> Self { key.wpubkey_hash() }
+impl From<&FullPublicKey> for WPubkeyHash {
+ fn from(key: &FullPublicKey) -> Self { key.wpubkey_hash() }
}
impl PrivateKey {
@@ -1306,7 +1308,7 @@ impl<'de> serde::Deserialize<'de> for PublicKey {
}
#[cfg(feature = "serde")]
-impl serde::Serialize for CompressedPublicKey {
+impl serde::Serialize for FullPublicKey {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
if s.is_human_readable() {
s.collect_str(self)
@@ -1317,13 +1319,13 @@ impl serde::Serialize for CompressedPublicKey {
}
#[cfg(feature = "serde")]
-impl<'de> serde::Deserialize<'de> for CompressedPublicKey {
+impl<'de> serde::Deserialize<'de> for FullPublicKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
if d.is_human_readable() {
struct HexVisitor;
impl serde::de::Visitor<'_> for HexVisitor {
- type Value = CompressedPublicKey;
+ type Value = FullPublicKey;
fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
formatter.write_str("a 66 digits long ASCII hex string")
@@ -1334,7 +1336,7 @@ impl<'de> serde::Deserialize<'de> for CompressedPublicKey {
E: serde::de::Error,
{
if let Ok(hex) = core::str::from_utf8(v) {
- hex.parse::<CompressedPublicKey>().map_err(E::custom)
+ hex.parse::<FullPublicKey>().map_err(E::custom)
} else {
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
}
@@ -1344,7 +1346,7 @@ impl<'de> serde::Deserialize<'de> for CompressedPublicKey {
where
E: serde::de::Error,
{
- v.parse::<CompressedPublicKey>().map_err(E::custom)
+ v.parse::<FullPublicKey>().map_err(E::custom)
}
}
d.deserialize_str(HexVisitor)
@@ -1352,7 +1354,7 @@ impl<'de> serde::Deserialize<'de> for CompressedPublicKey {
struct BytesVisitor;
impl serde::de::Visitor<'_> for BytesVisitor {
- type Value = CompressedPublicKey;
+ type Value = FullPublicKey;
fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
formatter.write_str("a bytestring")
@@ -1363,7 +1365,7 @@ impl<'de> serde::Deserialize<'de> for CompressedPublicKey {
E: serde::de::Error,
{
let arr = v.try_into().map_err(E::custom)?;
- CompressedPublicKey::from_bytes(arr).map_err(E::custom)
+ FullPublicKey::from_bytes(arr).map_err(E::custom)
}
}
@@ -1689,20 +1691,20 @@ impl From<FromSliceError> for ParsePublicKeyError {
fn from(e: FromSliceError) -> Self { Self::Encoding(e) }
}
-/// Error returned when parsing a [`CompressedPublicKey`] from a string.
+/// Error returned when parsing a [`FullPublicKey`] from a string.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum ParseCompressedPublicKeyError {
+pub enum ParseFullPublicKeyError {
/// secp256k1 Error.
Secp256k1(secp256k1::Error),
/// hex to array conversion error.
Hex(hex::DecodeFixedLengthBytesError),
}
-impl From<Infallible> for ParseCompressedPublicKeyError {
+impl From<Infallible> for ParseFullPublicKeyError {
fn from(never: Infallible) -> Self { match never {} }
}
-impl fmt::Display for ParseCompressedPublicKeyError {
+impl fmt::Display for ParseFullPublicKeyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Secp256k1(e) => write_err!(f, "secp256k1 error"; e),
@@ -1712,7 +1714,7 @@ impl fmt::Display for ParseCompressedPublicKeyError {
}
#[cfg(feature = "std")]
-impl std::error::Error for ParseCompressedPublicKeyError {
+impl std::error::Error for ParseFullPublicKeyError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Secp256k1(e) => Some(e),
@@ -1721,11 +1723,11 @@ impl std::error::Error for ParseCompressedPublicKeyError {
}
}
-impl From<secp256k1::Error> for ParseCompressedPublicKeyError {
+impl From<secp256k1::Error> for ParseFullPublicKeyError {
fn from(e: secp256k1::Error) -> Self { Self::Secp256k1(e) }
}
-impl From<hex::DecodeFixedLengthBytesError> for ParseCompressedPublicKeyError {
+impl From<hex::DecodeFixedLengthBytesError> for ParseFullPublicKeyError {
fn from(e: hex::DecodeFixedLengthBytesError) -> Self { Self::Hex(e) }
}
diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs
index b7192fe4..8bfe6ebc 100644
--- a/bitcoin/src/lib.rs
+++ b/bitcoin/src/lib.rs
@@ -166,14 +166,16 @@ pub use units::{
#[doc(hidden)]
pub type BlockInterval = BlockHeightInterval;
+#[deprecated(since = "TBD", note = "use `FullPublicKey` instead")]
+#[doc(hidden)]
+pub type CompressedPublicKey = FullPublicKey;
+
#[doc(inline)]
pub use crate::{
address::{Address, AddressType, KnownHrp},
bip32::XKeyIdentifier,
crypto::ecdsa,
- crypto::key::{
- self, CompressedPublicKey, Keypair, PrivateKey, PublicKey, WifKey, XOnlyPublicKey,
- },
+ crypto::key::{self, FullPublicKey, Keypair, PrivateKey, PublicKey, WifKey, XOnlyPublicKey},
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
network::params::{self, Params},
network::{Network, NetworkKind, TestnetVersion},
diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs
index ad2786e9..2b37177c 100644
--- a/bitcoin/src/sign_message.rs
+++ b/bitcoin/src/sign_message.rs
@@ -237,7 +237,7 @@ mod tests {
#[cfg(feature = "secp-recovery")]
#[cfg(feature = "std")]
fn message_signature() {
- use crate::{Address, AddressType, CompressedPublicKey, Network, NetworkKind, PrivateKey};
+ use crate::{Address, AddressType, FullPublicKey, Network, NetworkKind, PrivateKey};
let message = "rust-bitcoin MessageSignature test";
let msg_hash = super::signed_msg_hash(message);
@@ -269,7 +269,7 @@ mod tests {
let p2pkh = Address::p2pkh(pubkey, Network::Bitcoin);
assert_eq!(signature2.is_signed_by_address(&p2pkh, msg_hash), Ok(true));
- assert_eq!(pubkey, CompressedPublicKey::from_private_key(privkey).unwrap());
+ assert_eq!(pubkey, FullPublicKey::from_private_key(privkey).unwrap());
let signature_base64 = signature.to_base64();
let signature_round_trip =
super::MessageSignature::from_base64(&signature_base64).expect("message signature");
Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.