@@ -204,7 +204,7 @@ impl SecretKey {
204
204
SecretKey ( sk)
205
205
}
206
206
207
- /// Serialize the secret key as byte value
207
+ /// Serializes the secret key as byte value.
208
208
#[ inline]
209
209
pub fn serialize_secret ( & self ) -> [ u8 ; constants:: SECRET_KEY_SIZE ] {
210
210
self . 0
@@ -225,9 +225,12 @@ impl SecretKey {
225
225
}
226
226
227
227
#[ inline]
228
- /// Adds one secret key to another, modulo the curve order. WIll
229
- /// return an error if the resulting key would be invalid or if
230
- /// the tweak was not a 32-byte length slice.
228
+ /// Adds one secret key to another, modulo the curve order.
229
+ ///
230
+ /// # Errors
231
+ ///
232
+ /// Returns an error if the resulting key would be invalid or if the tweak was not a 32-byte
233
+ /// length slice.
231
234
pub fn add_assign (
232
235
& mut self ,
233
236
other : & [ u8 ] ,
@@ -345,7 +348,7 @@ impl PublicKey {
345
348
}
346
349
}
347
350
348
- /// Creates a public key directly from a slice
351
+ /// Creates a public key directly from a slice.
349
352
#[ inline]
350
353
pub fn from_slice ( data : & [ u8 ] ) -> Result < PublicKey , Error > {
351
354
if data. is_empty ( ) { return Err ( Error :: InvalidPublicKey ) ; }
@@ -394,9 +397,8 @@ impl PublicKey {
394
397
}
395
398
396
399
#[ inline]
397
- /// Serialize the key as a byte-encoded pair of values. In compressed form
398
- /// the y-coordinate is represented by only a single bit, as x determines
399
- /// it up to one bit.
400
+ /// Serializes the key as a byte-encoded pair of values. In compressed form the y-coordinate is
401
+ /// represented by only a single bit, as x determines it up to one bit.
400
402
pub fn serialize ( & self ) -> [ u8 ; constants:: PUBLIC_KEY_SIZE ] {
401
403
let mut ret = [ 0u8 ; constants:: PUBLIC_KEY_SIZE ] ;
402
404
@@ -415,7 +417,7 @@ impl PublicKey {
415
417
ret
416
418
}
417
419
418
- /// Serialize the key as a byte-encoded pair of values, in uncompressed form
420
+ /// Serializes the key as a byte-encoded pair of values, in uncompressed form.
419
421
pub fn serialize_uncompressed ( & self ) -> [ u8 ; constants:: UNCOMPRESSED_PUBLIC_KEY_SIZE ] {
420
422
let mut ret = [ 0u8 ; constants:: UNCOMPRESSED_PUBLIC_KEY_SIZE ] ;
421
423
@@ -435,8 +437,7 @@ impl PublicKey {
435
437
}
436
438
437
439
#[ inline]
438
- /// Negates the pk to the pk `self` in place
439
- /// Will return an error if the pk would be invalid.
440
+ /// Negates the public key in place.
440
441
pub fn negate_assign < C : Verification > (
441
442
& mut self ,
442
443
secp : & Secp256k1 < C >
@@ -448,9 +449,12 @@ impl PublicKey {
448
449
}
449
450
450
451
#[ inline]
451
- /// Adds the pk corresponding to `other` to the pk `self` in place
452
- /// Will return an error if the resulting key would be invalid or
453
- /// if the tweak was not a 32-byte length slice.
452
+ /// Adds the `other` public key to `self` in place.
453
+ ///
454
+ /// # Errors
455
+ ///
456
+ /// Returns an error if the resulting key would be invalid or if the tweak was not a 32-byte
457
+ /// length slice.
454
458
pub fn add_exp_assign < C : Verification > (
455
459
& mut self ,
456
460
secp : & Secp256k1 < C > ,
@@ -469,9 +473,12 @@ impl PublicKey {
469
473
}
470
474
471
475
#[ inline]
472
- /// Muliplies the pk `self` in place by the scalar `other`
473
- /// Will return an error if the resulting key would be invalid or
474
- /// if the tweak was not a 32-byte length slice.
476
+ /// Muliplies the public key in place by the scalar `other`.
477
+ ///
478
+ /// # Errors
479
+ ///
480
+ /// Returns an error if the resulting key would be invalid or if the tweak was not a 32-byte
481
+ /// length slice.
475
482
pub fn mul_assign < C : Verification > (
476
483
& mut self ,
477
484
secp : & Secp256k1 < C > ,
@@ -667,7 +674,7 @@ impl KeyPair {
667
674
& mut self . 0
668
675
}
669
676
670
- /// Creates a Schnorr KeyPair directly from generic Secp256k1 secret key.
677
+ /// Creates a Schnorr [` KeyPair`] directly from generic Secp256k1 secret key.
671
678
///
672
679
/// # Panics
673
680
///
@@ -689,7 +696,7 @@ impl KeyPair {
689
696
}
690
697
}
691
698
692
- /// Creates a Schnorr KeyPair directly from a secret key slice.
699
+ /// Creates a Schnorr [` KeyPair`] directly from a secret key slice.
693
700
///
694
701
/// # Errors
695
702
///
@@ -714,7 +721,7 @@ impl KeyPair {
714
721
}
715
722
}
716
723
717
- /// Creates a Schnorr KeyPair directly from a secret key string
724
+ /// Creates a Schnorr [` KeyPair`] directly from a secret key string.
718
725
///
719
726
/// # Errors
720
727
///
@@ -945,13 +952,13 @@ impl str::FromStr for XOnlyPublicKey {
945
952
}
946
953
947
954
impl XOnlyPublicKey {
948
- /// Obtains a raw const pointer suitable for use with FFI functions
955
+ /// Obtains a raw const pointer suitable for use with FFI functions.
949
956
#[ inline]
950
957
pub fn as_ptr ( & self ) -> * const ffi:: XOnlyPublicKey {
951
958
& self . 0
952
959
}
953
960
954
- /// Obtains a raw mutable pointer suitable for use with FFI functions
961
+ /// Obtains a raw mutable pointer suitable for use with FFI functions.
955
962
#[ inline]
956
963
pub fn as_mut_ptr ( & mut self ) -> * mut ffi:: XOnlyPublicKey {
957
964
& mut self . 0
@@ -974,12 +981,12 @@ impl XOnlyPublicKey {
974
981
}
975
982
}
976
983
977
- /// Creates a Schnorr public key directly from a slice
984
+ /// Creates a Schnorr public key directly from a slice.
978
985
///
979
986
/// # Errors
980
987
///
981
988
/// Returns [`Error::InvalidPublicKey`] if the length of the data slice is not 32 bytes or the
982
- /// slice does not represent a valid Secp256k1 point x coordinate
989
+ /// slice does not represent a valid Secp256k1 point x coordinate.
983
990
#[ inline]
984
991
pub fn from_slice ( data : & [ u8 ] ) -> Result < XOnlyPublicKey , Error > {
985
992
if data. is_empty ( ) || data. len ( ) != constants:: SCHNORRSIG_PUBLIC_KEY_SIZE {
@@ -1002,7 +1009,7 @@ impl XOnlyPublicKey {
1002
1009
}
1003
1010
1004
1011
#[ inline]
1005
- /// Serialize the key as a byte-encoded x coordinate value (32 bytes).
1012
+ /// Serializes the key as a byte-encoded x coordinate value (32 bytes).
1006
1013
pub fn serialize ( & self ) -> [ u8 ; constants:: SCHNORRSIG_PUBLIC_KEY_SIZE ] {
1007
1014
let mut ret = [ 0u8 ; constants:: SCHNORRSIG_PUBLIC_KEY_SIZE ] ;
1008
1015
@@ -1194,7 +1201,7 @@ impl CPtr for XOnlyPublicKey {
1194
1201
}
1195
1202
}
1196
1203
1197
- /// Creates a new Schnorr public key from a FFI x-only public key
1204
+ /// Creates a new Schnorr public key from a FFI x-only public key.
1198
1205
impl From < ffi:: XOnlyPublicKey > for XOnlyPublicKey {
1199
1206
#[ inline]
1200
1207
fn from ( pk : ffi:: XOnlyPublicKey ) -> XOnlyPublicKey {
0 commit comments