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

feat(scrypt): Add Params::n method #544

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scrypt/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,20 @@ impl Params {

/// log₂ of the Scrypt parameter `N`, the work factor.
///
/// Memory and CPU usage scale linearly with `N`.
/// Memory and CPU usage scale linearly with `N`. If you need `N`, use
/// [`Params::n`] instead.
pub const fn log_n(&self) -> u8 {
self.log_n
}

/// `N` parameter: the work factor.
///
/// This method returns 2 to the power of [`Params::log_n`]. Memory and CPU
/// usage scale linearly with `N`.
pub const fn n(&self) -> u64 {
1 << self.log_n
}

/// `r` parameter: resource usage.
///
/// scrypt iterates 2*r times. Memory and CPU time scale linearly
Expand Down
Loading