diff --git a/Cargo.toml b/Cargo.toml index 7b4dc33fcc..6807491b26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] bech32 = { version = "0.8.1", default-features = false } bitcoin_hashes = { version = "0.10.0", default-features = false } -secp256k1 = { version = "0.21.2", default-features = false } +secp256k1 = { version = "0.22.0", default-features = false } core2 = { version = "0.3.0", optional = true, default-features = false } base64-compat = { version = "1.0.0", optional = true } @@ -47,7 +47,7 @@ hashbrown = { version = "0.8", optional = true } [dev-dependencies] serde_json = "<1.0.45" serde_test = "1" -secp256k1 = { version = "0.21.2", features = [ "recovery", "rand-std" ] } +secp256k1 = { version = "0.22.0", features = [ "recovery", "rand-std" ] } bincode = "1.3.1" # We need to pin ryu (transitive dep from serde_json) to stay compatible with Rust 1.22.0 ryu = "<1.0.5" diff --git a/src/util/schnorr.rs b/src/util/schnorr.rs index 3ecce4a2c6..6a30000a9c 100644 --- a/src/util/schnorr.rs +++ b/src/util/schnorr.rs @@ -174,7 +174,7 @@ impl TweakedPublicKey { /// the y-coordinate is represented by only a single bit, as x determines /// it up to one bit. #[inline] - pub fn serialize(&self) -> [u8; constants::SCHNORRSIG_PUBLIC_KEY_SIZE] { + pub fn serialize(&self) -> [u8; constants::SCHNORR_PUBLIC_KEY_SIZE] { self.0.serialize() } } diff --git a/src/util/taproot.rs b/src/util/taproot.rs index f020b1175a..f66bba2dac 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -682,7 +682,8 @@ impl ControlBlock { { return Err(TaprootError::InvalidControlBlockSize(sl.len())); } - let output_key_parity = secp256k1::Parity::from((sl[0] & 1) as i32); + let output_key_parity = secp256k1::Parity::from_i32((sl[0] & 1) as i32) + .map_err(TaprootError::InvalidParity)?; let leaf_version = LeafVersion::from_consensus(sl[0] & TAPROOT_LEAF_MASK)?; let internal_key = UntweakedPublicKey::from_slice(&sl[1..TAPROOT_CONTROL_BASE_SIZE]) .map_err(TaprootError::InvalidInternalKey)?; @@ -970,6 +971,8 @@ pub enum TaprootError { InvalidControlBlockSize(usize), /// Invalid taproot internal key InvalidInternalKey(secp256k1::Error), + /// Invalid parity for internal key + InvalidParity(secp256k1::InvalidParityValue), /// Empty TapTree EmptyTree, } @@ -999,6 +1002,7 @@ impl fmt::Display for TaprootError { ), // TODO: add source when in MSRV TaprootError::InvalidInternalKey(e) => write!(f, "Invalid Internal XOnly key : {}", e), + TaprootError::InvalidParity(e) => write!(f, "Invalid parity value for internal key: {}", e), TaprootError::EmptyTree => write!(f, "Taproot Tree must contain at least one script"), } }