diff --git a/staking_deposit/key_handling/keystore.py b/staking_deposit/key_handling/keystore.py index 75bcddba..0aaaeca1 100644 --- a/staking_deposit/key_handling/keystore.py +++ b/staking_deposit/key_handling/keystore.py @@ -61,9 +61,9 @@ class KeystoreModule(BytesDataclass): @dataclass class KeystoreCrypto(BytesDataclass): - kdf: KeystoreModule = KeystoreModule() - checksum: KeystoreModule = KeystoreModule() - cipher: KeystoreModule = KeystoreModule() + kdf: KeystoreModule = dataclass_field(default_factory=KeystoreModule) + checksum: KeystoreModule = dataclass_field(default_factory=KeystoreModule) + cipher: KeystoreModule = dataclass_field(default_factory=KeystoreModule) @classmethod def from_json(cls, json_dict: Dict[Any, Any]) -> 'KeystoreCrypto': @@ -81,7 +81,7 @@ class Keystore(BytesDataclass): Ref: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2335.md """ - crypto: KeystoreCrypto = KeystoreCrypto() + crypto: KeystoreCrypto = dataclass_field(default_factory=KeystoreCrypto) description: str = '' pubkey: str = '' path: str = '' @@ -161,10 +161,9 @@ def decrypt(self, password: str) -> bytes: cipher = AES_128_CTR(key=decryption_key[:16], **self.crypto.cipher.params) return cipher.decrypt(self.crypto.cipher.message) - @dataclass class Pbkdf2Keystore(Keystore): - crypto: KeystoreCrypto = KeystoreCrypto( + crypto: KeystoreCrypto = dataclass_field(default_factory=lambda: KeystoreCrypto( kdf=KeystoreModule( function='pbkdf2', params={ @@ -179,12 +178,11 @@ class Pbkdf2Keystore(Keystore): cipher=KeystoreModule( function='aes-128-ctr', ) - ) - + )) @dataclass class ScryptKeystore(Keystore): - crypto: KeystoreCrypto = KeystoreCrypto( + crypto: KeystoreCrypto = dataclass_field(default_factory=lambda: KeystoreCrypto( kdf=KeystoreModule( function='scrypt', params={ @@ -200,4 +198,4 @@ class ScryptKeystore(Keystore): cipher=KeystoreModule( function='aes-128-ctr', ) - ) + ))