Closed valar999 closed 1 year ago
May be this way would be better?
--- a/eth_keyfile/keyfile.py
+++ b/eth_keyfile/keyfile.py
@@ -128,9 +128,9 @@ def _create_v3_keyfile_json(private_key, password, kdf,
else:
raise NotImplementedError("KDF not implemented: {0}".format(kdf))
- iv = big_endian_to_int(Random.get_random_bytes(16))
+ iv = Random.get_random_bytes(16)
encrypt_key = derived_key[:16]
- ciphertext = encrypt_aes_ctr(private_key, encrypt_key, iv)
+ ciphertext = encrypt_aes_ctr(private_key, encrypt_key, big_endian_to_int(iv))
mac = keccak(derived_key[16:32] + ciphertext)
address = keys.PrivateKey(private_key).public_key.to_address()
@@ -140,7 +140,7 @@ def _create_v3_keyfile_json(private_key, password, kdf,
'crypto': {
'cipher': 'aes-128-ctr',
'cipherparams': {
- 'iv': encode_hex_no_prefix(int_to_big_endian(iv)).zfill(32),
+ 'iv': encode_hex_no_prefix(iv),
},
'ciphertext': encode_hex_no_prefix(ciphertext),
'kdf': kdf,
What was wrong?
Parity does not accept iv with hex length != 32. It throws this error:
How was it fixed?
hex_iv.zfill(32) to make iv length always correct
Cute Animal Picture
![Cute animal picture]()