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

implementation of md6 in pure rust #636

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

truthixify
Copy link

implementation of md6 in pure rust.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

We can not merge this implementation in such state.

Please, do not disable the Clippy lints, follow the trait API defined in the digest crate, keep the crate no_std-capable (i.e. your code should not have any Vecs), add a CI workflow config for this crate (you can use the md5 file for reference), add the crate to the workspace by modifying the root Cargo.toml file, and remove the md6/.gitignore file.

Our trait APIs are a bit complex (and not documented that well), so I recommend taking a look at other crates in this repository first.

@truthixify
Copy link
Author

@newpavlov
I don't know why this is failing: sha2 / riscv64-zknh (pull_request)

@newpavlov
Copy link
Member

The CI failure is fixed in #637, so you need to rebase to master.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

Thank you! I have some surface-level comments for now. I will take a closer look at the algorithm implementation later.

md6/Cargo.toml Outdated
rust-version = "1.81"

[lib]
name = "md6"
Copy link
Member

Choose a reason for hiding this comment

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

These two lines are not needed.

md6/Cargo.toml Outdated

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
Copy link
Member

Choose a reason for hiding this comment

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

docsrs flag is passed by default during docs.rs builds and no longer needed. I will remove it from other crates in a separate PR.

@@ -0,0 +1,194 @@
use crate::consts::*;

const W: usize = MD6_W; // number of bits in a word (64)
Copy link
Member

Choose a reason for hiding this comment

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

You can simply rename these constants in the consts module.

const V: usize = MD6_V; // words for control word (0 or 64/w)
const B: usize = MD6_B; // data words per compression block (> 0) (64)

const T0: usize = 17; // index for linear feedback
Copy link
Member

Choose a reason for hiding this comment

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

I think it's worth to move these constants to the consts module.

pub(crate) type Md6ControlWord = u64;
pub(crate) type Md6NodeID = u64;

pub(crate) const MD6_MAX_STACK_HEIGHT: usize = 29; // maximum stack height
Copy link
Member

Choose a reason for hiding this comment

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

Please use docstrings for constant descriptions, i.e.:

/// Maximum stack height
pub(crate) const MD6_MAX_STACK_HEIGHT: usize = 29;

pub(crate) const MD6_N: usize = 89; // size of compression input block in words

/// These five values give lengths of the components of compression
/// input block; they should sum to MD6_N.
Copy link
Member

Choose a reason for hiding this comment

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

It's not a docstring comment. Use // instead to comment on a block of constants.

@@ -0,0 +1,21 @@
/// MD6 constants related to standard mode of operation

pub(crate) type Md6Word = u64;
Copy link
Member

Choose a reason for hiding this comment

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

You may just use pub for items in this module since you use pub(crate) mod consts; in lib.rs.

md6/tests/mod.rs Outdated
@@ -0,0 +1,363 @@
#![no_std]
Copy link
Member

Choose a reason for hiding this comment

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

#![no_std] is not needed in tests since tests rely on std by default.

Could you also provide a provenance link for these test vectors?

md6/src/md6.rs Outdated
impl Md6VarCore {
#[inline]
fn init(d: usize) -> Self {
//
Copy link
Member

@newpavlov newpavlov Jan 3, 2025

Choose a reason for hiding this comment

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

Remove this empty comment line?

Copy link
Author

Choose a reason for hiding this comment

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

Ok sir

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