Skip to content

Commit

Permalink
Update secp256k1 dependency
Browse files Browse the repository at this point in the history
Update our `rust-secp256k1` dependency to the latest version.

Requires doing:

- Add a new variant to `Error` for the case where parity of the internal
  key is an invalid value (not 0 or 1).
- Use non-deprecated const
  • Loading branch information
tcharding committed Mar 11, 2022
1 parent 337caad commit d68531d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -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 }
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/util/schnorr.rs
Expand Up @@ -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()
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/util/taproot.rs
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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"),
}
}
Expand Down

0 comments on commit d68531d

Please sign in to comment.