Skip to content

Commit

Permalink
Python 3.11 requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Sep 8, 2023
1 parent 33cdafe commit 6adcfa0
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 42 deletions.
65 changes: 60 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,66 @@ pyrsistent==0.16.1 \
eth-hash==0.3.2 \
--hash=sha256:3f40cecd5ead88184aa9550afc19d057f103728108c5102f592f8415949b5a76 \
--hash=sha256:de7385148a8e0237ba1240cddbc06d53f56731140f8593bdb8429306f6b42271
cytoolz==0.11.2 \
--hash=sha256:ea23663153806edddce7e4153d1d407d62357c05120a4e8485bddf1bd5ab22b4
toolz==0.11.2 \
--hash=sha256:6b312d5e15138552f1bda8a4e66c30e236c831b612b2bf0005f8a1df10a4bc33 \
--hash=sha256:a5700ce83414c64514d82d60bcda8aabfde092d1c1a8663f9200c07fdcc6da8f
cytoolz==0.12.2 \
--hash=sha256:9070ae35c410d644e6df98a8f69f3ed2807e657d0df2a26b2643127cbf6944a5 \
--hash=sha256:9007bb1290c79402be6b84bcf9e7a622a073859d61fcee146dc7bc47afe328f3 \
--hash=sha256:d29988bde28a90a00367edcf92afa1a2f7ecf43ea3ae383291b7da6d380ccc25 \
--hash=sha256:735147aa41b8eeb104da186864b55e2a6623c758000081d19c93d759cd9523e3 \
--hash=sha256:663911786dcde3e4a5d88215c722c531c7548903dc07d418418c0d1c768072c0 \
--hash=sha256:0568d4da0a9ee9f9f5ab318f6501557f1cfe26d18c96c8e0dac7332ae04c6717 \
--hash=sha256:698da4fa1f7baeea0607738cb1f9877ed1ba50342b29891b0223221679d6f729 \
--hash=sha256:df4e32badb2ccf1773e1e74020b7e3b8caf9e92f842c6be7d14888ecdefc2c6c \
--hash=sha256:c820608e7077416f766b148d75e158e454881961881b657cff808529d261dd24 \
--hash=sha256:ce7889dc3701826d519ede93cdff11940fb5567dbdc165dce0e78047eece02b7 \
--hash=sha256:c26805b6c8dc8565ed91045c44040bf6c0fe5cb5b390c78cd1d9400d08a6cd39 \
--hash=sha256:1ce324d1b413636ea5ee929f79637821f13c9e55e9588f38228947294944d2ed \
--hash=sha256:a973f5286758f76824ecf19ae1999f6697371a9121c8f163295d181d19a819d7 \
--hash=sha256:2fb740482794a72e2e5fec58e4d9b00dcd5a60a8cef68431ff12f2ba0e0d9a7e \
--hash=sha256:a08b4346350660799d81d4016e748bcb134a9083301d41f9618f64a6077f89f2 \
--hash=sha256:fa44215bc31675a6380cd896dadb7f2054a7b94cfb87e53e52af844c65406a54 \
--hash=sha256:81e6a9a8fda78a2f4901d2915b25bf620f372997ca1f20a14f7cefef5ad6f6f4 \
--hash=sha256:b41a85b9b9a2530b72b0d3d10e383fc3c2647ae88169d557d5e216f881860318 \
--hash=sha256:5556acde785a61d4cf8b8534ae109b023cbd2f9df65ee2afbe070be47c410f8c \
--hash=sha256:275d53fd769df2102d6c9fc98e553bd8a9a38926f54d6b20cf29f0dd00bf3b75 \
--hash=sha256:00547da587f124b32b072ce52dd5e4b37cf199fedcea902e33c67548523e4678 \
--hash=sha256:9b28787eaf2174e68f0acb3c66f9c6b98bdfeb0930c0d0b08e1941c7aedc8d27 \
--hash=sha256:4a7d8b869ded171f6cdf584fc2fc6ae03b30a0e1e37a9daf213a59857a62ed90 \
--hash=sha256:997b7e0960072f6bb445402da162f964ea67387b9f18bda2361edcc026e13597 \
--hash=sha256:68ae7091cc73a752f0b938f15bb193de80ca5edf5ae2ea6360d93d3e9228357b \
--hash=sha256:cde6dbb788a4cbc4a80a72aa96386ba4c2b17bdfff3ace0709799adbe16d6476 \
--hash=sha256:48425107fbb1af3f0f2410c004f16be10ffc9374358e5600b57fa543f46f8def \
--hash=sha256:96796594c770bc6587376e74ddc7d9c982d68f47116bb69d90873db5e0ea88b6 \
--hash=sha256:6a93644d7996fd696ab7f1f466cd75d718d0a00d5c8118b9fe8c64231dc1f85e \
--hash=sha256:89247ac220031a4f9f689688bcee42b38fd770d4cce294e5d914afc53b630abe \
--hash=sha256:7d352d4de060604e605abdc5c8a5d0429d5f156cb9866609065d3003454d4cea \
--hash=sha256:843500cd3e4884b92fd4037912bc42d5f047108d2c986d36352e880196d465b0 \
--hash=sha256:4bff49986c9bae127928a2f9fd6313146a342bfae8292f63e562f872bd01b871 \
--hash=sha256:5998f81bf6a2b28a802521efe14d9fc119f74b64e87b62ad1b0e7c3d8366d0c7 \
--hash=sha256:f6e86ac2b45a95f75c6f744147483e0fc9697ce7dfe1726083324c236f873f8b \
--hash=sha256:63b31345e20afda2ae30dba246955517a4264464d75e071fc2fa641e88c763ec \
--hash=sha256:a67f75cc51a2dc7229a8ac84291e4d61dc5abfc8940befcf37a2836d95873340 \
--hash=sha256:388f840fd911d61a96e9e595eaf003f9dc39e847c9060b8e623ab29e556f009b \
--hash=sha256:9bf51354e15520715f068853e6ab8190e77139940e8b8b633bdb587956a08fb0 \
--hash=sha256:5fef7b602ccf8a3c77ab483479ccd7a952a8c5bb1c263156671ba7aaa24d1035 \
--hash=sha256:478051e5ef8278b2429864c8d148efcebdc2be948a61c9a44757cd8c816c98f5 \
--hash=sha256:294d24edc747ef4e1b28e54365f713becb844e7898113fafbe3e9165dc44aeea \
--hash=sha256:45c7b4eac7571707269ebc2893facdf87e359cd5c7cfbfa9e6bd8b33fb1079c5 \
--hash=sha256:fa436abd4ac9ca71859baf5794614e6ec8fa27362f0162baedcc059048da55f7 \
--hash=sha256:14108cafb140dd68fdda610c2bbc6a37bf052cd48cfebf487ed44145f7a2b67f \
--hash=sha256:24c0d71e9ac91f4466b1bd280f7de43aa4d94682daaf34d85d867a9b479b87cc \
--hash=sha256:d0086ba8d41d73647b13087a3ca9c020f6bfec338335037e8f5172b4c7c8dce5 \
--hash=sha256:4180b2785d1278e6abb36a72ac97c92432db53fa2df00ee943d2c15a33627d31 \
--hash=sha256:9480b4b327be83c4d29cb88bcace761b11f5e30198ffe2287889455c6819e934 \
--hash=sha256:e6de6a4bdfaee382c2de2a3580b3ae76fce6105da202bbd835e5efbeae6a9c6e \
--hash=sha256:cd461e402e24929d866f05061d2f8337e3a8456e75e21b72c125abff2477c7f7 \
--hash=sha256:0a9d12436fd64937bd2c9609605f527af7f1a8db6e6637639b44121c0fe715d6 \
--hash=sha256:6c8d0dff4865da54ae825d43e1721925721b19f3b9aca8e730c2ce73dee2c630 \
--hash=sha256:101b5bd32badfc8b1f9c7be04ba3ae04fb47f9c8736590666ce9449bff76e0b1 \
--hash=sha256:960d85ebaa974ecea4e71fa56d098378fa51fd670ee744614cbb95bf95e28fc7 \
--hash=sha256:81074edf3c74bc9bd250d223408a5df0ff745d1f7a462597536cd26b9390e2d6
toolz==0.12.0 \
--hash=sha256:2059bd4148deb1884bb0eb770a3cde70e7f954cfbbdc2285f1f2de01fd21eb6f \
--hash=sha256:9007bb1290c79402be6b84bcf9e7a622a073859d61fcee146dc7bc47afe328f3
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
Expand Down
81 changes: 44 additions & 37 deletions staking_deposit/key_handling/keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from typing import Any, Dict, Union
from unicodedata import normalize
from uuid import uuid4
from functools import partial
from typing import Dict, Any

