From dae9de9068d74cb8f21bd4fddbd7aa722fa25ea2 Mon Sep 17 00:00:00 2001 From: "Augusto F. Hack" Date: Thu, 18 Jan 2024 15:15:12 +0100 Subject: [PATCH] docs: fix warnings --- src/dsa/rpo_falcon512/mod.rs | 4 ++-- src/dsa/rpo_falcon512/polynomial.rs | 24 ++++++++++++------------ src/dsa/rpo_falcon512/signature.rs | 4 ++-- src/merkle/delta.rs | 6 +++--- src/merkle/mmr/delta.rs | 6 +++--- src/merkle/path.rs | 4 ++-- src/rand/rpo.rs | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/dsa/rpo_falcon512/mod.rs b/src/dsa/rpo_falcon512/mod.rs index 5bbe5cf..3ccc266 100644 --- a/src/dsa/rpo_falcon512/mod.rs +++ b/src/dsa/rpo_falcon512/mod.rs @@ -39,10 +39,10 @@ const NONCE_LEN: usize = 40; const NONCE_ELEMENTS: usize = 8; /// Public key length as a u8 vector. -const PK_LEN: usize = 897; +pub const PK_LEN: usize = 897; /// Secret key length as a u8 vector. -const SK_LEN: usize = 1281; +pub const SK_LEN: usize = 1281; /// Signature length as a u8 vector. const SIG_LEN: usize = 626; diff --git a/src/dsa/rpo_falcon512/polynomial.rs b/src/dsa/rpo_falcon512/polynomial.rs index fdb9e34..1d7c586 100644 --- a/src/dsa/rpo_falcon512/polynomial.rs +++ b/src/dsa/rpo_falcon512/polynomial.rs @@ -4,7 +4,7 @@ use core::ops::{Add, Mul, Sub}; // FALCON POLYNOMIAL // ================================================================================================ -/// A polynomial over Z_p[x]/(phi) where phi := x^512 + 1 +/// A polynomial over Z_p\[x\]/(phi) where phi := x^512 + 1 #[derive(Debug, Copy, Clone, PartialEq)] pub struct Polynomial([u16; N]); @@ -24,7 +24,7 @@ impl Polynomial { Self(data) } - /// Decodes raw bytes representing a public key into a polynomial in Z_p[x]/(phi). + /// Decodes raw bytes representing a public key into a polynomial in Z_p\[x\]/(phi). /// /// # Errors /// Returns an error if: @@ -69,14 +69,14 @@ impl Polynomial { } } - /// Decodes the signature into the coefficients of a polynomial in Z_p[x]/(phi). It assumes + /// Decodes the signature into the coefficients of a polynomial in Z_p\[x\]/(phi). It assumes /// that the signature has been encoded using the uncompressed format. /// /// # Errors /// Returns an error if: /// - The signature has been encoded using a different algorithm than the reference compressed /// encoding algorithm. - /// - The encoded signature polynomial is in Z_p[x]/(phi') where phi' = x^N' + 1 and N' != 512. + /// - The encoded signature polynomial is in Z_p\[x\]/(phi') where phi' = x^N' + 1 and N' != 512. /// - While decoding the high bits of a coefficient, the current accumulated value of its /// high bits is larger than 2048. /// - The decoded coefficient is -0. @@ -149,12 +149,12 @@ impl Polynomial { // POLYNOMIAL OPERATIONS // -------------------------------------------------------------------------------------------- - /// Multiplies two polynomials over Z_p[x] without reducing modulo p. Given that the degrees + /// Multiplies two polynomials over Z_p\[x\] without reducing modulo p. Given that the degrees /// of the input polynomials are less than 512 and their coefficients are less than the modulus /// q equal to 12289, the resulting product polynomial is guaranteed to have coefficients less /// than the Miden prime. /// - /// Note that this multiplication is not over Z_p[x]/(phi). + /// Note that this multiplication is not over Z_p\[x\]/(phi). pub fn mul_modulo_p(a: &Self, b: &Self) -> [u64; 1024] { let mut c = [0; 2 * N]; for i in 0..N { @@ -166,8 +166,8 @@ impl Polynomial { c } - /// Reduces a polynomial, that is the product of two polynomials over Z_p[x], modulo - /// the irreducible polynomial phi. This results in an element in Z_p[x]/(phi). + /// Reduces a polynomial, that is the product of two polynomials over Z_p\[x\], modulo + /// the irreducible polynomial phi. This results in an element in Z_p\[x\]/(phi). pub fn reduce_negacyclic(a: &[u64; 1024]) -> Self { let mut c = [0; N]; for i in 0..N { @@ -181,7 +181,7 @@ impl Polynomial { Self(c) } - /// Computes the norm squared of a polynomial in Z_p[x]/(phi) after normalizing its + /// Computes the norm squared of a polynomial in Z_p\[x\]/(phi) after normalizing its /// coefficients to be in the interval (-p/2, p/2]. pub fn sq_norm(&self) -> u64 { let mut res = 0; @@ -203,7 +203,7 @@ impl Default for Polynomial { } } -/// Multiplication over Z_p[x]/(phi) +/// Multiplication over Z_p\[x\]/(phi) impl Mul for Polynomial { type Output = Self; @@ -227,7 +227,7 @@ impl Mul for Polynomial { } } -/// Addition over Z_p[x]/(phi) +/// Addition over Z_p\[x\]/(phi) impl Add for Polynomial { type Output = Self; @@ -239,7 +239,7 @@ impl Add for Polynomial { } } -/// Subtraction over Z_p[x]/(phi) +/// Subtraction over Z_p\[x\]/(phi) impl Sub for Polynomial { type Output = Self; diff --git a/src/dsa/rpo_falcon512/signature.rs b/src/dsa/rpo_falcon512/signature.rs index df98915..55f2f64 100644 --- a/src/dsa/rpo_falcon512/signature.rs +++ b/src/dsa/rpo_falcon512/signature.rs @@ -11,7 +11,7 @@ use core::cell::OnceCell; /// An RPO Falcon512 signature over a message. /// -/// The signature is a pair of polynomials (s1, s2) in (Z_p[x]/(phi))^2, where: +/// The signature is a pair of polynomials (s1, s2) in (Z_p\[x\]/(phi))^2, where: /// - p := 12289 /// - phi := x^512 + 1 /// - s1 = c - s2 * h @@ -86,7 +86,7 @@ impl Signature { // HASH-TO-POINT // -------------------------------------------------------------------------------------------- - /// Returns a polynomial in Z_p[x]/(phi) representing the hash of the provided message. + /// Returns a polynomial in Z_p\[x\]/(phi) representing the hash of the provided message. pub fn hash_to_point(&self, message: Word) -> Polynomial { hash_to_point(message, &self.nonce()) } diff --git a/src/merkle/delta.rs b/src/merkle/delta.rs index 064cd01..ffb57b0 100644 --- a/src/merkle/delta.rs +++ b/src/merkle/delta.rs @@ -19,7 +19,7 @@ pub struct MerkleStoreDelta(pub Vec<(RpoDigest, MerkleTreeDelta)>); // MERKLE TREE DELTA // ================================================================================================ -/// [MerkleDelta] stores the differences between the initial and final Merkle tree states. +/// [MerkleTreeDelta] stores the differences between the initial and final Merkle tree states. /// /// The differences are represented as follows: /// - depth: the depth of the merkle tree. @@ -47,7 +47,7 @@ impl MerkleTreeDelta { // ACCESSORS // -------------------------------------------------------------------------------------------- - /// Returns the depth of the Merkle tree the [MerkleDelta] is associated with. + /// Returns the depth of the Merkle tree the [MerkleTreeDelta] is associated with. pub fn depth(&self) -> u8 { self.depth } @@ -75,7 +75,7 @@ impl MerkleTreeDelta { } } -/// Extracts a [MerkleDelta] object by comparing the leaves of two Merkle trees specifies by +/// Extracts a [MerkleTreeDelta] object by comparing the leaves of two Merkle trees specifies by /// their roots and depth. pub fn merkle_tree_delta>( tree_root_1: RpoDigest, diff --git a/src/merkle/mmr/delta.rs b/src/merkle/mmr/delta.rs index 4bd9961..df4bc46 100644 --- a/src/merkle/mmr/delta.rs +++ b/src/merkle/mmr/delta.rs @@ -1,16 +1,16 @@ use super::super::{RpoDigest, Vec}; -/// Container for the update data of a [PartialMmr] +/// Container for the update data of a [super::PartialMmr] #[derive(Debug)] pub struct MmrDelta { - /// The new version of the [Mmr] + /// The new version of the [super::Mmr] pub forest: usize, /// Update data. /// /// The data is packed as follows: /// 1. All the elements needed to perform authentication path updates. These are the right - /// siblings required to perform tree merges on the [PartialMmr]. + /// siblings required to perform tree merges on the [super::PartialMmr]. /// 2. The new peaks. pub data: Vec, } diff --git a/src/merkle/path.rs b/src/merkle/path.rs index f2b12b7..37ed135 100644 --- a/src/merkle/path.rs +++ b/src/merkle/path.rs @@ -163,7 +163,7 @@ impl<'a> Iterator for InnerNodeIterator<'a> { // MERKLE PATH CONTAINERS // ================================================================================================ -/// A container for a [Word] value and its [MerklePath] opening. +/// A container for a [crate::Word] value and its [MerklePath] opening. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ValuePath { /// The node value opening for `path`. @@ -179,7 +179,7 @@ impl ValuePath { } } -/// A container for a [MerklePath] and its [Word] root. +/// A container for a [MerklePath] and its [crate::Word] root. /// /// This structure does not provide any guarantees regarding the correctness of the path to the /// root. For more information, check [MerklePath::verify]. diff --git a/src/rand/rpo.rs b/src/rand/rpo.rs index 7c7d97c..284355a 100644 --- a/src/rand/rpo.rs +++ b/src/rand/rpo.rs @@ -19,7 +19,7 @@ const HALF_RATE_WIDTH: usize = (Rpo256::RATE_RANGE.end - Rpo256::RATE_RANGE.star // RPO RANDOM COIN // ================================================================================================ /// A simplified version of the `SPONGE_PRG` reseedable pseudo-random number generator algorithm -/// described in https://eprint.iacr.org/2011/499.pdf. +/// described in . /// /// The simplification is related to the following facts: /// 1. A call to the reseed method implies one and only one call to the permutation function.