@@ -17,18 +17,18 @@ use crate::{
17
17
Verification , XOnlyPublicKey ,
18
18
} ;
19
19
20
- /// Serialized length (in bytes) of the aggregated nonce.
20
+ /// Serialized size (in bytes) of the aggregated nonce.
21
21
/// The serialized form is used for transmitting or storing the aggregated nonce.
22
- pub const AGGNONCE_SERIALIZED_LEN : usize = 66 ;
22
+ pub const AGGNONCE_SERIALIZED_SIZE : usize = 66 ;
23
23
24
- /// Serialized length (in bytes) of an individual public nonce.
24
+ /// Serialized size (in bytes) of an individual public nonce.
25
25
/// The serialized form is used for transmission between signers.
26
- pub const PUBNONCE_SERIALIZED_LEN : usize = 66 ;
26
+ pub const PUBNONCE_SERIALIZED_SIZE : usize = 66 ;
27
27
28
- /// Serialized length (in bytes) of a partial signature.
28
+ /// Serialized size (in bytes) of a partial signature.
29
29
/// The serialized form is used for transmitting partial signatures to be
30
30
/// aggregated into the final signature.
31
- pub const PART_SIG_SERIALIZED_LEN : usize = 32 ;
31
+ pub const PART_SIG_SERIALIZED_SIZE : usize = 32 ;
32
32
33
33
/// Musig parsing errors
34
34
#[ derive( Debug , Clone , Copy , Eq , PartialEq , PartialOrd , Ord , Hash ) ]
@@ -257,9 +257,9 @@ impl fmt::Display for PartialSignature {
257
257
impl core:: str:: FromStr for PartialSignature {
258
258
type Err = ParseError ;
259
259
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
260
- let mut res = [ 0u8 ; PART_SIG_SERIALIZED_LEN ] ;
260
+ let mut res = [ 0u8 ; PART_SIG_SERIALIZED_SIZE ] ;
261
261
match from_hex ( s, & mut res) {
262
- Ok ( PART_SIG_SERIALIZED_LEN ) => PartialSignature :: from_byte_array ( & res) ,
262
+ Ok ( PART_SIG_SERIALIZED_SIZE ) => PartialSignature :: from_byte_array ( & res) ,
263
263
_ => Err ( ParseError :: MalformedArg ) ,
264
264
}
265
265
}
@@ -287,7 +287,7 @@ impl<'de> serde::Deserialize<'de> for PartialSignature {
287
287
d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
288
288
"a raw MuSig2 partial signature" ,
289
289
|slice| {
290
- let bytes: & [ u8 ; PART_SIG_SERIALIZED_LEN ] =
290
+ let bytes: & [ u8 ; PART_SIG_SERIALIZED_SIZE ] =
291
291
slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
292
292
293
293
Self :: from_byte_array ( bytes)
@@ -299,8 +299,8 @@ impl<'de> serde::Deserialize<'de> for PartialSignature {
299
299
300
300
impl PartialSignature {
301
301
/// Serialize a PartialSignature as a byte array.
302
- pub fn serialize ( & self ) -> [ u8 ; PART_SIG_SERIALIZED_LEN ] {
303
- let mut data = MaybeUninit :: < [ u8 ; PART_SIG_SERIALIZED_LEN ] > :: uninit ( ) ;
302
+ pub fn serialize ( & self ) -> [ u8 ; PART_SIG_SERIALIZED_SIZE ] {
303
+ let mut data = MaybeUninit :: < [ u8 ; PART_SIG_SERIALIZED_SIZE ] > :: uninit ( ) ;
304
304
unsafe {
305
305
if ffi:: secp256k1_musig_partial_sig_serialize (
306
306
ffi:: secp256k1_context_no_precomp,
@@ -321,9 +321,7 @@ impl PartialSignature {
321
321
/// # Errors:
322
322
///
323
323
/// - MalformedArg: If the signature [`PartialSignature`] is out of curve order
324
- pub fn from_byte_array (
325
- data : & [ u8 ; PART_SIG_SERIALIZED_LEN ] ,
326
- ) -> Result < Self , ParseError > {
324
+ pub fn from_byte_array ( data : & [ u8 ; PART_SIG_SERIALIZED_SIZE ] ) -> Result < Self , ParseError > {
327
325
let mut partial_sig = MaybeUninit :: < ffi:: MusigPartialSignature > :: uninit ( ) ;
328
326
unsafe {
329
327
if ffi:: secp256k1_musig_partial_sig_parse (
@@ -686,14 +684,14 @@ impl SecretNonce {
686
684
///
687
685
/// See <https://blockstream.com/2019/02/18/musig-a-new-multisignature-standard/>
688
686
/// for more details about these risks.
689
- pub fn dangerous_into_bytes ( self ) -> [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_LEN ] {
687
+ pub fn dangerous_into_bytes ( self ) -> [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_SIZE ] {
690
688
self . 0 . dangerous_into_bytes ( )
691
689
}
692
690
693
691
/// Function to create a new [`SecretNonce`] from a 32 byte array.
694
692
///
695
693
/// Refer to the warning on [`SecretNonce::dangerous_into_bytes`] for more details.
696
- pub fn dangerous_from_bytes ( array : [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_LEN ] ) -> Self {
694
+ pub fn dangerous_from_bytes ( array : [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_SIZE ] ) -> Self {
697
695
SecretNonce ( ffi:: MusigSecNonce :: dangerous_from_bytes ( array) )
698
696
}
699
697
}
@@ -727,9 +725,9 @@ impl fmt::Display for PublicNonce {
727
725
impl core:: str:: FromStr for PublicNonce {
728
726
type Err = ParseError ;
729
727
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
730
- let mut res = [ 0u8 ; PUBNONCE_SERIALIZED_LEN ] ;
728
+ let mut res = [ 0u8 ; PUBNONCE_SERIALIZED_SIZE ] ;
731
729
match from_hex ( s, & mut res) {
732
- Ok ( PUBNONCE_SERIALIZED_LEN ) => PublicNonce :: from_byte_array ( & res) ,
730
+ Ok ( PUBNONCE_SERIALIZED_SIZE ) => PublicNonce :: from_byte_array ( & res) ,
733
731
_ => Err ( ParseError :: MalformedArg ) ,
734
732
}
735
733
}
@@ -757,7 +755,7 @@ impl<'de> serde::Deserialize<'de> for PublicNonce {
757
755
d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
758
756
"a raw MuSig2 public nonce" ,
759
757
|slice| {
760
- let bytes: & [ u8 ; PUBNONCE_SERIALIZED_LEN ] =
758
+ let bytes: & [ u8 ; PUBNONCE_SERIALIZED_SIZE ] =
761
759
slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
762
760
763
761
Self :: from_byte_array ( bytes)
@@ -769,8 +767,8 @@ impl<'de> serde::Deserialize<'de> for PublicNonce {
769
767
770
768
impl PublicNonce {
771
769
/// Serialize a PublicNonce
772
- pub fn serialize ( & self ) -> [ u8 ; PUBNONCE_SERIALIZED_LEN ] {
773
- let mut data = [ 0 ; PUBNONCE_SERIALIZED_LEN ] ;
770
+ pub fn serialize ( & self ) -> [ u8 ; PUBNONCE_SERIALIZED_SIZE ] {
771
+ let mut data = [ 0 ; PUBNONCE_SERIALIZED_SIZE ] ;
774
772
unsafe {
775
773
if ffi:: secp256k1_musig_pubnonce_serialize (
776
774
ffi:: secp256k1_context_no_precomp,
@@ -791,9 +789,7 @@ impl PublicNonce {
791
789
/// # Errors:
792
790
///
793
791
/// - MalformedArg: If the [`PublicNonce`] is 132 bytes, but out of curve order
794
- pub fn from_byte_array (
795
- data : & [ u8 ; PUBNONCE_SERIALIZED_LEN ] ,
796
- ) -> Result < Self , ParseError > {
792
+ pub fn from_byte_array ( data : & [ u8 ; PUBNONCE_SERIALIZED_SIZE ] ) -> Result < Self , ParseError > {
797
793
let mut pub_nonce = MaybeUninit :: < ffi:: MusigPubNonce > :: uninit ( ) ;
798
794
unsafe {
799
795
if ffi:: secp256k1_musig_pubnonce_parse (
@@ -844,9 +840,9 @@ impl fmt::Display for AggregatedNonce {
844
840
impl core:: str:: FromStr for AggregatedNonce {
845
841
type Err = ParseError ;
846
842
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
847
- let mut res = [ 0u8 ; AGGNONCE_SERIALIZED_LEN ] ;
843
+ let mut res = [ 0u8 ; AGGNONCE_SERIALIZED_SIZE ] ;
848
844
match from_hex ( s, & mut res) {
849
- Ok ( AGGNONCE_SERIALIZED_LEN ) => AggregatedNonce :: from_byte_array ( & res) ,
845
+ Ok ( AGGNONCE_SERIALIZED_SIZE ) => AggregatedNonce :: from_byte_array ( & res) ,
850
846
_ => Err ( ParseError :: MalformedArg ) ,
851
847
}
852
848
}
@@ -874,7 +870,7 @@ impl<'de> serde::Deserialize<'de> for AggregatedNonce {
874
870
d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
875
871
"a raw MuSig2 aggregated nonce" ,
876
872
|slice| {
877
- let bytes: & [ u8 ; AGGNONCE_SERIALIZED_LEN ] =
873
+ let bytes: & [ u8 ; AGGNONCE_SERIALIZED_SIZE ] =
878
874
slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
879
875
880
876
Self :: from_byte_array ( bytes)
@@ -954,8 +950,8 @@ impl AggregatedNonce {
954
950
}
955
951
956
952
/// Serialize a AggregatedNonce into a 66 bytes array.
957
- pub fn serialize ( & self ) -> [ u8 ; AGGNONCE_SERIALIZED_LEN ] {
958
- let mut data = [ 0 ; AGGNONCE_SERIALIZED_LEN ] ;
953
+ pub fn serialize ( & self ) -> [ u8 ; AGGNONCE_SERIALIZED_SIZE ] {
954
+ let mut data = [ 0 ; AGGNONCE_SERIALIZED_SIZE ] ;
959
955
unsafe {
960
956
if ffi:: secp256k1_musig_aggnonce_serialize (
961
957
ffi:: secp256k1_context_no_precomp,
@@ -976,9 +972,7 @@ impl AggregatedNonce {
976
972
/// # Errors:
977
973
///
978
974
/// - MalformedArg: If the byte slice is 66 bytes, but the [`AggregatedNonce`] is invalid
979
- pub fn from_byte_array (
980
- data : & [ u8 ; AGGNONCE_SERIALIZED_LEN ] ,
981
- ) -> Result < Self , ParseError > {
975
+ pub fn from_byte_array ( data : & [ u8 ; AGGNONCE_SERIALIZED_SIZE ] ) -> Result < Self , ParseError > {
982
976
let mut aggnonce = MaybeUninit :: < ffi:: MusigAggNonce > :: uninit ( ) ;
983
977
unsafe {
984
978
if ffi:: secp256k1_musig_aggnonce_parse (
0 commit comments