@@ -572,24 +572,15 @@ impl KeyAggCache {
572
572
573
573
/// Musig Secret Nonce.
574
574
///
575
- /// This structure MUST NOT be copied or
576
- /// read or written to it directly. A signer who is online throughout the whole
577
- /// process and can keep this structure in memory can use the provided API
578
- /// functions for a safe standard workflow. See
579
- /// <https://blockstream.com/2019/02/18/musig-a-new-multisignature-standard/> for
580
- /// more details about the risks associated with serializing or deserializing
581
- /// this structure. There are no serialization and parsing functions (yet).
575
+ /// A signer who is online throughout the whole process and can keep this structure
576
+ /// in memory can use the provided API functions for a safe standard workflow.
582
577
///
583
- /// Note this deliberately does not implement `Copy` or `Clone`. After creation, the only
584
- /// use of this nonce is [`Session::partial_sign`] API that takes ownership of this
585
- /// and drops it . This is to prevent accidental misuse of this nonce.
578
+ /// This structure does not implement `Copy` or `Clone`; after construction the only
579
+ /// thing that can or should be done with this nonce is to call [`Session::partial_sign`],
580
+ /// which will take ownership . This is to prevent accidental reuse of the nonce.
586
581
///
587
- /// A signer who is online throughout the whole process and can keep this
588
- /// structure in memory can use the provided API functions for a safe standard
589
- /// workflow.
590
- ///
591
- /// Signers that pre-compute and save these nonces are not yet supported. Users
592
- /// who want to serialize this must use unsafe rust to do so.
582
+ /// See the warning on [`Self::dangerous_into_bytes`] for more information about
583
+ /// the risks of non-standard workflows.
593
584
#[ allow( missing_copy_implementations) ]
594
585
#[ derive( Debug ) ]
595
586
pub struct SecretNonce ( ffi:: MusigSecNonce ) ;
@@ -612,20 +603,20 @@ impl SecretNonce {
612
603
/// Function to return a copy of the internal array. See WARNING before using this function.
613
604
///
614
605
/// # Warning:
615
- /// This structure MUST NOT be copied or read or written to directly. A
616
- /// signer who is online throughout the whole process and can keep this
617
- /// structure in memory can use the provided API functions for a safe standard
618
- /// workflow.
619
606
///
620
- /// We repeat, copying this data structure can result in nonce reuse which will
621
- /// leak the secret signing key.
607
+ /// Storing and re-creating this structure may leak to nonce reuse, which will leak
608
+ /// your secret key in two signing sessions, even if neither session is completed.
609
+ /// These functions should be avoided if possible and used with care.
610
+ ///
611
+ /// See <https://blockstream.com/2019/02/18/musig-a-new-multisignature-standard/>
612
+ /// for more details about these risks.
622
613
pub fn dangerous_into_bytes ( self ) -> [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_LEN ] {
623
614
self . 0 . dangerous_into_bytes ( )
624
615
}
625
616
626
- /// Function to create a new MusigKeyAggCoef from a 32 byte array. See WARNING before using this function .
617
+ /// Function to create a new [`SecretNonce`] from a 32 byte array.
627
618
///
628
- /// Refer to [`SecretNonce::dangerous_into_bytes`] for more details.
619
+ /// Refer to the warning on [`SecretNonce::dangerous_into_bytes`] for more details.
629
620
pub fn dangerous_from_bytes ( array : [ u8 ; secp256k1_sys:: MUSIG_SECNONCE_LEN ] ) -> Self {
630
621
SecretNonce ( ffi:: MusigSecNonce :: dangerous_from_bytes ( array) )
631
622
}
0 commit comments