From fb583c3446730a043265d475fbdcfeaa1ff0e5de Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Tue, 10 Dec 2024 16:34:06 +0900 Subject: [PATCH 1/2] feat(scrypt): Add `Params::n` method --- scrypt/src/params.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scrypt/src/params.rs b/scrypt/src/params.rs index d957a017..74c04d08 100644 --- a/scrypt/src/params.rs +++ b/scrypt/src/params.rs @@ -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 the square 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 From 7e9044734bd98e56546a1650bdabb9a283eb5028 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 11 Dec 2024 02:49:44 +0900 Subject: [PATCH 2/2] docs(scrypt): Fix incorrect description --- scrypt/src/params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrypt/src/params.rs b/scrypt/src/params.rs index 74c04d08..449f758b 100644 --- a/scrypt/src/params.rs +++ b/scrypt/src/params.rs @@ -110,7 +110,7 @@ impl Params { /// `N` parameter: the work factor. /// - /// This method returns the square of [`Params::log_n`]. Memory and CPU + /// 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