Skip to content
Snippets Groups Projects
Commit ef63450c authored by Cédric Moreau's avatar Cédric Moreau
Browse files

refact: scrypt Nrp parameters

parent d6bb963c
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment