@@ -250,6 +250,7 @@ pub trait EncryptedSecretKey {
250250 // strip the prefix and create keypair
251251 Ok ( decrypted)
252252 }
253+
253254 /// Encrypts a secret key using password-based encryption.
254255 ///
255256 /// This method implements the encryption process compatible with Mina
@@ -280,10 +281,7 @@ pub trait EncryptedSecretKey {
280281 /// and nonce
281282 /// - Default Argon2i parameters: 128MB memory cost, 6 iterations
282283 /// - 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 > {
287285 let argon2 = setup_argon ( Self :: PW_DIFF ) ?;
288286
289287 // add the prefix byte to the key
@@ -310,18 +308,9 @@ pub trait EncryptedSecretKey {
310308 box_primitive : Self :: BOX_PRIMITIVE . to_string ( ) ,
311309 pw_primitive : Self :: PW_PRIMITIVE . to_string ( ) ,
312310 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 ) ,
325314 } )
326315 }
327316}
0 commit comments