Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-mini-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cédric Moreau
duniter-mini-client
Commits
ef63450c
Commit
ef63450c
authored
3 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
refact: scrypt Nrp parameters
parent
d6bb963c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/crypto/duniter_key.rs
+4
-1
4 additions, 1 deletion
src/crypto/duniter_key.rs
with
4 additions
and
1 deletion
src/crypto/duniter_key.rs
+
4
−
1
View file @
ef63450c
...
...
@@ -10,6 +10,9 @@ use crate::crypto::duniter_signature::DuniterSignature;
const
PUBLIC_KEY_LEN
:
usize
=
32
;
const
SECRET_KEY_LEN
:
usize
=
64
;
const
SCRYPT_N
:
u8
=
12
;
const
SCRYPT_R
:
u32
=
16
;
const
SCRYPT_P
:
u32
=
1
;
/// The main functional class for handle Duniter crypto.
pub
struct
DuniterKey
{
...
...
@@ -54,7 +57,7 @@ impl DuniterKey {
fn
derive_seed
(
salt
:
&
str
,
passwd
:
&
str
)
->
Result
<
Output
,
Box
<
dyn
Error
>>
{
let
saltb64
=
base64
::
encode
(
salt
);
// convert utf8 to base64
let
salt
=
SaltString
::
new
(
saltb64
.as_str
())
?
;
// expectes base64-encoded str
let
params
=
Params
::
new
(
12
,
16
,
1
)
?
;
let
params
=
Params
::
new
(
SCRYPT_N
,
SCRYPT_R
,
SCRYPT_P
)
?
;
let
password_hash
=
Scrypt
.hash_password
(
passwd
.as_bytes
(),
None
,
params
,
&
salt
)
?
;
Ok
(
password_hash
.hash
.expect
(
"Seed should have been generated"
))
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment