Skip to content

Commit

Permalink
Update keystore.py
Browse files Browse the repository at this point in the history
The current version doesn't work for me (relatively fresh Ubuntu 24.04 install). This fixes it.
  • Loading branch information
vbuterin authored Sep 11, 2024
1 parent fdab65d commit 8733c06
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions staking_deposit/key_handling/keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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 = ''
Expand Down Expand Up @@ -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={
Expand All @@ -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={
Expand All @@ -200,4 +198,4 @@ class ScryptKeystore(Keystore):
cipher=KeystoreModule(
function='aes-128-ctr',
)
)
))

0 comments on commit 8733c06

Please sign in to comment.