Skip to content

Commit 909fcd5

Browse files
committed
Merge #740: fix docs for new clippy lint
3810686 Revert "Automated update to Github CI to rustc nightly-2024-09-10" (Andrew Poelstra) d3d9a05 fix docs for new clippy lint. (Andrew Poelstra) Pull request description: There are a bunch of doccomments whose first lines are (much) too long. Most of these are also difficult to understand and/or out-of-date. Just rewrite them all. ACKs for top commit: Kixunil: ACK 3810686 Tree-SHA512: 291bd2c30c8d46c54d99eba17b6cc5f018912b906f4395fa753218551c1ba50724bdd55699f12bf9de254debf9612541c47e1fcd9c2eb04784f71c21e94b5ea5
2 parents 818192b + 3810686 commit 909fcd5

File tree

4 files changed

+50
-26
lines changed

4 files changed

+50
-26
lines changed

nightly-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2024-09-10
1+
nightly-2024-08-04

secp256k1-sys/src/lib.rs

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ pub const SECP256K1_SER_UNCOMPRESSED: c_uint = (1 << 1);
4141
/// Flag for keys to indicate compressed serialization format
4242
pub const SECP256K1_SER_COMPRESSED: c_uint = (1 << 1) | (1 << 8);
4343

44-
/// A nonce generation function. Ordinary users of the library
45-
/// never need to see this type; only if you need to control
46-
/// nonce generation do you need to use it. I have deliberately
47-
/// made this hard to do: you have to write your own wrapper
48-
/// around the FFI functions to use it. And it's an unsafe type.
49-
/// Nonces are generated deterministically by RFC6979 by
50-
/// default; there should be no need to ever change this.
44+
/// A nonce generation function.
45+
///
46+
/// Ordinary users of the library never need to see this type; the default
47+
/// nonce generation function should be sufficient for almost all usecases.
48+
///
49+
/// To use this type, you must write your own (unsafe) wrapper. It is unsafe
50+
/// because any secure implementation must dereference the passed-in raw
51+
/// pointers and/or call FFI functions.
5152
pub type NonceFn = Option<unsafe extern "C" fn(
5253
nonce32: *mut c_uchar,
5354
msg32: *const c_uchar,
@@ -66,11 +67,15 @@ pub type EcdhHashFn = Option<unsafe extern "C" fn(
6667
data: *mut c_void,
6768
) -> c_int>;
6869

69-
/// Same as secp256k1_nonce function with the exception of accepting an
70-
/// additional pubkey argument and not requiring an attempt argument. The pubkey
71-
/// argument can protect signature schemes with key-prefixed challenge hash
72-
/// inputs against reusing the nonce when signing with the wrong precomputed
73-
/// pubkey.
70+
/// Same as [`NonceFn`], but accepts an additional pubkey argument and does not
71+
/// accept an attempt argument.
72+
///
73+
/// The pubkey argument will protect signature schemes with tweaked keys from
74+
/// reusing the nonce when signing with a different precomputed pubkey, which
75+
/// for BIP 340 signatures is just as bad as reusing a nonce across different
76+
/// messages.
77+
///
78+
/// As with [`NonceFn`] ordinary users should never need to touch this type.
7479
pub type SchnorrNonceFn = Option<unsafe extern "C" fn(
7580
nonce32: *mut c_uchar,
7681
msg32: *const c_uchar,
@@ -119,10 +124,19 @@ impl SchnorrSigExtraParams {
119124
}
120125
}
121126

122-
/// A Secp256k1 context, containing various precomputed values and such
123-
/// needed to do elliptic curve computations. If you create one of these
124-
/// with `secp256k1_context_create` you MUST destroy it with
125-
/// `secp256k1_context_destroy`, or else you will have a memory leak.
127+
/// An opaque Secp256k1 context.
128+
///
129+
/// Currently this object contains a blinding factor used internally to
130+
/// randomize computations to protect against sidechannel attacks. In the
131+
/// past it has contained precomputation tables to speed up crypto operations.
132+
///
133+
/// It should be assumed to be expensive to create and therefore should be
134+
/// reused when possible.
135+
///
136+
/// If you create one of these with `secp256k1_context_create` you must
137+
/// destroy it with `secp256k1_context_destroy`. (Failure to destroy it is
138+
/// a memory leak; destroying it using any other allocator is undefined
139+
/// behavior.)
126140
#[derive(Clone, Debug)]
127141
#[repr(C)] pub struct Context(c_int);
128142

src/ellswift.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ where
7171
1
7272
}
7373

74-
/// `ElligatorSwift` is an encoding of a uniformly chosen point on the curve
75-
/// as a 64-byte array that is indistinguishable from a uniformly random array.
74+
/// An encoding of an elliptic curvepoint such that a uniformly random on-curve
75+
/// point will be encoded as uniformly random bits.
76+
///
7677
/// This object holds two field elements u and t, which are the inputs to
7778
/// the `ElligatorSwift` encoding function.
7879
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -280,10 +281,15 @@ impl ElligatorSwiftSharedSecret {
280281
pub const fn as_secret_bytes(&self) -> &[u8; 32] { &self.0 }
281282
}
282283

283-
/// Represents which party we are in the ECDH, A is the initiator, B is the responder.
284-
/// This is important because the hash of the shared secret is different depending on which party
285-
/// we are. In this context, "we" means the party that is using this library, and possesses the
286-
/// secret key passed to `ElligatorSwift::shared_secret`.
284+
/// Represents which party we are in the ECDH.
285+
///
286+
/// Here `A` is the initiator and `B` is the responder.
287+
///
288+
/// this context, "we" means the party that possesses the secret key passed to
289+
/// [`ElligatorSwift::shared_secret`].
290+
///
291+
/// This distinction is important because the different parties compute different
292+
/// hashes of the shared secret.
287293
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
288294
pub enum ElligatorSwiftParty {
289295
/// We are the initiator of the ECDH

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ use crate::ffi::CPtr;
194194
pub use crate::key::{InvalidParityValue, Keypair, Parity, PublicKey, SecretKey, XOnlyPublicKey};
195195
pub use crate::scalar::Scalar;
196196

197-
/// Trait describing something that promises to be a 32-byte random number; in particular,
198-
/// it has negligible probability of being zero or overflowing the group order. Such objects
199-
/// may be converted to `Message`s without any error paths.
197+
/// Trait describing something that promises to be a 32-byte uniformly random number.
198+
///
199+
/// In particular, anything implementing this trait must have neglibile probability
200+
/// of being zero, overflowing the group order, or equalling any specific value.
201+
///
202+
/// Since version 0.29 this has been deprecated; users should instead implement
203+
/// `Into<Message>` for types that satisfy these properties.
200204
#[deprecated(
201205
since = "0.29.0",
202206
note = "Please see v0.29.0 rust-secp256k1/CHANGELOG.md for suggestion"

0 commit comments

Comments
 (0)