Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 9 #50

Closed
wants to merge 2 commits into from
Closed

Fix/issue 9 #50

wants to merge 2 commits into from

Conversation

omibo
Copy link
Collaborator

@omibo omibo commented Feb 2, 2024

Add documentation for keccakf.rs and aux_functions.rs.
Specifically:

keccakf.rs:

  • rotate_left64() function.
  • keccakf_1600 function.

aux_functions.rs:

  • nist_800_185 module
  • byte_utils module

Comment on lines 5 to +12
/// The bytepad(X, w) function prepends an encoding of the integer w to an input string X, then pads
/// the result with zeros until it is a byte string whose length in bytes is a multiple of w.
/// * `x`: the byte string to pad
/// * `w`: the rate of the sponge
/// * `return`: z = encode(`x`) + `x` + (`0` * LCM of length of z and w)
/// the result with zeros until it is a byte string whose length in bytes is a multiple of w. See NIST SP 800-185 2.3.3 .
/// # Arguments:
/// * `input` - The byte string to pad.
/// * `w` - The rate of the sponge.
///
/// # Returns:
/// A byte string z = encode(x) + x + (0 * LCM of length of z and w)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines 22 to +29
/// The encode_string function is used to encode bit strings in a way that may be parsed
/// unambiguously from the beginning of the string.
/// * `return`: left_encode(len(`s`)) + `s`
/// unambiguously from the beginning of the string. See NIST SP 800-185 2.3.2 .
///
/// # Arguments:
/// * `s` - A reference to a vector of bytes.
///
/// # Returns:
/// A byte string representing the left-encoded length of `s` concatenated with `s`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +36 to +45
/// # Left Encode
/// Encodes the input as a vecotr of bytes in a way that can be unambiguously parsed
/// from the beginning of the string by inserting the length of the byte string before the byte string
/// representation of the input. See NIST SP 800-185 2.3.1 .
///
/// # Arguments:
/// * `value` - The 64-bit unsigned integer to encode.
///
/// # Returns:
/// A vector of bytes representing the left-encoded value.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +146 to +149
/// Returns a string representation of the current local date and time.
///
/// # Returns:
/// A string timestamp representing the current local time and date corresponding to the locale on the local machine.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although the rest of the library follows this pattern in many places, the return is actually implicit and this extra notation adds unneeded verbosity

Comment on lines +63 to +72
/// # Right Encode
/// Encodes the input as a byte string in a way that can be unambiguously parsed
/// from the end of the string by inserting the length of the byte string after the byte string
/// representation of the input. See NIST SP 800-185 2.3.1 .
///
/// # Arguments:
/// * `value` - The 64-bit unsigned integer to encode.
///
/// # Returns:
/// A vector of bytes representing the right-encoded value.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +99 to +106

/// Generates and returns a vector of random bytes of the specified size.
///
/// # Arguments:
/// * `size` - The size of the vector of random bytes to generate.
///
/// # Returns:
/// A vector of random bytes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +113 to +119
/// Generates and returns a random big integer with the specified number of bits.
///
/// # Arguments:
/// * `bits` - The number of bits for the random big integer.
///
/// # Returns:
/// A random big integer.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +130 to +140
/// Performs in-place XOR operation on two byte streams using iterators.
///
/// # Arguments:
/// * `a` - A mutable reference to a vector of bytes to be XORed and replaced with the result.
/// * `b` - An immutable reference to a vector of bytes.
///
/// # Return:
/// The result of the XOR operation is stored in the vector referenced by `a`.
///
/// # Remarks:
/// This function is a probable bottleneck unless implemented with SIMD.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

Comment on lines +1 to +9
/// # Rotate Left
/// Rotate a 64-bit unsigned integer to the left by a specified number of bits.
///
/// # Arguments:
/// * `x` - The 64-bit unsigned integer to rotate.
/// * `y` - The number of bits to rotate `x` by.
///
/// # Returns:
/// The rotated 64-bit unsigned integer.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now, particularly because its not pub.

fn rotate_left64(x: u64, y: u64) -> u64 {
// The expression ((x) >> (64 - (y))) effectively adds the y most significant bits of the input x as the least significant bits of the shifted value.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary right now

@Dustin-Ray
Copy link
Owner

Dustin-Ray commented Feb 6, 2024

thanks for the effort on this. The original objective of #9 is to find anything that is undocumented and provide documentation if it makes sense to do so. Much of this PR is modifying existing docs which isnt really needed at this time.

the area that needs the most help right now would be here, anything that is pub will be publicly exposed and should have docs explaining its usage.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be added to gitignore and should not be included with a pr

@omibo omibo closed this Feb 11, 2024
@omibo omibo deleted the fix/issue-9 branch February 11, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants