Skip to content

Commit efb47e9

Browse files
committed
Merge #532: Do trivial docs improvements
ecdad39 context: Improve rustdocs (Tobin C. Harding) e945751 schnorr: Improve rustdocs (Tobin C. Harding) 47f19a7 Use lowercase for schnorr (Tobin C. Harding) 27b3e92 Do trivial cleanup to module level docs (Tobin C. Harding) Pull request description: Audit of docs in `rust-secp256k1` and do a few trivial fixes. The docs are in pretty good condition, they just need more content as described in #128 if that issue is still valid. ACKs for top commit: apoelstra: ACK ecdad39 Tree-SHA512: 7466090325e02331f11e34cd38625541fbe8e642882afa6ddf2cf5d11ed669c7b2b48fd5b819915392760f4c6ef4ee460c2e622b3af648f99906c3ac408045d4
2 parents e4ed848 + ecdad39 commit efb47e9

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

src/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ pub const MAX_SIGNATURE_SIZE: usize = 72;
3434
/// The maximum size of a compact signature.
3535
pub const COMPACT_SIGNATURE_SIZE: usize = 64;
3636

37-
/// The size of a Schnorr signature.
37+
/// The size of a schnorr signature.
3838
pub const SCHNORR_SIGNATURE_SIZE: usize = 64;
3939

40-
/// The size of a Schnorr public key.
40+
/// The size of a schnorr public key.
4141
pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;
4242

4343
/// The size of a key pair.

src/context.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ pub unsafe trait Context: private::Sealed {
7979
unsafe fn deallocate(ptr: *mut u8, size: usize);
8080
}
8181

82-
/// Marker trait for indicating that an instance of `Secp256k1` can be used for signing.
82+
/// Marker trait for indicating that an instance of [`Secp256k1`] can be used for signing.
8383
pub trait Signing: Context {}
8484

85-
/// Marker trait for indicating that an instance of `Secp256k1` can be used for verification.
85+
/// Marker trait for indicating that an instance of [`Secp256k1`] can be used for verification.
8686
pub trait Verification: Context {}
8787

