@@ -17,18 +17,18 @@ use crate::{
1717 Verification , XOnlyPublicKey ,
1818} ;
1919
20- /// Serialized length (in bytes) of the aggregated nonce.
20+ /// Serialized size (in bytes) of the aggregated nonce.
2121/// 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 ;
2323
24- /// Serialized length (in bytes) of an individual public nonce.
24+ /// Serialized size (in bytes) of an individual public nonce.
2525/// 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 ;
2727
28- /// Serialized length (in bytes) of a partial signature.
28+ /// Serialized size (in bytes) of a partial signature.
2929/// The serialized form is used for transmitting partial signatures to be
3030/// aggregated into the final signature.
31- pub const PART_SIG_SERIALIZED_LEN : usize = 32 ;
31+ pub const PART_SIG_SERIALIZED_SIZE : usize = 32 ;
3232
3333/// Musig parsing errors
3434#[ derive( Debug , Clone , Copy , Eq , PartialEq , PartialOrd , Ord , Hash ) ]
@@ -257,9 +257,9 @@ impl fmt::Display for PartialSignature {
257257impl core:: str:: FromStr for PartialSignature {
258258 type Err = ParseError ;
259259 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 ] ;
261261 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) ,
263263 _ => Err ( ParseError :: MalformedArg ) ,
264264 }
265265 }
@@ -287,7 +287,7 @@ impl<'de> serde::Deserialize<'de> for PartialSignature {
287287 d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
288288 "a raw MuSig2 partial signature" ,
289289 |slice| {
290- let bytes: & [ u8 ; PART_SIG_SERIALIZED_LEN ] =
290+ let bytes: & [ u8 ; PART_SIG_SERIALIZED_SIZE ] =
291291 slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
292292
293293 Self :: from_byte_array ( bytes)
@@ -299,8 +299,8 @@ impl<'de> serde::Deserialize<'de> for PartialSignature {
299299
300300impl PartialSignature {
301301 /// 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 ( ) ;
304304 unsafe {
305305 if ffi:: secp256k1_musig_partial_sig_serialize (
306306 ffi:: secp256k1_context_no_precomp,
@@ -321,9 +321,7 @@ impl PartialSignature {
321321 /// # Errors:
322322 ///
323323 /// - 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 > {
327325 let mut partial_sig = MaybeUninit :: < ffi:: MusigPartialSignature > :: uninit ( ) ;
328326 unsafe {
329327 if ffi:: secp256k1_musig_partial_sig_parse (
@@ -686,14 +684,14 @@ impl SecretNonce {
686684 ///
687685 /// See <https://blockstream.com/2019/02/18/musig-a-new-multisignature-standard/>
688686 /// 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 ] {
690688 self . 0 . dangerous_into_bytes ( )
691689 }
692690
693691 /// Function to create a new [`SecretNonce`] from a 32 byte array.
694692 ///
695693 /// 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 {
697695 SecretNonce ( ffi:: MusigSecNonce :: dangerous_from_bytes ( array) )
698696 }
699697}
@@ -727,9 +725,9 @@ impl fmt::Display for PublicNonce {
727725impl core:: str:: FromStr for PublicNonce {
728726 type Err = ParseError ;
729727 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 ] ;
731729 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) ,
733731 _ => Err ( ParseError :: MalformedArg ) ,
734732 }
735733 }
@@ -757,7 +755,7 @@ impl<'de> serde::Deserialize<'de> for PublicNonce {
757755 d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
758756 "a raw MuSig2 public nonce" ,
759757 |slice| {
760- let bytes: & [ u8 ; PUBNONCE_SERIALIZED_LEN ] =
758+ let bytes: & [ u8 ; PUBNONCE_SERIALIZED_SIZE ] =
761759 slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
762760
763761 Self :: from_byte_array ( bytes)
@@ -769,8 +767,8 @@ impl<'de> serde::Deserialize<'de> for PublicNonce {
769767
770768impl PublicNonce {
771769 /// 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 ] ;
774772 unsafe {
775773 if ffi:: secp256k1_musig_pubnonce_serialize (
776774 ffi:: secp256k1_context_no_precomp,
@@ -791,9 +789,7 @@ impl PublicNonce {
791789 /// # Errors:
792790 ///
793791 /// - 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 > {
797793 let mut pub_nonce = MaybeUninit :: < ffi:: MusigPubNonce > :: uninit ( ) ;
798794 unsafe {
799795 if ffi:: secp256k1_musig_pubnonce_parse (
@@ -844,9 +840,9 @@ impl fmt::Display for AggregatedNonce {
844840impl core:: str:: FromStr for AggregatedNonce {
845841 type Err = ParseError ;
846842 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 ] ;
848844 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) ,
850846 _ => Err ( ParseError :: MalformedArg ) ,
851847 }
852848 }
@@ -874,7 +870,7 @@ impl<'de> serde::Deserialize<'de> for AggregatedNonce {
874870 d. deserialize_bytes ( super :: serde_util:: BytesVisitor :: new (
875871 "a raw MuSig2 aggregated nonce" ,
876872 |slice| {
877- let bytes: & [ u8 ; AGGNONCE_SERIALIZED_LEN ] =
873+ let bytes: & [ u8 ; AGGNONCE_SERIALIZED_SIZE ] =
878874 slice. try_into ( ) . map_err ( |_| ParseError :: MalformedArg ) ?;
879875
880876 Self :: from_byte_array ( bytes)
@@ -954,8 +950,8 @@ impl AggregatedNonce {
954950 }
955951
956952 /// 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 ] ;
959955 unsafe {
960956 if ffi:: secp256k1_musig_aggnonce_serialize (
961957 ffi:: secp256k1_context_no_precomp,
@@ -976,9 +972,7 @@ impl AggregatedNonce {
976972 /// # Errors:
977973 ///
978974 /// - 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 > {
982976 let mut aggnonce = MaybeUninit :: < ffi:: MusigAggNonce > :: uninit ( ) ;
983977 unsafe {
984978 if ffi:: secp256k1_musig_aggnonce_parse (
0 commit comments