diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-10 15:07:06 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-10 15:07:06 +0000 |
| commit | d127e53514ffb9ec8a07cd4d5267a6eb7fdc835b (patch) | |
| tree | cf472d70e1d9ca051eeccdc271e8f93d9fee6256 | |
| parent | ed0520e3829bedb2ed5a134538b6182df7810880 (diff) | |
automatic import of python-eth-keyfile
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-eth-keyfile.spec | 621 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 623 insertions, 0 deletions
@@ -0,0 +1 @@ +/eth-keyfile-0.6.1.tar.gz diff --git a/python-eth-keyfile.spec b/python-eth-keyfile.spec new file mode 100644 index 0000000..4ebde94 --- /dev/null +++ b/python-eth-keyfile.spec @@ -0,0 +1,621 @@ +%global _empty_manifest_terminate_build 0 +Name: python-eth-keyfile +Version: 0.6.1 +Release: 1 +Summary: A library for handling the encrypted keyfiles used to store ethereum private keys. +License: MIT +URL: https://github.com/ethereum/eth-keyfile +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/60/8e/affe6f0d1c0f02c8bbdf900cb57c5a4b97410ff341807fc3107484d2a58f/eth-keyfile-0.6.1.tar.gz +BuildArch: noarch + +Requires: python3-eth-utils +Requires: python3-eth-keys +Requires: python3-pycryptodome +Requires: python3-eth-utils +Requires: python3-eth-keys +Requires: python3-pycryptodome +Requires: python3-bumpversion +Requires: python3-wheel +Requires: python3-setuptools +Requires: python3-pluggy +Requires: python3-idna +Requires: python3-requests +Requires: python3-tox +Requires: python3-twine +Requires: python3-pytest +Requires: python3-flake8 +Requires: python3-eth-utils +Requires: python3-eth-keys +Requires: python3-pycryptodome +Requires: python3-flake8 +Requires: python3-pytest + +%description +# Ethereum Keyfile + +A library for handling the encrypted keyfiles used to store ethereum private keys + + +> This library and repository was previously located at https://github.com/pipermerriam/ethereum-keyfile. It was transferred to the Ethereum foundation github in November 2017 and renamed to `eth-keyfile`. The PyPi package was also renamed from `ethereum-keyfile` to `eth-keyfile`. + +## Installation + +```sh +pip install eth-keyfile +``` + + +## Development + +```sh +pip install -e .[dev] +``` + + +### Running the tests + +You can run the tests with: + +```sh +py.test tests +``` + +Or you can install `tox` to run the full test suite. + + +### Releasing + +Pandoc is required for transforming the markdown README to the proper format to +render correctly on pypi. + +For Debian-like systems: + +``` +apt install pandoc +``` + +Or on OSX: + +```sh +brew install pandoc +``` + +To release a new version: + +```sh +make release bump=$$VERSION_PART_TO_BUMP$$ +``` + +#### How to bumpversion + +The version format for this repo is `{major}.{minor}.{patch}` for stable, and +`{major}.{minor}.{patch}-{stage}.{devnum}` for unstable (`stage` can be alpha or beta). + +To issue the next version in line, specify which part to bump, +like `make release bump=minor` or `make release bump=devnum`. + +If you are in a beta version, `make release bump=stage` will switch to a stable. + +To issue an unstable version when the current version is stable, specify the +new version explicitly, like `make release bump="--new-version 2.0.0-alpha.1 devnum"` + + +## Documentation + +### `eth_keyfile.load_keyfile(path_or_file_obj) --> keyfile_json` + +Takes either a filesystem path represented as a string or a file object and +returns the parsed keyfile json as a python dictionary. + +```python +>>> from eth_keyfile import load_keyfile +>>> load_keyfile('path/to-my-keystore/keystore.json') +{ + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + + +### `eth_keyfile.create_keyfile_json(private_key, password, kdf="pbkdf2", work_factor=None, salt_size=16) --> keyfile_json` + +Takes the following parameters: + +* `private_key`: A bytestring of length 32 +* `password`: A bytestring which will be the password that can be used to decrypt the resulting keyfile. +* `kdf`: The key derivation function. Allowed values are `pbkdf2` and `scrypt`. By default, `pbkdf2` will be used. +* `work_factor`: The work factor which will be used for the given key derivation function. By default `1000000` will be used for `pbkdf2` and `262144` for `scrypt`. +* `salt_size`: Salt size in bytes. + +Returns the keyfile json as a python dictionary. + +```python +>>> private_key = b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +>>> create_keyfile_json(private_key, b'foo') +{ + "address" : "1a642f0e3c3af545e7acbd38b07251b3990914f1", + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + +### `eth_keyfile.decode_keyfile_json(keyfile_json, password) --> private_key` + +Takes the keyfile json as a python dictionary and the password for the keyfile, +returning the decoded private key. + +```python +>>> keyfile_json = { +... "crypto" : { +... "cipher" : "aes-128-ctr", +... "cipherparams" : { +... "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" +... }, +... "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", +... "kdf" : "pbkdf2", +... "kdfparams" : { +... "c" : 262144, +... "dklen" : 32, +... "prf" : "hmac-sha256", +... "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" +... }, +... "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" +... }, +... "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", +... "version" : 3 +... } +>>> decode_keyfile_json(keyfile_json, b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + +### `eth_keyfile.extract_key_from_keyfile(path_or_file_obj, password) --> private_key` + +Takes a filesystem path represented by a string or a file object and the +password for the keyfile. Returns the private key as a bytestring. + +```python +>>> extract_key_from_keyfile('path/to-my-keystore/keyfile.json', b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + + +%package -n python3-eth-keyfile +Summary: A library for handling the encrypted keyfiles used to store ethereum private keys. +Provides: python-eth-keyfile +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-eth-keyfile +# Ethereum Keyfile + +A library for handling the encrypted keyfiles used to store ethereum private keys + + +> This library and repository was previously located at https://github.com/pipermerriam/ethereum-keyfile. It was transferred to the Ethereum foundation github in November 2017 and renamed to `eth-keyfile`. The PyPi package was also renamed from `ethereum-keyfile` to `eth-keyfile`. + +## Installation + +```sh +pip install eth-keyfile +``` + + +## Development + +```sh +pip install -e .[dev] +``` + + +### Running the tests + +You can run the tests with: + +```sh +py.test tests +``` + +Or you can install `tox` to run the full test suite. + + +### Releasing + +Pandoc is required for transforming the markdown README to the proper format to +render correctly on pypi. + +For Debian-like systems: + +``` +apt install pandoc +``` + +Or on OSX: + +```sh +brew install pandoc +``` + +To release a new version: + +```sh +make release bump=$$VERSION_PART_TO_BUMP$$ +``` + +#### How to bumpversion + +The version format for this repo is `{major}.{minor}.{patch}` for stable, and +`{major}.{minor}.{patch}-{stage}.{devnum}` for unstable (`stage` can be alpha or beta). + +To issue the next version in line, specify which part to bump, +like `make release bump=minor` or `make release bump=devnum`. + +If you are in a beta version, `make release bump=stage` will switch to a stable. + +To issue an unstable version when the current version is stable, specify the +new version explicitly, like `make release bump="--new-version 2.0.0-alpha.1 devnum"` + + +## Documentation + +### `eth_keyfile.load_keyfile(path_or_file_obj) --> keyfile_json` + +Takes either a filesystem path represented as a string or a file object and +returns the parsed keyfile json as a python dictionary. + +```python +>>> from eth_keyfile import load_keyfile +>>> load_keyfile('path/to-my-keystore/keystore.json') +{ + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + + +### `eth_keyfile.create_keyfile_json(private_key, password, kdf="pbkdf2", work_factor=None, salt_size=16) --> keyfile_json` + +Takes the following parameters: + +* `private_key`: A bytestring of length 32 +* `password`: A bytestring which will be the password that can be used to decrypt the resulting keyfile. +* `kdf`: The key derivation function. Allowed values are `pbkdf2` and `scrypt`. By default, `pbkdf2` will be used. +* `work_factor`: The work factor which will be used for the given key derivation function. By default `1000000` will be used for `pbkdf2` and `262144` for `scrypt`. +* `salt_size`: Salt size in bytes. + +Returns the keyfile json as a python dictionary. + +```python +>>> private_key = b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +>>> create_keyfile_json(private_key, b'foo') +{ + "address" : "1a642f0e3c3af545e7acbd38b07251b3990914f1", + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + +### `eth_keyfile.decode_keyfile_json(keyfile_json, password) --> private_key` + +Takes the keyfile json as a python dictionary and the password for the keyfile, +returning the decoded private key. + +```python +>>> keyfile_json = { +... "crypto" : { +... "cipher" : "aes-128-ctr", +... "cipherparams" : { +... "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" +... }, +... "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", +... "kdf" : "pbkdf2", +... "kdfparams" : { +... "c" : 262144, +... "dklen" : 32, +... "prf" : "hmac-sha256", +... "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" +... }, +... "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" +... }, +... "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", +... "version" : 3 +... } +>>> decode_keyfile_json(keyfile_json, b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + +### `eth_keyfile.extract_key_from_keyfile(path_or_file_obj, password) --> private_key` + +Takes a filesystem path represented by a string or a file object and the +password for the keyfile. Returns the private key as a bytestring. + +```python +>>> extract_key_from_keyfile('path/to-my-keystore/keyfile.json', b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + + +%package help +Summary: Development documents and examples for eth-keyfile +Provides: python3-eth-keyfile-doc +%description help +# Ethereum Keyfile + +A library for handling the encrypted keyfiles used to store ethereum private keys + + +> This library and repository was previously located at https://github.com/pipermerriam/ethereum-keyfile. It was transferred to the Ethereum foundation github in November 2017 and renamed to `eth-keyfile`. The PyPi package was also renamed from `ethereum-keyfile` to `eth-keyfile`. + +## Installation + +```sh +pip install eth-keyfile +``` + + +## Development + +```sh +pip install -e .[dev] +``` + + +### Running the tests + +You can run the tests with: + +```sh +py.test tests +``` + +Or you can install `tox` to run the full test suite. + + +### Releasing + +Pandoc is required for transforming the markdown README to the proper format to +render correctly on pypi. + +For Debian-like systems: + +``` +apt install pandoc +``` + +Or on OSX: + +```sh +brew install pandoc +``` + +To release a new version: + +```sh +make release bump=$$VERSION_PART_TO_BUMP$$ +``` + +#### How to bumpversion + +The version format for this repo is `{major}.{minor}.{patch}` for stable, and +`{major}.{minor}.{patch}-{stage}.{devnum}` for unstable (`stage` can be alpha or beta). + +To issue the next version in line, specify which part to bump, +like `make release bump=minor` or `make release bump=devnum`. + +If you are in a beta version, `make release bump=stage` will switch to a stable. + +To issue an unstable version when the current version is stable, specify the +new version explicitly, like `make release bump="--new-version 2.0.0-alpha.1 devnum"` + + +## Documentation + +### `eth_keyfile.load_keyfile(path_or_file_obj) --> keyfile_json` + +Takes either a filesystem path represented as a string or a file object and +returns the parsed keyfile json as a python dictionary. + +```python +>>> from eth_keyfile import load_keyfile +>>> load_keyfile('path/to-my-keystore/keystore.json') +{ + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + + +### `eth_keyfile.create_keyfile_json(private_key, password, kdf="pbkdf2", work_factor=None, salt_size=16) --> keyfile_json` + +Takes the following parameters: + +* `private_key`: A bytestring of length 32 +* `password`: A bytestring which will be the password that can be used to decrypt the resulting keyfile. +* `kdf`: The key derivation function. Allowed values are `pbkdf2` and `scrypt`. By default, `pbkdf2` will be used. +* `work_factor`: The work factor which will be used for the given key derivation function. By default `1000000` will be used for `pbkdf2` and `262144` for `scrypt`. +* `salt_size`: Salt size in bytes. + +Returns the keyfile json as a python dictionary. + +```python +>>> private_key = b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +>>> create_keyfile_json(private_key, b'foo') +{ + "address" : "1a642f0e3c3af545e7acbd38b07251b3990914f1", + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" + }, + "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", + "kdf" : "pbkdf2", + "kdfparams" : { + "c" : 262144, + "dklen" : 32, + "prf" : "hmac-sha256", + "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" + }, + "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" + }, + "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", + "version" : 3 +} +``` + +### `eth_keyfile.decode_keyfile_json(keyfile_json, password) --> private_key` + +Takes the keyfile json as a python dictionary and the password for the keyfile, +returning the decoded private key. + +```python +>>> keyfile_json = { +... "crypto" : { +... "cipher" : "aes-128-ctr", +... "cipherparams" : { +... "iv" : "6087dab2f9fdbbfaddc31a909735c1e6" +... }, +... "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46", +... "kdf" : "pbkdf2", +... "kdfparams" : { +... "c" : 262144, +... "dklen" : 32, +... "prf" : "hmac-sha256", +... "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd" +... }, +... "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2" +... }, +... "id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6", +... "version" : 3 +... } +>>> decode_keyfile_json(keyfile_json, b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + +### `eth_keyfile.extract_key_from_keyfile(path_or_file_obj, password) --> private_key` + +Takes a filesystem path represented by a string or a file object and the +password for the keyfile. Returns the private key as a bytestring. + +```python +>>> extract_key_from_keyfile('path/to-my-keystore/keyfile.json', b'foo') +b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' +``` + + +%prep +%autosetup -n eth-keyfile-0.6.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-eth-keyfile -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.6.1-1 +- Package Spec generated @@ -0,0 +1 @@ +abecabcb6d6b17018339dcb648282c43 eth-keyfile-0.6.1.tar.gz |