8888
/// Represents the set of capabilities needed for signing (preallocated memory).
@@ -247,8 +247,8 @@ mod alloc_only {
247247
impl Secp256k1<VerifyOnly> {
248248
/// Creates a new Secp256k1 context that can only be used for verification.
249249
///
250-
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
251-
/// If `rand-std` feature is not enabled please consider randomizing the context (see docs
250+
/// * If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
251+
/// * If `rand-std` feature is not enabled please consider randomizing the context (see docs
252252
/// for `Secp256k1::gen_new()`).
253253
pub fn verification_only() -> Secp256k1<VerifyOnly> { Secp256k1::gen_new() }
254254
}
@@ -307,7 +307,7 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> {
307307
}
308308

309309
impl<'buf, C: Context + 'buf> Secp256k1<C> {
310-
/// Lets you create a context with a preallocated buffer in a generic manner(sign/verify/all).
310+
/// Lets you create a context with a preallocated buffer in a generic manner (sign/verify/all).
311311
pub fn preallocated_gen_new(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<C>, Error> {
312312
#[cfg(target_arch = "wasm32")]
313313
ffi::types::sanity_checks_for_wasm();
@@ -329,7 +329,7 @@ impl<'buf, C: Context + 'buf> Secp256k1<C> {
329329
}
330330

331331
impl<'buf> Secp256k1<AllPreallocated<'buf>> {
332-
/// Creates a new Secp256k1 context with all capabilities
332+
/// Creates a new Secp256k1 context with all capabilities.
333333
pub fn preallocated_new(
334334
buf: &'buf mut [AlignedType],
335335
) -> Result<Secp256k1<AllPreallocated<'buf>>, Error> {
@@ -338,7 +338,7 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> {
338338
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context.
339339
pub fn preallocate_size() -> usize { Self::preallocate_size_gen() }
340340

341-
/// Create a context from a raw context.
341+
/// Creates a context from a raw context.
342342
///
343343
/// # Safety
344344
/// This is highly unsafe, due to the number of conditions that aren't checked.
@@ -372,9 +372,10 @@ impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> {
372372
#[inline]
373373
pub fn preallocate_signing_size() -> usize { Self::preallocate_size_gen() }
374374

375-
/// Create a context from a raw context.
375+
/// Creates a context from a raw context.
376376
///
377377
/// # Safety
378+
///
378379
/// This is highly unsafe, due to the number of conditions that aren't checked.
379380
/// * `raw_ctx` needs to be a valid Secp256k1 context pointer.
380381
/// that was generated by *exactly* the same code/version of the libsecp256k1 used here.
@@ -406,9 +407,10 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> {
406407
#[inline]
407408
pub fn preallocate_verification_size() -> usize { Self::preallocate_size_gen() }
408409

409-
/// Create a context from a raw context.
410+
/// Creates a context from a raw context.
410411
///
411412
/// # Safety
413+
///
412414
/// This is highly unsafe, due to the number of conditions that aren't checked.
413415
/// * `raw_ctx` needs to be a valid Secp256k1 context pointer.
414416
/// that was generated by *exactly* the same code/version of the libsecp256k1 used here.

src/ecdsa/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Structs and functionality related to the ECDSA signature algorithm.
2+
//!
23
34
#[cfg(feature = "recovery")]
45
mod recovery;

src/key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ impl CPtr for KeyPair {
10781078
fn as_mut_c_ptr(&mut self) -> *mut Self::Target { &mut self.0 }
10791079
}
10801080

1081-
/// An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.
1081+
/// An x-only public key, used for verification of schnorr signatures and serialized according to BIP-340.
10821082
///
10831083
/// # Serde support
10841084
///
@@ -1165,7 +1165,7 @@ impl XOnlyPublicKey {
11651165
}
11661166
}
11671167

1168-
/// Creates a Schnorr public key directly from a slice.
1168+
/// Creates a schnorr public key directly from a slice.
11691169
///
11701170
/// # Errors
11711171
///
@@ -1472,7 +1472,7 @@ impl CPtr for XOnlyPublicKey {
14721472
fn as_mut_c_ptr(&mut self) -> *mut Self::Target { &mut self.0 }
14731473
}
14741474

1475-
/// Creates a new Schnorr public key from a FFI x-only public key.
1475+
/// Creates a new schnorr public key from a FFI x-only public key.
14761476
impl From<ffi::XOnlyPublicKey> for XOnlyPublicKey {
14771477
#[inline]
14781478
fn from(pk: ffi::XOnlyPublicKey) -> XOnlyPublicKey { XOnlyPublicKey(pk) }

src/scalar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! points. The most common type of scalars are private keys. However not all scalars are private
55
//! keys. They can even be public *values*. To make handling them safer and easier this module
66
//! provides the `Scalar` type and related.
7+
//!
78
89
use core::fmt;
910

src/schnorr.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! # schnorrsig
2-
//! Support for Schnorr signatures.
1+
//! Support for schnorr signatures.
32
//!
43
54
use core::{fmt, ptr, str};
@@ -15,7 +14,7 @@ use crate::{
1514
constants, from_hex, impl_array_newtype, Error, Message, Secp256k1, Signing, Verification,
1615
};
1716

18-
/// Represents a Schnorr signature.
17+
/// Represents a schnorr signature.
1918
#[derive(Copy, Clone)]
2019
pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]);
2120
impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE);
@@ -74,7 +73,7 @@ impl str::FromStr for Signature {
7473
}
7574

7675
impl Signature {
77-
/// Creates a Signature directly from a slice
76+
/// Creates a `Signature` directly from a slice.
7877
#[inline]
7978
pub fn from_slice(data: &[u8]) -> Result<Signature, Error> {
8079
match data.len() {
@@ -120,20 +119,20 @@ impl<C: Signing> Secp256k1<C> {
120119
}
121120
}
122121

123-
/// Create a schnorr signature internally using the ThreadRng random number
122+
/// Creates a schnorr signature internally using the [`rand::rngs::ThreadRng`] random number
124123
/// generator to generate the auxiliary random data.
125124
#[cfg(feature = "rand-std")]
126125
#[cfg_attr(docsrs, doc(cfg(feature = "rand-std")))]
127126
pub fn sign_schnorr(&self, msg: &Message, keypair: &KeyPair) -> Signature {
128127
self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng())
129128
}
130129

131-
/// Create a schnorr signature without using any auxiliary random data.
130+
/// Creates a schnorr signature without using any auxiliary random data.
132131
pub fn sign_schnorr_no_aux_rand(&self, msg: &Message, keypair: &KeyPair) -> Signature {
133132
self.sign_schnorr_helper(msg, keypair, ptr::null())
134133
}
135134

136-
/// Create a Schnorr signature using the given auxiliary random data.
135+
/// Creates a schnorr signature using the given auxiliary random data.
137136
pub fn sign_schnorr_with_aux_rand(
138137
&self,
139138
msg: &Message,
@@ -143,7 +142,7 @@ impl<C: Signing> Secp256k1<C> {
143142
self.sign_schnorr_helper(msg, keypair, aux_rand.as_c_ptr() as *const ffi::types::c_uchar)
144143
}
145144

146-
/// Create a schnorr signature using the given random number generator to
145+
/// Creates a schnorr signature using the given random number generator to
147146
/// generate the auxiliary random data.
148147
#[cfg(feature = "rand")]
149148
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
@@ -160,7 +159,7 @@ impl<C: Signing> Secp256k1<C> {
160159
}
161160

162161
impl<C: Verification> Secp256k1<C> {
163-
/// Verify a Schnorr signature.
162+
/// Verifies a schnorr signature.
164163
pub fn verify_schnorr(
165164
&self,
166165
sig: &Signature,

0 commit comments

Comments
 (0)