From 5e07e7596b3c128c2290089f87a2851946fb538d Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 18 Nov 2021 10:52:28 +1100 Subject: [PATCH] Add period to sentences Add the terminating period to all docs sentences. (Also one instance of capitialize initial character in sentence.) --- src/constants.rs | 8 ++++---- src/context.rs | 24 ++++++++++++------------ src/ecdh.rs | 2 +- src/ecdsa/recovery.rs | 19 +++++++++---------- src/key.rs | 4 ++-- src/lib.rs | 30 +++++++++++++++--------------- 6 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 668683f..5754183 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -14,7 +14,7 @@ // //! # Constants -//! Constants related to the API and the underlying curve +//! Constants related to the API and the underlying curve. /// The size (in bytes) of a message pub const MESSAGE_SIZE: usize = 32; @@ -51,7 +51,7 @@ pub const FIELD_SIZE: [u8; 32] = [ 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f ]; -/// The order of the secp256k1 curve +/// The order of the secp256k1 curve. pub const CURVE_ORDER: [u8; 32] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, @@ -59,7 +59,7 @@ pub const CURVE_ORDER: [u8; 32] = [ 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41 ]; -/// The X coordinate of the generator +/// The X coordinate of the generator. pub const GENERATOR_X: [u8; 32] = [ 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, @@ -67,7 +67,7 @@ pub const GENERATOR_X: [u8; 32] = [ 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98 ]; -/// The Y coordinate of the generator +/// The Y coordinate of the generator. pub const GENERATOR_Y: [u8; 32] = [ 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, diff --git a/src/context.rs b/src/context.rs index 15a4b20..1331f5d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -11,7 +11,7 @@ pub use self::alloc_only::*; #[cfg(all(feature = "global-context", feature = "std"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "std"))))] -/// Module implementing a singleton pattern for a global `Secp256k1` context +/// Module implementing a singleton pattern for a global `Secp256k1` context. pub mod global { #[cfg(feature = "rand-std")] use rand; @@ -20,7 +20,7 @@ pub mod global { use std::sync::Once; use {Secp256k1, All}; - /// Proxy struct for global `SECP256K1` context + /// Proxy struct for global `SECP256K1` context. #[derive(Debug, Copy, Clone)] pub struct GlobalContext { __private: (), @@ -98,8 +98,8 @@ pub struct AllPreallocated<'buf> { mod private { use super::*; // A trick to prevent users from implementing a trait. - // on one hand this trait is public, on the other it's in a private module - // so it's not visible to anyone besides it's parent (the context module) + // On one hand this trait is public, on the other it's in a private module + // so it's not visible to anyone besides it's parent (the context module). pub trait Sealed {} impl<'buf> Sealed for AllPreallocated<'buf> {} @@ -289,7 +289,7 @@ unsafe impl<'buf> Context for VerifyOnlyPreallocated<'buf> { const DESCRIPTION: &'static str = "verification only"; unsafe fn deallocate(_ptr: *mut u8, _size: usize) { - // Allocated by the user + // Allocated by the user. } } @@ -298,7 +298,7 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> { const DESCRIPTION: &'static str = "all capabilities"; unsafe fn deallocate(_ptr: *mut u8, _size: usize) { - // Allocated by the user + // Allocated by the user. } } @@ -328,7 +328,7 @@ impl<'buf> Secp256k1> { pub fn preallocated_new(buf: &'buf mut [AlignedType]) -> Result>, Error> { Secp256k1::preallocated_gen_new(buf) } - /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context + /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context. pub fn preallocate_size() -> usize { Self::preallocate_size_gen() } @@ -354,12 +354,12 @@ impl<'buf> Secp256k1> { } impl<'buf> Secp256k1> { - /// Creates a new Secp256k1 context that can only be used for signing + /// Creates a new Secp256k1 context that can only be used for signing. pub fn preallocated_signing_only(buf: &'buf mut [AlignedType]) -> Result>, Error> { Secp256k1::preallocated_gen_new(buf) } - /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context + /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context. #[inline] pub fn preallocate_signing_size() -> usize { Self::preallocate_size_gen() @@ -374,7 +374,7 @@ impl<'buf> Secp256k1> { /// * The capabilities (All/SignOnly/VerifyOnly) of the context *must* match the flags passed to libsecp256k1 /// when generating the context. /// * The user must handle the freeing of the context(using the correct functions) by himself. - /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior., + /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior. /// pub unsafe fn from_raw_signining_only(raw_ctx: *mut ffi::Context) -> ManuallyDrop>> { ManuallyDrop::new(Secp256k1 { @@ -391,7 +391,7 @@ impl<'buf> Secp256k1> { Secp256k1::preallocated_gen_new(buf) } - /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context + /// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context. #[inline] pub fn preallocate_verification_size() -> usize { Self::preallocate_size_gen() @@ -406,7 +406,7 @@ impl<'buf> Secp256k1> { /// * The capabilities (All/SignOnly/VerifyOnly) of the context *must* match the flags passed to libsecp256k1 /// when generating the context. /// * The user must handle the freeing of the context(using the correct functions) by himself. - /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior., + /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior. /// pub unsafe fn from_raw_verification_only(raw_ctx: *mut ffi::Context) -> ManuallyDrop>> { ManuallyDrop::new(Secp256k1 { diff --git a/src/ecdh.rs b/src/ecdh.rs index 30ad59e..a96d8de 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -13,7 +13,7 @@ // //! # ECDH -//! Support for shared secret computations +//! Support for shared secret computations. //! use core::ptr; diff --git a/src/ecdsa/recovery.rs b/src/ecdsa/recovery.rs index ca367de..4b1488f 100644 --- a/src/ecdsa/recovery.rs +++ b/src/ecdsa/recovery.rs @@ -25,11 +25,11 @@ use ffi::recovery as ffi; use super::*; use {Verification, Secp256k1, Signing, Message}; -/// A tag used for recovering the public key from a compact signature +/// A tag used for recovering the public key from a compact signature. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct RecoveryId(i32); -/// An ECDSA signature with a recovery ID for pubkey recovery +/// An ECDSA signature with a recovery ID for pubkey recovery. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct RecoverableSignature(ffi::RecoverableSignature); @@ -53,8 +53,7 @@ pub fn to_i32(self) -> i32 { impl RecoverableSignature { #[inline] /// Converts a compact-encoded byte slice to a signature. This - /// representation is nonstandard and defined by the libsecp256k1 - /// library. + /// representation is nonstandard and defined by the libsecp256k1 library. pub fn from_compact(data: &[u8], recid: RecoveryId) -> Result { if data.is_empty() {return Err(Error::InvalidSignature);} @@ -77,20 +76,20 @@ impl RecoverableSignature { } } - /// Obtains a raw pointer suitable for use with FFI functions + /// Obtains a raw pointer suitable for use with FFI functions. #[inline] pub fn as_ptr(&self) -> *const ffi::RecoverableSignature { &self.0 } - /// Obtains a raw mutable pointer suitable for use with FFI functions + /// Obtains a raw mutable pointer suitable for use with FFI functions. #[inline] pub fn as_mut_ptr(&mut self) -> *mut ffi::RecoverableSignature { &mut self.0 } #[inline] - /// Serializes the recoverable signature in compact format + /// Serializes the recoverable signature in compact format. pub fn serialize_compact(&self) -> (RecoveryId, [u8; 64]) { let mut ret = [0u8; 64]; let mut recid = 0i32; @@ -107,7 +106,7 @@ impl RecoverableSignature { } /// Converts a recoverable signature to a non-recoverable one (this is needed - /// for verification + /// for verification). #[inline] pub fn to_standard(&self) -> Signature { unsafe { @@ -135,7 +134,7 @@ impl CPtr for RecoverableSignature { } } -/// Creates a new recoverable signature from a FFI one +/// Creates a new recoverable signature from a FFI one. impl From for RecoverableSignature { #[inline] fn from(sig: ffi::RecoverableSignature) -> RecoverableSignature { @@ -144,7 +143,7 @@ impl From for RecoverableSignature { } impl Secp256k1 { - /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce + /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce. /// Requires a signing-capable context. #[deprecated(since = "0.21.0", note = "Use sign_ecdsa_recoverable instead.")] pub fn sign_recoverable(&self, msg: &Message, sk: &key::SecretKey) -> RecoverableSignature { diff --git a/src/key.rs b/src/key.rs index 562f02e..33bdeb2 100644 --- a/src/key.rs +++ b/src/key.rs @@ -57,7 +57,7 @@ impl str::FromStr for SecretKey { } } -/// The number 1 encoded as a secret key +/// The number 1 encoded as a secret key. pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -344,7 +344,7 @@ impl PublicKey { unsafe { let mut pk = ffi::PublicKey::new(); // We can assume the return value because it's not possible to construct - // an invalid `SecretKey` without transmute trickery or something + // an invalid `SecretKey` without transmute trickery or something. let res = ffi::secp256k1_ec_pubkey_create(secp.ctx, &mut pk, sk.as_c_ptr()); debug_assert_eq!(res, 1); PublicKey(pk) diff --git a/src/lib.rs b/src/lib.rs index c007c98..2abe90f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -205,7 +205,7 @@ pub use context::global::SECP256K1; use hashes::Hash; // Backwards compatible changes -/// Schnorr Sig related methods +/// Schnorr Signature related methods. #[deprecated(since = "0.21.0", note = "Use schnorr instead.")] pub mod schnorrsig { #[deprecated(since = "0.21.0", note = "Use crate::XOnlyPublicKey instead.")] @@ -255,7 +255,7 @@ impl ThirtyTwoByteHash for hashes::sha256t::Hash { } } -/// A (hashed) message input to an ECDSA signature +/// A (hashed) message input to an ECDSA signature. pub struct Message([u8; constants::MESSAGE_SIZE]); impl_array_newtype!(Message, u8, constants::MESSAGE_SIZE); impl_pretty_debug!(Message); @@ -302,7 +302,7 @@ impl Message { } impl From for Message { - /// Converts a 32-byte hash directly to a message without error paths + /// Converts a 32-byte hash directly to a message without error paths. fn from(t: T) -> Message { Message(t.into_32()) } @@ -314,21 +314,21 @@ pub enum Error { /// Signature failed verification IncorrectSignature, /// Badly sized message ("messages" are actually fixed-sized digests; see the `MESSAGE_SIZE` - /// constant) + /// constant). InvalidMessage, - /// Bad public key + /// Bad public key. InvalidPublicKey, - /// Bad signature + /// Bad signature. InvalidSignature, - /// Bad secret key + /// Bad secret key. InvalidSecretKey, - /// Bad recovery id + /// Bad recovery id. InvalidRecoveryId, /// Invalid tweak for add_*_assign or mul_*_assign InvalidTweak, - /// Didn't pass enough memory to context creation with preallocated memory + /// Didn't pass enough memory to context creation with preallocated memory. NotEnoughMemory, - /// Bad set of public keys + /// Bad set of public keys. InvalidPublicKeySum, /// The only valid parity values are 0 or 1. InvalidParityValue, @@ -351,7 +351,7 @@ impl Error { } } -// Passthrough Debug to Display, since errors should be user-visible +// Passthrough Debug to Display, since errors should be user-visible. impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { f.write_str(self.as_str()) @@ -363,16 +363,16 @@ impl fmt::Display for Error { impl std::error::Error for Error {} -/// The secp256k1 engine, used to execute all signature operations +/// The secp256k1 engine, used to execute all signature operations. pub struct Secp256k1 { ctx: *mut ffi::Context, phantom: PhantomData, size: usize, } -// The underlying secp context does not contain any references to memory it does not own +// The underlying secp context does not contain any references to memory it does not own. unsafe impl Send for Secp256k1 {} -// The API does not permit any mutation of `Secp256k1` objects except through `&mut` references +// The API does not permit any mutation of `Secp256k1` objects except through `&mut` references. unsafe impl Sync for Secp256k1 {} impl PartialEq for Secp256k1 { @@ -406,7 +406,7 @@ impl Secp256k1 { &self.ctx } - /// Returns the required memory for a preallocated context buffer in a generic manner(sign/verify/all) + /// Returns the required memory for a preallocated context buffer in a generic manner(sign/verify/all). pub fn preallocate_size_gen() -> usize { let word_size = mem::size_of::(); let bytes = unsafe { ffi::secp256k1_context_preallocated_size(C::FLAGS) };