diff --git a/coins/monero/generators/src/lib.rs b/coins/monero/generators/src/lib.rs index 05ddde56..1fc7c099 100644 --- a/coins/monero/generators/src/lib.rs +++ b/coins/monero/generators/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use std_shims::{sync::OnceLock, vec::Vec}; @@ -59,7 +60,9 @@ pub const LOG_COMMITMENT_BITS: usize = 6; // 2 ** 6 == N /// Container struct for Bulletproofs(+) generators. #[allow(non_snake_case)] pub struct Generators { + /// The G (bold) vector of generators. pub G: Vec, + /// The H (bold) vector of generators. pub H: Vec, } diff --git a/coins/monero/io/src/lib.rs b/coins/monero/io/src/lib.rs index 7c7001b7..56f3aab7 100644 --- a/coins/monero/io/src/lib.rs +++ b/coins/monero/io/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use core::fmt::Debug; diff --git a/coins/monero/primitives/src/lib.rs b/coins/monero/primitives/src/lib.rs index 1697b887..7f9ebae4 100644 --- a/coins/monero/primitives/src/lib.rs +++ b/coins/monero/primitives/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use std_shims::vec::Vec; @@ -21,31 +22,32 @@ use monero_generators::H; // On std, we cache some variables in statics. #[cfg(feature = "std")] static INV_EIGHT_CELL: OnceLock = OnceLock::new(); +/// The inverse of 8 over l. #[cfg(feature = "std")] #[allow(non_snake_case)] -/// The inverse of 8 over l. pub fn INV_EIGHT() -> Scalar { *INV_EIGHT_CELL.get_or_init(|| Scalar::from(8u8).invert()) } // In no-std environments, we prefer the reduced memory use and calculate it ad-hoc. +/// The inverse of 8 over l. #[cfg(not(feature = "std"))] #[allow(non_snake_case)] -/// The inverse of 8 over l. pub fn INV_EIGHT() -> Scalar { Scalar::from(8u8).invert() } #[cfg(feature = "std")] -static BASEPOINT_PRECOMP_CELL: OnceLock = OnceLock::new(); +static G_PRECOMP_CELL: OnceLock = OnceLock::new(); +/// A cached (if std) pre-computation of the Ed25519 generator, G. #[cfg(feature = "std")] #[allow(non_snake_case)] -pub fn BASEPOINT_PRECOMP() -> &'static VartimeEdwardsPrecomputation { - BASEPOINT_PRECOMP_CELL - .get_or_init(|| VartimeEdwardsPrecomputation::new([ED25519_BASEPOINT_POINT])) +pub fn G_PRECOMP() -> &'static VartimeEdwardsPrecomputation { + G_PRECOMP_CELL.get_or_init(|| VartimeEdwardsPrecomputation::new([ED25519_BASEPOINT_POINT])) } +/// A cached (if std) pre-computation of the Ed25519 generator, G. #[cfg(not(feature = "std"))] #[allow(non_snake_case)] -pub fn BASEPOINT_PRECOMP() -> VartimeEdwardsPrecomputation { +pub fn G_PRECOMP() -> VartimeEdwardsPrecomputation { VartimeEdwardsPrecomputation::new([ED25519_BASEPOINT_POINT]) } @@ -71,7 +73,9 @@ pub fn keccak256_to_scalar(data: impl AsRef<[u8]>) -> Scalar { #[allow(non_snake_case)] #[derive(Clone, PartialEq, Eq, Zeroize, ZeroizeOnDrop)] pub struct Commitment { + /// The mask for this commitment. pub mask: Scalar, + /// The amount committed to by this commitment. pub amount: u64, } @@ -147,12 +151,12 @@ impl Decoys { self.signer_index } - // The ring. + /// The ring. pub fn ring(&self) -> &[[EdwardsPoint; 2]] { &self.ring } - // The [key, commitment] pair of the signer. + /// The [key, commitment] pair of the signer. pub fn signer_ring_members(&self) -> [EdwardsPoint; 2] { self.ring[usize::from(self.signer_index)] } diff --git a/coins/monero/ringct/bulletproofs/src/lib.rs b/coins/monero/ringct/bulletproofs/src/lib.rs index 28932578..5881efa8 100644 --- a/coins/monero/ringct/bulletproofs/src/lib.rs +++ b/coins/monero/ringct/bulletproofs/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(non_snake_case)] @@ -53,7 +54,9 @@ pub enum BulletproofError { #[allow(clippy::large_enum_variant)] #[derive(Clone, PartialEq, Eq, Debug)] pub enum Bulletproof { + /// A Bulletproof. Original(OriginalStruct), + /// A Bulletproof+. Plus(AggregateRangeProof), } diff --git a/coins/monero/ringct/clsag/src/lib.rs b/coins/monero/ringct/clsag/src/lib.rs index fbd3a42c..fd6ae488 100644 --- a/coins/monero/ringct/clsag/src/lib.rs +++ b/coins/monero/ringct/clsag/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(non_snake_case)] @@ -24,7 +25,7 @@ use curve25519_dalek::{ use monero_io::*; use monero_generators::hash_to_point; -use monero_primitives::{INV_EIGHT, BASEPOINT_PRECOMP, Commitment, Decoys, keccak256_to_scalar}; +use monero_primitives::{INV_EIGHT, G_PRECOMP, Commitment, Decoys, keccak256_to_scalar}; #[cfg(feature = "multisig")] mod multisig; @@ -189,7 +190,7 @@ fn core( EdwardsPoint::multiscalar_mul([s[i], c_p, c_c], [ED25519_BASEPOINT_POINT, P[i], C[i]]) } Mode::Verify(..) => { - BASEPOINT_PRECOMP().vartime_mixed_multiscalar_mul([s[i]], [c_p, c_c], [P[i], C[i]]) + G_PRECOMP().vartime_mixed_multiscalar_mul([s[i]], [c_p, c_c], [P[i], C[i]]) } }; diff --git a/coins/monero/src/ringct/mlsag.rs b/coins/monero/ringct/mlsag/src/lib.rs similarity index 100% rename from coins/monero/src/ringct/mlsag.rs rename to coins/monero/ringct/mlsag/src/lib.rs