@@ -250,6 +250,7 @@ pub trait EncryptedSecretKey {
250
250
// strip the prefix and create keypair
251
251
Ok ( decrypted)
252
252
}
253
+
253
254
/// Encrypts a secret key using password-based encryption.
254
255
///
255
256
/// This method implements the encryption process compatible with Mina
@@ -280,10 +281,7 @@ pub trait EncryptedSecretKey {
280
281
/// and nonce
281
282
/// - Default Argon2i parameters: 128MB memory cost, 6 iterations
282
283
/// - Each encryption produces unique salt and nonce for security
283
- fn try_encrypt (
284
- key : & [ u8 ] ,
285
- password : & str ,
286
- ) -> Result < EncryptedSecretKeyFile , EncryptionError > {
284
+ fn try_encrypt ( key : & [ u8 ] , password : & str ) -> Result < EncryptedSecretKeyFile , EncryptionError > {
287
285
let argon2 = setup_argon ( Self :: PW_DIFF ) ?;
288
286
289
287
// add the prefix byte to the key
@@ -310,18 +308,9 @@ pub trait EncryptedSecretKey {
310
308
box_primitive : Self :: BOX_PRIMITIVE . to_string ( ) ,
311
309
pw_primitive : Self :: PW_PRIMITIVE . to_string ( ) ,
312
310
nonce : Base58String :: new ( & nonce, Self :: ENCRYPTION_DATA_VERSION_BYTE ) ,
313
- pwsalt : Base58String :: new (
314
- salt_portion,
315
- Self :: ENCRYPTION_DATA_VERSION_BYTE ,
316
- ) ,
317
- pwdiff : (
318
- argon2. params ( ) . m_cost ( ) * 1024 ,
319
- argon2. params ( ) . t_cost ( ) ,
320
- ) ,
321
- ciphertext : Base58String :: new (
322
- & ciphertext,
323
- Self :: ENCRYPTION_DATA_VERSION_BYTE ,
324
- ) ,
311
+ pwsalt : Base58String :: new ( salt_portion, Self :: ENCRYPTION_DATA_VERSION_BYTE ) ,
312
+ pwdiff : ( argon2. params ( ) . m_cost ( ) * 1024 , argon2. params ( ) . t_cost ( ) ) ,
313
+ ciphertext : Base58String :: new ( & ciphertext, Self :: ENCRYPTION_DATA_VERSION_BYTE ) ,
325
314
} )
326
315
}
327
316
}
0 commit comments