from staking_deposit.utils.crypto import (
AES_128_CTR,
Expand Down Expand Up @@ -59,11 +61,12 @@ class KeystoreModule(BytesDataclass):
message: bytes = bytes()


@dataclass
@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 +84,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 @@ -162,42 +165,46 @@ def decrypt(self, password: str) -> bytes:
return cipher.decrypt(self.crypto.cipher.message)



def create_keystore_crypto(
kdf_function: str,
kdf_params: Dict[str, Any],
checksum_function: str,
cipher_function: str
) -> KeystoreCrypto:
return KeystoreCrypto(
kdf=KeystoreModule(function=kdf_function, params=kdf_params),
checksum=KeystoreModule(function=checksum_function),
cipher=KeystoreModule(function=cipher_function)
)


@dataclass
class Pbkdf2Keystore(Keystore):
crypto: KeystoreCrypto = KeystoreCrypto(
kdf=KeystoreModule(
function='pbkdf2',
params={
'c': 2**18,
'dklen': 32,
"prf": 'hmac-sha256'
},
),
checksum=KeystoreModule(
function='sha256',
),
cipher=KeystoreModule(
function='aes-128-ctr',
)
)
crypto: KeystoreCrypto = dataclass_field(default_factory=partial(
create_keystore_crypto,
'pbkdf2',
{
'c': 2**18,
'dklen': 32,
"prf": 'hmac-sha256'
},
'sha256',
'aes-128-ctr'
))


@dataclass
class ScryptKeystore(Keystore):
crypto: KeystoreCrypto = KeystoreCrypto(
kdf=KeystoreModule(
function='scrypt',
params={
'dklen': 32,
'n': 2**18,
'r': 8,
'p': 1,
},
),
checksum=KeystoreModule(
function='sha256',
),
cipher=KeystoreModule(
function='aes-128-ctr',
)
)
crypto: KeystoreCrypto = dataclass_field(default_factory=partial(
create_keystore_crypto,
'scrypt',
{
'dklen': 32,
'n': 2**18,
'r': 8,
'p': 1,
},
'sha256',
'aes-128-ctr'
))

0 comments on commit 6adcfa0

Please sign in to comment.