Skip to content

Commit 79770e1

Browse files
committed
Deprecate SCHNORRSIG_SIGNATURE_SIZE
Recently we moved from using the identifier 'schnorrsig' to 'schnorr', we omitted to update the schnorr signature size constant. Deprecate `SCHNORRSIG_SIGNATURE_SIZE` and add `SCHONORR_SIGNATURE_SIZE`.
1 parent 7a417fd commit 79770e1

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/constants.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ pub const MAX_SIGNATURE_SIZE: usize = 72;
3535
pub const COMPACT_SIGNATURE_SIZE: usize = 64;
3636

3737
/// The size of a Schnorr signature.
38-
pub const SCHNORRSIG_SIGNATURE_SIZE: usize = 64;
38+
pub const SCHNORR_SIGNATURE_SIZE: usize = 64;
39+
40+
/// The size of a Schnorr signature.
41+
#[deprecated(since = "0.22.0", note = "Use SCHNORR_SIGNATURE_SIZE instead.")]
42+
pub const SCHNORRSIG_SIGNATURE_SIZE: usize = SCHNORR_SIGNATURE_SIZE;
3943

4044
/// The size of a Schnorr public key.
4145
pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;

src/schnorr.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use {Message, Signing, Verification, KeyPair, XOnlyPublicKey};
1717
use SECP256K1;
1818

1919
/// Represents a Schnorr signature.
20-
pub struct Signature([u8; constants::SCHNORRSIG_SIGNATURE_SIZE]);
21-
impl_array_newtype!(Signature, u8, constants::SCHNORRSIG_SIGNATURE_SIZE);
20+
pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]);
21+
impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE);
2222
impl_pretty_debug!(Signature);
2323

2424
#[cfg(feature = "serde")]
@@ -68,10 +68,10 @@ impl fmt::Display for Signature {
6868
impl str::FromStr for Signature {
6969
type Err = Error;
7070
fn from_str(s: &str) -> Result<Signature, Error> {
71-
let mut res = [0u8; constants::SCHNORRSIG_SIGNATURE_SIZE];
71+
let mut res = [0u8; constants::SCHNORR_SIGNATURE_SIZE];
7272
match from_hex(s, &mut res) {
73-
Ok(constants::SCHNORRSIG_SIGNATURE_SIZE) => {
74-
Signature::from_slice(&res[0..constants::SCHNORRSIG_SIGNATURE_SIZE])
73+
Ok(constants::SCHNORR_SIGNATURE_SIZE) => {
74+
Signature::from_slice(&res[0..constants::SCHNORR_SIGNATURE_SIZE])
7575
}
7676
_ => Err(Error::InvalidSignature),
7777
}
@@ -83,8 +83,8 @@ impl Signature {
8383
#[inline]
8484
pub fn from_slice(data: &[u8]) -> Result<Signature, Error> {
8585
match data.len() {
86-
constants::SCHNORRSIG_SIGNATURE_SIZE => {
87-
let mut ret = [0u8; constants::SCHNORRSIG_SIGNATURE_SIZE];
86+
constants::SCHNORR_SIGNATURE_SIZE => {
87+
let mut ret = [0u8; constants::SCHNORR_SIGNATURE_SIZE];
8888
ret[..].copy_from_slice(data);
8989
Ok(Signature(ret))
9090
}
@@ -109,7 +109,7 @@ impl<C: Signing> Secp256k1<C> {
109109
nonce_data: *const ffi::types::c_void,
110110
) -> Signature {
111111
unsafe {
112-
let mut sig = [0u8; constants::SCHNORRSIG_SIGNATURE_SIZE];
112+
let mut sig = [0u8; constants::SCHNORR_SIGNATURE_SIZE];
113113
assert_eq!(
114114
1,
115115
ffi::secp256k1_schnorrsig_sign(
@@ -567,7 +567,7 @@ mod tests {
567567
let aux = [3u8; 32];
568568
let sig = s
569569
.sign_schnorr_with_aux_rand(&msg, &keypair, &aux);
570-
static SIG_BYTES: [u8; constants::SCHNORRSIG_SIGNATURE_SIZE] = [
570+
static SIG_BYTES: [u8; constants::SCHNORR_SIGNATURE_SIZE] = [
571571
0x14, 0xd0, 0xbf, 0x1a, 0x89, 0x53, 0x50, 0x6f, 0xb4, 0x60, 0xf5, 0x8b, 0xe1, 0x41,
572572
0xaf, 0x76, 0x7f, 0xd1, 0x12, 0x53, 0x5f, 0xb3, 0x92, 0x2e, 0xf2, 0x17, 0x30, 0x8e,
573573
0x2c, 0x26, 0x70, 0x6f, 0x1e, 0xeb, 0x43, 0x2b, 0x3d, 0xba, 0x9a, 0x01, 0x08, 0x2f,

0 commit comments

Comments
 (0)