From 05da4603fb8155f89fc24dcebf880938a0394e85 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 16 Aug 2020 02:31:31 -0400 Subject: freeze the dependencies --- README.rst | 6 +- .../_pysha3.cpython-38-x86_64-linux-gnu.so | Bin 0 -> 517664 bytes freezed_deps/base58-2.0.1.dist-info/COPYING | 19 + freezed_deps/base58-2.0.1.dist-info/INSTALLER | 1 + freezed_deps/base58-2.0.1.dist-info/METADATA | 20 + freezed_deps/base58-2.0.1.dist-info/RECORD | 13 + freezed_deps/base58-2.0.1.dist-info/WHEEL | 5 + .../base58-2.0.1.dist-info/entry_points.txt | 3 + freezed_deps/base58-2.0.1.dist-info/top_level.txt | 1 + freezed_deps/base58/__init__.py | 130 ++ freezed_deps/base58/__main__.py | 47 + freezed_deps/base58/py.typed | 1 + freezed_deps/bech32.py | 123 ++ freezed_deps/bin/base58 | 8 + freezed_deps/bin/keytree.py | 238 +++ freezed_deps/ecdsa-0.15.dist-info/INSTALLER | 1 + freezed_deps/ecdsa-0.15.dist-info/LICENSE | 24 + freezed_deps/ecdsa-0.15.dist-info/METADATA | 625 ++++++ freezed_deps/ecdsa-0.15.dist-info/RECORD | 52 + freezed_deps/ecdsa-0.15.dist-info/WHEEL | 6 + freezed_deps/ecdsa-0.15.dist-info/top_level.txt | 1 + freezed_deps/ecdsa/__init__.py | 25 + freezed_deps/ecdsa/_compat.py | 39 + freezed_deps/ecdsa/_rwlock.py | 85 + freezed_deps/ecdsa/_version.py | 21 + freezed_deps/ecdsa/curves.py | 128 ++ freezed_deps/ecdsa/der.py | 384 ++++ freezed_deps/ecdsa/ecdh.py | 306 +++ freezed_deps/ecdsa/ecdsa.py | 446 +++++ freezed_deps/ecdsa/ellipticcurve.py | 780 ++++++++ freezed_deps/ecdsa/keys.py | 1219 ++++++++++++ freezed_deps/ecdsa/numbertheory.py | 600 ++++++ freezed_deps/ecdsa/rfc6979.py | 107 + freezed_deps/ecdsa/test_der.py | 384 ++++ freezed_deps/ecdsa/test_ecdh.py | 350 ++++ freezed_deps/ecdsa/test_ecdsa.py | 448 +++++ freezed_deps/ecdsa/test_ellipticcurve.py | 188 ++ freezed_deps/ecdsa/test_jacobi.py | 365 ++++ freezed_deps/ecdsa/test_keys.py | 373 ++++ freezed_deps/ecdsa/test_malformed_sigs.py | 306 +++ freezed_deps/ecdsa/test_numbertheory.py | 275 +++ freezed_deps/ecdsa/test_pyecdsa.py | 1445 ++++++++++++++ freezed_deps/ecdsa/test_rw_lock.py | 175 ++ freezed_deps/ecdsa/util.py | 401 ++++ freezed_deps/keytree.py-0.2.dist-info/INSTALLER | 1 + freezed_deps/keytree.py-0.2.dist-info/METADATA | 17 + freezed_deps/keytree.py-0.2.dist-info/RECORD | 10 + freezed_deps/keytree.py-0.2.dist-info/WHEEL | 5 + .../keytree.py-0.2.dist-info/direct_url.json | 1 + .../keytree.py-0.2.dist-info/top_level.txt | 1 + freezed_deps/mnemonic-0.19.dist-info/AUTHORS | 2 + freezed_deps/mnemonic-0.19.dist-info/INSTALLER | 1 + freezed_deps/mnemonic-0.19.dist-info/LICENSE | 21 + freezed_deps/mnemonic-0.19.dist-info/METADATA | 42 + freezed_deps/mnemonic-0.19.dist-info/RECORD | 19 + freezed_deps/mnemonic-0.19.dist-info/WHEEL | 6 + freezed_deps/mnemonic-0.19.dist-info/top_level.txt | 1 + freezed_deps/mnemonic/__init__.py | 1 + freezed_deps/mnemonic/mnemonic.py | 291 +++ .../mnemonic/wordlist/chinese_simplified.txt | 2048 ++++++++++++++++++++ .../mnemonic/wordlist/chinese_traditional.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/english.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/french.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/italian.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/japanese.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/korean.txt | 2048 ++++++++++++++++++++ freezed_deps/mnemonic/wordlist/spanish.txt | 2048 ++++++++++++++++++++ freezed_deps/pysha3-1.0.2.dist-info/INSTALLER | 1 + freezed_deps/pysha3-1.0.2.dist-info/LICENSE | 49 + freezed_deps/pysha3-1.0.2.dist-info/METADATA | 251 +++ freezed_deps/pysha3-1.0.2.dist-info/RECORD | 9 + freezed_deps/pysha3-1.0.2.dist-info/WHEEL | 5 + freezed_deps/pysha3-1.0.2.dist-info/top_level.txt | 2 + freezed_deps/sha3.py | 24 + freezed_deps/six-1.15.0.dist-info/INSTALLER | 1 + freezed_deps/six-1.15.0.dist-info/LICENSE | 18 + freezed_deps/six-1.15.0.dist-info/METADATA | 49 + freezed_deps/six-1.15.0.dist-info/RECORD | 8 + freezed_deps/six-1.15.0.dist-info/WHEEL | 6 + freezed_deps/six-1.15.0.dist-info/top_level.txt | 1 + freezed_deps/six.py | 982 ++++++++++ keytree.py | 4 + 82 files changed, 28384 insertions(+), 3 deletions(-) create mode 100755 freezed_deps/_pysha3.cpython-38-x86_64-linux-gnu.so create mode 100644 freezed_deps/base58-2.0.1.dist-info/COPYING create mode 100644 freezed_deps/base58-2.0.1.dist-info/INSTALLER create mode 100644 freezed_deps/base58-2.0.1.dist-info/METADATA create mode 100644 freezed_deps/base58-2.0.1.dist-info/RECORD create mode 100644 freezed_deps/base58-2.0.1.dist-info/WHEEL create mode 100644 freezed_deps/base58-2.0.1.dist-info/entry_points.txt create mode 100644 freezed_deps/base58-2.0.1.dist-info/top_level.txt create mode 100644 freezed_deps/base58/__init__.py create mode 100644 freezed_deps/base58/__main__.py create mode 100644 freezed_deps/base58/py.typed create mode 100644 freezed_deps/bech32.py create mode 100755 freezed_deps/bin/base58 create mode 100755 freezed_deps/bin/keytree.py create mode 100644 freezed_deps/ecdsa-0.15.dist-info/INSTALLER create mode 100644 freezed_deps/ecdsa-0.15.dist-info/LICENSE create mode 100644 freezed_deps/ecdsa-0.15.dist-info/METADATA create mode 100644 freezed_deps/ecdsa-0.15.dist-info/RECORD create mode 100644 freezed_deps/ecdsa-0.15.dist-info/WHEEL create mode 100644 freezed_deps/ecdsa-0.15.dist-info/top_level.txt create mode 100644 freezed_deps/ecdsa/__init__.py create mode 100644 freezed_deps/ecdsa/_compat.py create mode 100644 freezed_deps/ecdsa/_rwlock.py create mode 100644 freezed_deps/ecdsa/_version.py create mode 100644 freezed_deps/ecdsa/curves.py create mode 100644 freezed_deps/ecdsa/der.py create mode 100644 freezed_deps/ecdsa/ecdh.py create mode 100644 freezed_deps/ecdsa/ecdsa.py create mode 100644 freezed_deps/ecdsa/ellipticcurve.py create mode 100644 freezed_deps/ecdsa/keys.py create mode 100644 freezed_deps/ecdsa/numbertheory.py create mode 100644 freezed_deps/ecdsa/rfc6979.py create mode 100644 freezed_deps/ecdsa/test_der.py create mode 100644 freezed_deps/ecdsa/test_ecdh.py create mode 100644 freezed_deps/ecdsa/test_ecdsa.py create mode 100644 freezed_deps/ecdsa/test_ellipticcurve.py create mode 100644 freezed_deps/ecdsa/test_jacobi.py create mode 100644 freezed_deps/ecdsa/test_keys.py create mode 100644 freezed_deps/ecdsa/test_malformed_sigs.py create mode 100644 freezed_deps/ecdsa/test_numbertheory.py create mode 100644 freezed_deps/ecdsa/test_pyecdsa.py create mode 100644 freezed_deps/ecdsa/test_rw_lock.py create mode 100644 freezed_deps/ecdsa/util.py create mode 100644 freezed_deps/keytree.py-0.2.dist-info/INSTALLER create mode 100644 freezed_deps/keytree.py-0.2.dist-info/METADATA create mode 100644 freezed_deps/keytree.py-0.2.dist-info/RECORD create mode 100644 freezed_deps/keytree.py-0.2.dist-info/WHEEL create mode 100644 freezed_deps/keytree.py-0.2.dist-info/direct_url.json create mode 100644 freezed_deps/keytree.py-0.2.dist-info/top_level.txt create mode 100644 freezed_deps/mnemonic-0.19.dist-info/AUTHORS create mode 100644 freezed_deps/mnemonic-0.19.dist-info/INSTALLER create mode 100644 freezed_deps/mnemonic-0.19.dist-info/LICENSE create mode 100644 freezed_deps/mnemonic-0.19.dist-info/METADATA create mode 100644 freezed_deps/mnemonic-0.19.dist-info/RECORD create mode 100644 freezed_deps/mnemonic-0.19.dist-info/WHEEL create mode 100644 freezed_deps/mnemonic-0.19.dist-info/top_level.txt create mode 100644 freezed_deps/mnemonic/__init__.py create mode 100644 freezed_deps/mnemonic/mnemonic.py create mode 100644 freezed_deps/mnemonic/wordlist/chinese_simplified.txt create mode 100644 freezed_deps/mnemonic/wordlist/chinese_traditional.txt create mode 100644 freezed_deps/mnemonic/wordlist/english.txt create mode 100644 freezed_deps/mnemonic/wordlist/french.txt create mode 100644 freezed_deps/mnemonic/wordlist/italian.txt create mode 100644 freezed_deps/mnemonic/wordlist/japanese.txt create mode 100644 freezed_deps/mnemonic/wordlist/korean.txt create mode 100644 freezed_deps/mnemonic/wordlist/spanish.txt create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/INSTALLER create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/LICENSE create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/METADATA create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/RECORD create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/WHEEL create mode 100644 freezed_deps/pysha3-1.0.2.dist-info/top_level.txt create mode 100644 freezed_deps/sha3.py create mode 100644 freezed_deps/six-1.15.0.dist-info/INSTALLER create mode 100644 freezed_deps/six-1.15.0.dist-info/LICENSE create mode 100644 freezed_deps/six-1.15.0.dist-info/METADATA create mode 100644 freezed_deps/six-1.15.0.dist-info/RECORD create mode 100644 freezed_deps/six-1.15.0.dist-info/WHEEL create mode 100644 freezed_deps/six-1.15.0.dist-info/top_level.txt create mode 100644 freezed_deps/six.py diff --git a/README.rst b/README.rst index 7dfd2c1..d2fa02b 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,6 @@ keytree ======= - CD into the cloned repo -- Install the deps: ``pip3 --user install .`` -- Derive 10 keys from the given mnemonic: ``keytree.py --end-idx 10`` -- Generate a new mnemonic and derive 10 keys from it: ``keytree.py --end-idx 10 --gen-mnemonic`` +- Derive 10 keys from the given mnemonic: ``./keytree.py --end-idx 10`` +- Generate a new mnemonic and derive 10 keys from it: ``./keytree.py --end-idx 10 --gen-mnemonic`` +- Caveat: if you instead do a normal pip install and use ``keytree.py``, it will use the latest deps fetched by pip. diff --git a/freezed_deps/_pysha3.cpython-38-x86_64-linux-gnu.so b/freezed_deps/_pysha3.cpython-38-x86_64-linux-gnu.so new file mode 100755 index 0000000..0d09638 Binary files /dev/null and b/freezed_deps/_pysha3.cpython-38-x86_64-linux-gnu.so differ diff --git a/freezed_deps/base58-2.0.1.dist-info/COPYING b/freezed_deps/base58-2.0.1.dist-info/COPYING new file mode 100644 index 0000000..342bd62 --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/COPYING @@ -0,0 +1,19 @@ +Copyright (c) 2015 David Keijser + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/freezed_deps/base58-2.0.1.dist-info/INSTALLER b/freezed_deps/base58-2.0.1.dist-info/INSTALLER new file mode 100644 index 0000000..a1b589e --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/freezed_deps/base58-2.0.1.dist-info/METADATA b/freezed_deps/base58-2.0.1.dist-info/METADATA new file mode 100644 index 0000000..22a37ad --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/METADATA @@ -0,0 +1,20 @@ +Metadata-Version: 2.1 +Name: base58 +Version: 2.0.1 +Summary: Base58 and Base58Check implementation +Home-page: https://github.com/keis/base58 +Author: David Keijser +Author-email: keijser@gmail.com +License: MIT +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Natural Language :: English +Classifier: License :: OSI Approved :: MIT License +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 3 +Requires-Python: >=3.5 + +UNKNOWN + + diff --git a/freezed_deps/base58-2.0.1.dist-info/RECORD b/freezed_deps/base58-2.0.1.dist-info/RECORD new file mode 100644 index 0000000..d20c1c2 --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/RECORD @@ -0,0 +1,13 @@ +../../bin/base58,sha256=WWCKVkDRfe64OQtfsxf-b0PQGIclDIn84xO8gkjjWcY,213 +base58-2.0.1.dist-info/COPYING,sha256=z0aU8EC3oxzY7D280LWDpgHA1MN94Ba-eqCgbjpqOlQ,1057 +base58-2.0.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +base58-2.0.1.dist-info/METADATA,sha256=r4yScmUS3A8Yx7mmsSyaqfMSINg6FAIQK2ocWJO1tJw,540 +base58-2.0.1.dist-info/RECORD,, +base58-2.0.1.dist-info/WHEEL,sha256=p46_5Uhzqz6AzeSosiOnxK-zmFja1i22CrQCjmYe8ec,92 +base58-2.0.1.dist-info/entry_points.txt,sha256=7WwcggBSeBwcC22-LkpqMOCaPdey0nOG3QEaKok403Y,49 +base58-2.0.1.dist-info/top_level.txt,sha256=BVSonMPECDcX_2XqQ7iILRqitlshZNNEmLCEWlpvUvI,7 +base58/__init__.py,sha256=ccX9CZMek4UC0edA_cHs71MgC4YqJCPBhvycuzhbucc,3085 +base58/__main__.py,sha256=OiE3DXq4vwYyAVYC3SM9Y0AQbMuS2IA0v2mvzwv96pk,1080 +base58/__pycache__/__init__.cpython-38.pyc,, +base58/__pycache__/__main__.cpython-38.pyc,, +base58/py.typed,sha256=dcrsqJrcYfTX-ckLFJMTaj6mD8aDe2u0tkQG-ZYxnEg,26 diff --git a/freezed_deps/base58-2.0.1.dist-info/WHEEL b/freezed_deps/base58-2.0.1.dist-info/WHEEL new file mode 100644 index 0000000..3b5c403 --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/WHEEL @@ -0,0 +1,5 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.33.6) +Root-Is-Purelib: true +Tag: py3-none-any + diff --git a/freezed_deps/base58-2.0.1.dist-info/entry_points.txt b/freezed_deps/base58-2.0.1.dist-info/entry_points.txt new file mode 100644 index 0000000..dc6d6a2 --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +base58 = base58.__main__:main + diff --git a/freezed_deps/base58-2.0.1.dist-info/top_level.txt b/freezed_deps/base58-2.0.1.dist-info/top_level.txt new file mode 100644 index 0000000..b4c9d71 --- /dev/null +++ b/freezed_deps/base58-2.0.1.dist-info/top_level.txt @@ -0,0 +1 @@ +base58 diff --git a/freezed_deps/base58/__init__.py b/freezed_deps/base58/__init__.py new file mode 100644 index 0000000..ff2fa18 --- /dev/null +++ b/freezed_deps/base58/__init__.py @@ -0,0 +1,130 @@ +'''Base58 encoding + +Implementations of Base58 and Base58Check encodings that are compatible +with the bitcoin network. +''' + +# This module is based upon base58 snippets found scattered over many bitcoin +# tools written in python. From what I gather the original source is from a +# forum post by Gavin Andresen, so direct your praise to him. +# This module adds shiny packaging and support for python3. + +from hashlib import sha256 +from typing import Union + +__version__ = '2.0.1' + +# 58 character alphabet used +BITCOIN_ALPHABET = \ + b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' +RIPPLE_ALPHABET = b'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz' + +# Retro compatibility +alphabet = BITCOIN_ALPHABET + + +def scrub_input(v: Union[str, bytes]) -> bytes: + if isinstance(v, str): + v = v.encode('ascii') + + return v + + +def b58encode_int( + i: int, default_one: bool = True, alphabet: bytes = BITCOIN_ALPHABET +) -> bytes: + """ + Encode an integer using Base58 + """ + if not i and default_one: + return alphabet[0:1] + string = b"" + while i: + i, idx = divmod(i, 58) + string = alphabet[idx:idx+1] + string + return string + + +def b58encode( + v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET +) -> bytes: + """ + Encode a string using Base58 + """ + v = scrub_input(v) + + nPad = len(v) + v = v.lstrip(b'\0') + nPad -= len(v) + + p, acc = 1, 0 + for c in reversed(v): + acc += p * c + p = p << 8 + result = b58encode_int(acc, default_one=False, alphabet=alphabet) + return alphabet[0:1] * nPad + result + + +def b58decode_int( + v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET +) -> int: + """ + Decode a Base58 encoded string as an integer + """ + v = v.rstrip() + v = scrub_input(v) + + decimal = 0 + for char in v: + decimal = decimal * 58 + alphabet.index(char) + return decimal + + +def b58decode( + v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET +) -> bytes: + """ + Decode a Base58 encoded string + """ + v = v.rstrip() + v = scrub_input(v) + + origlen = len(v) + v = v.lstrip(alphabet[0:1]) + newlen = len(v) + + acc = b58decode_int(v, alphabet=alphabet) + + result = [] + while acc > 0: + acc, mod = divmod(acc, 256) + result.append(mod) + + return b'\0' * (origlen - newlen) + bytes(reversed(result)) + + +def b58encode_check( + v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET +) -> bytes: + """ + Encode a string using Base58 with a 4 character checksum + """ + v = scrub_input(v) + + digest = sha256(sha256(v).digest()).digest() + return b58encode(v + digest[:4], alphabet=alphabet) + + +def b58decode_check( + v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET +) -> bytes: + '''Decode and verify the checksum of a Base58 encoded string''' + + result = b58decode(v, alphabet=alphabet) + result, check = result[:-4], result[-4:] + digest = sha256(sha256(result).digest()).digest() + + if check != digest[:4]: + raise ValueError("Invalid checksum") + + return result diff --git a/freezed_deps/base58/__main__.py b/freezed_deps/base58/__main__.py new file mode 100644 index 0000000..b76fdad --- /dev/null +++ b/freezed_deps/base58/__main__.py @@ -0,0 +1,47 @@ +import argparse +import sys + +from base58 import b58decode, b58decode_check, b58encode, b58encode_check + + +def main(): + '''Base58 encode or decode FILE, or standard input, to standard output.''' + + stdout = sys.stdout.buffer + + parser = argparse.ArgumentParser(description=main.__doc__) + parser.add_argument( + 'file', + metavar='FILE', + nargs='?', + type=argparse.FileType('r'), + default='-') + parser.add_argument( + '-d', '--decode', + action='store_true', + help='decode data') + parser.add_argument( + '-c', '--check', + action='store_true', + help='append a checksum before encoding') + + args = parser.parse_args() + fun = { + (False, False): b58encode, + (False, True): b58encode_check, + (True, False): b58decode, + (True, True): b58decode_check + }[(args.decode, args.check)] + + data = args.file.buffer.read() + + try: + result = fun(data) + except Exception as e: + sys.exit(e) + + stdout.write(result) + + +if __name__ == '__main__': + main() diff --git a/freezed_deps/base58/py.typed b/freezed_deps/base58/py.typed new file mode 100644 index 0000000..e5aff4f --- /dev/null +++ b/freezed_deps/base58/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/freezed_deps/bech32.py b/freezed_deps/bech32.py new file mode 100644 index 0000000..d450080 --- /dev/null +++ b/freezed_deps/bech32.py @@ -0,0 +1,123 @@ +# Copyright (c) 2017 Pieter Wuille +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Reference implementation for Bech32 and segwit addresses.""" + + +CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" + + +def bech32_polymod(values): + """Internal function that computes the Bech32 checksum.""" + generator = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3] + chk = 1 + for value in values: + top = chk >> 25 + chk = (chk & 0x1ffffff) << 5 ^ value + for i in range(5): + chk ^= generator[i] if ((top >> i) & 1) else 0 + return chk + + +def bech32_hrp_expand(hrp): + """Expand the HRP into values for checksum computation.""" + return [ord(x) >> 5 for x in hrp] + [0] + [ord(x) & 31 for x in hrp] + + +def bech32_verify_checksum(hrp, data): + """Verify a checksum given HRP and converted data characters.""" + return bech32_polymod(bech32_hrp_expand(hrp) + data) == 1 + + +def bech32_create_checksum(hrp, data): + """Compute the checksum values given HRP and data.""" + values = bech32_hrp_expand(hrp) + data + polymod = bech32_polymod(values + [0, 0, 0, 0, 0, 0]) ^ 1 + return [(polymod >> 5 * (5 - i)) & 31 for i in range(6)] + + +def bech32_encode(hrp, data): + """Compute a Bech32 string given HRP and data values.""" + combined = data + bech32_create_checksum(hrp, data) + return hrp + '1' + ''.join([CHARSET[d] for d in combined]) + + +def bech32_decode(bech): + """Validate a Bech32 string, and determine HRP and data.""" + if ((any(ord(x) < 33 or ord(x) > 126 for x in bech)) or + (bech.lower() != bech and bech.upper() != bech)): + return (None, None) + bech = bech.lower() + pos = bech.rfind('1') + if pos < 1 or pos + 7 > len(bech) or len(bech) > 90: + return (None, None) + if not all(x in CHARSET for x in bech[pos+1:]): + return (None, None) + hrp = bech[:pos] + data = [CHARSET.find(x) for x in bech[pos+1:]] + if not bech32_verify_checksum(hrp, data): + return (None, None) + return (hrp, data[:-6]) + + +def convertbits(data, frombits, tobits, pad=True): + """General power-of-2 base conversion.""" + acc = 0 + bits = 0 + ret = [] + maxv = (1 << tobits) - 1 + max_acc = (1 << (frombits + tobits - 1)) - 1 + for value in data: + if value < 0 or (value >> frombits): + return None + acc = ((acc << frombits) | value) & max_acc + bits += frombits + while bits >= tobits: + bits -= tobits + ret.append((acc >> bits) & maxv) + if pad: + if bits: + ret.append((acc << (tobits - bits)) & maxv) + elif bits >= frombits or ((acc << (tobits - bits)) & maxv): + return None + return ret + + +def decode(hrp, addr): + """Decode a segwit address.""" + hrpgot, data = bech32_decode(addr) + if hrpgot != hrp: + return (None, None) + decoded = convertbits(data[1:], 5, 8, False) + if decoded is None or len(decoded) < 2 or len(decoded) > 40: + return (None, None) + if data[0] > 16: + return (None, None) + if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32: + return (None, None) + return (data[0], decoded) + + +def encode(hrp, witver, witprog): + """Encode a segwit address.""" + ret = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5)) + if decode(hrp, ret) == (None, None): + return None + return ret diff --git a/freezed_deps/bin/base58 b/freezed_deps/bin/base58 new file mode 100755 index 0000000..1e291f0 --- /dev/null +++ b/freezed_deps/bin/base58 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from base58.__main__ import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/freezed_deps/bin/keytree.py b/freezed_deps/bin/keytree.py new file mode 100755 index 0000000..41650c5 --- /dev/null +++ b/freezed_deps/bin/keytree.py @@ -0,0 +1,238 @@ +#!/usr/bin/python +# MIT License +# +# Copyright (c) 2020 Ted Yin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# +# This little script offers decryption and verification of the existing +# Ethereum wallets, as well as generation of a new wallet. You can use any +# utf-8 string as the password, which could provide with better security +# against the brute-force attack. + +# Use at your own risk. +# +# Example: +# python ./keytree.py + +import sys +import argparse +import hashlib +import hmac +import unicodedata +import bech32 +from getpass import getpass +from ecdsa import SigningKey, VerifyingKey, SECP256k1 +from ecdsa.ecdsa import generator_secp256k1 +from ecdsa.ellipticcurve import INFINITY +from base58 import b58encode +from sha3 import keccak_256 +import re +import mnemonic + +err = sys.stderr + + +def sha256(data): + h = hashlib.sha256() + h.update(data) + return h.digest() + + +def ripemd160(data): + h = hashlib.new('ripemd160') + h.update(data) + return h.digest() + + +class BIP32Error(Exception): + pass + + +# point(p): returns the coordinate pair resulting from EC point multiplication +# (repeated application of the EC group operation) of the secp256k1 base point +# with the integer p. +def point(p): + return generator_secp256k1 * p + + +# ser32(i): serialize a 32-bit unsigned integer i as a 4-byte sequence, most +# significant byte first. +def ser32(i): + return i.to_bytes(4, byteorder='big') + + +# ser256(p): serializes the integer p as a 32-byte sequence, most significant +# byte first. +def ser256(p): + return p.to_bytes(32, byteorder='big') + + +# serP(P): serializes the coordinate pair P = (x,y) as a byte sequence using +# SEC1's compressed form: (0x02 or 0x03) || ser256(x), where the header byte +# depends on the parity of the omitted y coordinate. +def serP(P): + if P.y() & 1 == 0: + parity = b'\x02' + else: + parity = b'\x03' + return parity + ser256(P.x()) + + +def is_infinity(P): + return P == INFINITY + + +# parse256(p): interprets a 32-byte sequence as a 256-bit number, most +# significant byte first. +def parse256(p): + assert(len(p) == 32) + return int.from_bytes(p, byteorder='big') + + +def iH(x): + return x + (1 << 31) + + +n = generator_secp256k1.order() +rformat = re.compile(r"^[0-9]+'?$") + + +def ckd_pub(K_par, c_par, i): + if i >= 1 << 31: + raise BIP32Error("the child is a hardended key") + I = hmac.digest( + c_par, serP(K_par) + ser32(i), 'sha512') + I_L, I_R = I[:32], I[32:] + K_i = point(parse256(I_L)) + K_par + c_i = I_R + if parse256(I_L) >= n or is_infinity(K_i): + raise BIP32Error("invalid i") + return K_i, c_i + +def ckd_prv(k_par, c_par, i): + if i >= 1 << 31: + I = hmac.digest( + c_par, b'\x00' + ser256(k_par) + ser32(i), 'sha512') + else: + I = hmac.digest( + c_par, serP(point(k_par)) + ser32(i), 'sha512') + I_L, I_R = I[:32], I[32:] + k_i = (parse256(I_L) + k_par) % n + c_i = I_R + if parse256(I_L) >= n or k_i == 0: + raise BIP32Error("invalid i") + return k_i, c_i + +class BIP32: + def __init__(self, seed, key="Bitcoin seed"): + I = hmac.digest(b"Bitcoin seed", seed, 'sha512') + I_L, I_R = I[:32], I[32:] + self.m = parse256(I_L) + self.M = SigningKey.from_string(I_L, curve=SECP256k1) \ + .get_verifying_key().pubkey.point + self.c = I_R + + def derive(self, path="m"): + tokens = path.split('/') + if tokens[0] == "m": + k = self.m + c = self.c + for r in tokens[1:]: + if not rformat.match(r): + raise BIP32Error("unsupported path format") + if r[-1] == "'": + i = iH(int(r[:-1])) + else: + i = int(r) + k, c = ckd_prv(k, c, i) + return SigningKey.from_string(k.to_bytes(32, byteorder='big'), curve=SECP256k1) + elif tokens[0] == "M": + K = self.M + c = self.c + for r in tokens[1:]: + if not rformat.match(r): + raise BIP32Error("unsupported path format") + if r[-1] == "'": + i = iH(int(r[:-1])) + else: + i = int(r) + K, c = ckd_pub(K, c, i) + return VerifyingKey.from_public_point(K, curve=SECP256k1) + else: + raise BIP32Error("unsupported path format") + +def get_eth_addr(pk): + pub_key = pk.to_string() + m = keccak_256() + m.update(pub_key) + return m.hexdigest()[24:] + +def get_privkey_btc(sk): + priv_key = b'\x80' + sk.to_string() + checksum = sha256(sha256(priv_key))[:4] + return b58encode(priv_key + checksum).decode("utf-8") + +def get_btc_addr(pk): + h = b'\x00' + ripemd160(sha256(b'\x04' + pk.to_string())) + checksum = sha256(sha256(h))[:4] + h += checksum + return b58encode(h).decode("utf-8") + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Derive BIP32 key pairs from BIP39 mnemonic') + parser.add_argument('--show-private', action='store_true', default=False, help='also show private keys') + parser.add_argument('--custom-words', action='store_true', default=False, help='use an arbitrary word combination as mnemonic') + parser.add_argument('--account-path', default="44'/9000'/0'/0", help='path prefix for key deriving') + parser.add_argument('--gen-mnemonic', action='store_true', default=False, help='generate a mnemonic (instead of taking an input)') + parser.add_argument('--lang', type=str, default="english", help='language for mnemonic words') + parser.add_argument('--start-idx', type=int, default=0, help='the start index for keys') + parser.add_argument('--end-idx', type=int, default=1, help='the end index for keys (exclusive)') + + args = parser.parse_args() + + + if args.gen_mnemonic: + mgen = mnemonic.Mnemonic(args.lang) + words = mgen.generate(256) + print("KEEP THIS PRIVATE: {}".format(words)) + else: + words = getpass('Enter the mnemonic: ') + if not args.custom_words: + mchecker = mnemonic.Mnemonic(args.lang) + if not mchecker.check(words): + err.write("Invalid mnemonic\n") + sys.exit(1) + + seed = hashlib.pbkdf2_hmac('sha512', unicodedata.normalize('NFKD', words).encode("utf-8"), b"mnemonic", 2048) + gen = BIP32(seed) + if args.start_idx < 0 or args.end_idx < 0: + sys.exit(1) + for i in range(args.start_idx, args.end_idx): + path = "m/{}/{}".format(args.account_path, i) + priv = gen.derive(path) + pub = priv.get_verifying_key() + cpub = pub.to_string(encoding="compressed") + if args.show_private: + print("{}.priv(raw) {}".format(i, priv.to_string().hex())) + print("{}.priv(BTC) {}".format(i, get_privkey_btc(priv))) + print("{}.addr(AVAX) X-{}".format(i, bech32.bech32_encode('avax', bech32.convertbits(ripemd160(sha256(cpub)), 8, 5)))) + print("{}.addr(BTC) {}".format(i, get_btc_addr(pub))) + print("{}.addr(ETH) {}".format(i, get_eth_addr(pub))) diff --git a/freezed_deps/ecdsa-0.15.dist-info/INSTALLER b/freezed_deps/ecdsa-0.15.dist-info/INSTALLER new file mode 100644 index 0000000..a1b589e --- /dev/null +++ b/freezed_deps/ecdsa-0.15.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/freezed_deps/ecdsa-0.15.dist-info/LICENSE b/freezed_deps/ecdsa-0.15.dist-info/LICENSE new file mode 100644 index 0000000..474479a --- /dev/null +++ b/freezed_deps/ecdsa-0.15.dist-info/LICENSE @@ -0,0 +1,24 @@ +"python-ecdsa" Copyright (c) 2010 Brian Warner + +Portions written in 2005 by Peter Pearson and placed in the public domain. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/freezed_deps/ecdsa-0.15.dist-info/METADATA b/freezed_deps/ecdsa-0.15.dist-info/METADATA new file mode 100644 index 0000000..6e8a2ef --- /dev/null +++ b/freezed_deps/ecdsa-0.15.dist-info/METADATA @@ -0,0 +1,625 @@ +Metadata-Version: 2.1 +Name: ecdsa +Version: 0.15 +Summary: ECDSA cryptographic signature library (pure python) +Home-page: http://github.com/warner/python-ecdsa +Author: Brian Warner +Author-email: warner@lothar.com +License: MIT +Platform: UNKNOWN +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.* +Description-Content-Type: text/markdown +Requires-Dist: six (>=1.9.0) +Provides-Extra: gmpy +Requires-Dist: gmpy ; extra == 'gmpy' +Provides-Extra: gmpy2 +Requires-Dist: gmpy2 ; extra == 'gmpy2' + +# Pure-Python ECDSA + +[![build status](https://travis-ci.org/warner/python-ecdsa.png)](http://travis-ci.org/warner/python-ecdsa) +[![Coverage Status](https://coveralls.io/repos/warner/python-ecdsa/badge.svg)](https://coveralls.io/r/warner/python-ecdsa) +[![condition coverage](https://img.shields.io/badge/condition%20coverage-81%25-yellow)](https://travis-ci.org/warner/python-ecdsa/jobs/626479178#L776) +[![Latest Version](https://img.shields.io/pypi/v/ecdsa.svg?style=flat)](https://pypi.python.org/pypi/ecdsa/) + + +This is an easy-to-use implementation of ECDSA cryptography (Elliptic Curve +Digital Signature Algorithm), implemented purely in Python, released under +the MIT license. With this library, you can quickly create keypairs (signing +key and verifying key), sign messages, and verify the signatures. The keys +and signatures are very short, making them easy to handle and incorporate +into other protocols. + +## Features + +This library provides key generation, signing, and verifying, for five +popular NIST "Suite B" GF(p) (_prime field_) curves, with key lengths of 192, +224, 256, 384, and 521 bits. The "short names" for these curves, as known by +the OpenSSL tool (`openssl ecparam -list_curves`), are: `prime192v1`, +`secp224r1`, `prime256v1`, `secp384r1`, and `secp521r1`. It includes the +256-bit curve `secp256k1` used by Bitcoin. There is also support for the +regular (non-twisted) variants of Brainpool curves from 160 to 512 bits. The +"short names" of those curves are: `brainpoolP160r1`, `brainpoolP192r1`, +`brainpoolP224r1`, `brainpoolP256r1`, `brainpoolP320r1`, `brainpoolP384r1`, +`brainpoolP512r1`. +No other curves are included, but it is not too hard to add support for more +curves over prime fields. + +## Dependencies + +This library uses only Python and the 'six' package. It is compatible with +Python 2.6, 2.7 and 3.3+. It also supports execution on the alternative +implementations like pypy and pypy3. + +If `gmpy2` or `gmpy` is installed, they will be used for faster arithmetic. +Either of them can be installed after this library is installed, +`python-ecdsa` will detect their presence on start-up and use them +automatically. + +To run the OpenSSL compatibility tests, the 'openssl' tool must be in your +`PATH`. This release has been tested successfully against OpenSSL 0.9.8o, +1.0.0a, 1.0.2f and 1.1.1d (among others). + + +## Installation + +This library is available on PyPI, it's recommended to install it using `pip`: + +``` +pip install ecdsa +``` + +In case higher performance is wanted and using native code is not a problem, +it's possible to specify installation together with `gmpy2`: + +``` +pip install ecdsa[gmpy2] +``` + +or (slower, legacy option): +``` +pip install ecdsa[gmpy] +``` + +## Speed + +The following table shows how long this library takes to generate keypairs +(`keygen`), to sign data (`sign`), and to verify those signatures (`verify`). +All those values are in seconds. +For convenience, the inverses of those values are also provided: +how many keys per second can be generated (`keygen/s`), how many signatures +can be made per second (`sign/s`) and how many signatures can be verified +per second (`verify/s`). The size of raw signature (generally the smallest +way a signature can be encoded) is also provided in the `siglen` column. +Use `tox -e speed` to generate this table on your own computer. +On an Intel Core i7 4790K @ 4.0GHz I'm getting the following performance: + +``` + siglen keygen keygen/s sign sign/s verify verify/s + NIST192p: 48 0.00035s 2893.02 0.00038s 2620.53 0.00069s 1458.92 + NIST224p: 56 0.00043s 2307.11 0.00048s 2092.00 0.00088s 1131.33 + NIST256p: 64 0.00056s 1793.70 0.00061s 1639.87 0.00113s 883.79 + NIST384p: 96 0.00116s 864.33 0.00124s 806.29 0.00233s 429.87 + NIST521p: 132 0.00221s 452.16 0.00234s 427.31 0.00460s 217.19 + SECP256k1: 64 0.00056s 1772.65 0.00061s 1628.73 0.00110s 912.13 + BRAINPOOLP160r1: 40 0.00026s 3801.86 0.00029s 3401.11 0.00052s 1930.47 + BRAINPOOLP192r1: 48 0.00034s 2925.73 0.00038s 2634.34 0.00070s 1438.06 + BRAINPOOLP224r1: 56 0.00044s 2287.98 0.00048s 2083.87 0.00088s 1137.52 + BRAINPOOLP256r1: 64 0.00056s 1774.11 0.00061s 1628.25 0.00112s 890.71 + BRAINPOOLP320r1: 80 0.00081s 1238.18 0.00087s 1146.71 0.00151s 661.95 + BRAINPOOLP384r1: 96 0.00117s 855.47 0.00124s 804.56 0.00241s 414.83 + BRAINPOOLP512r1: 128 0.00223s 447.99 0.00234s 427.49 0.00437s 229.09 + + ecdh ecdh/s + NIST192p: 0.00110s 910.70 + NIST224p: 0.00143s 701.17 + NIST256p: 0.00178s 560.44 + NIST384p: 0.00383s 261.03 + NIST521p: 0.00745s 134.23 + SECP256k1: 0.00168s 596.23 + BRAINPOOLP160r1: 0.00085s 1174.02 + BRAINPOOLP192r1: 0.00113s 883.47 + BRAINPOOLP224r1: 0.00145s 687.82 + BRAINPOOLP256r1: 0.00195s 514.03 + BRAINPOOLP320r1: 0.00277s 360.80 + BRAINPOOLP384r1: 0.00412s 242.58 + BRAINPOOLP512r1: 0.00787s 127.12 +``` + +To test performance with `gmpy2` loaded, use `tox -e speedgmpy2`. +On the same machine I'm getting the following performance with `gmpy2`: +``` + siglen keygen keygen/s sign sign/s verify verify/s + NIST192p: 48 0.00017s 5945.50 0.00018s 5544.66 0.00033s 3002.54 + NIST224p: 56 0.00021s 4742.14 0.00022s 4463.52 0.00044s 2248.59 + NIST256p: 64 0.00024s 4155.73 0.00025s 3994.28 0.00047s 2105.34 + NIST384p: 96 0.00041s 2415.06 0.00043s 2316.41 0.00085s 1177.18 + NIST521p: 132 0.00072s 1391.14 0.00074s 1359.63 0.00140s 716.31 + SECP256k1: 64 0.00024s 4216.50 0.00025s 3994.52 0.00047s 2120.57 + BRAINPOOLP160r1: 40 0.00014s 7038.99 0.00015s 6501.55 0.00029s 3397.79 + BRAINPOOLP192r1: 48 0.00017s 5983.18 0.00018s 5626.08 0.00035s 2843.62 + BRAINPOOLP224r1: 56 0.00021s 4727.54 0.00022s 4464.86 0.00043s 2326.84 + BRAINPOOLP256r1: 64 0.00024s 4221.00 0.00025s 4010.26 0.00049s 2046.40 + BRAINPOOLP320r1: 80 0.00032s 3142.14 0.00033s 3009.15 0.00061s 1652.88 + BRAINPOOLP384r1: 96 0.00041s 2415.98 0.00043s 2340.35 0.00083s 1198.77 + BRAINPOOLP512r1: 128 0.00064s 1567.27 0.00066s 1526.33 0.00127s 788.51 + + ecdh ecdh/s + NIST192p: 0.00051s 1960.26 + NIST224p: 0.00067s 1502.97 + NIST256p: 0.00073s 1376.12 + NIST384p: 0.00132s 758.68 + NIST521p: 0.00231s 433.23 + SECP256k1: 0.00072s 1387.18 + BRAINPOOLP160r1: 0.00042s 2366.60 + BRAINPOOLP192r1: 0.00049s 2026.80 + BRAINPOOLP224r1: 0.00067s 1486.52 + BRAINPOOLP256r1: 0.00076s 1310.31 + BRAINPOOLP320r1: 0.00101s 986.16 + BRAINPOOLP384r1: 0.00131s 761.35 + BRAINPOOLP512r1: 0.00211s 473.30 +``` + +(there's also `gmpy` version, execute it using `tox -e speedgmpy`) + +For comparison, a highly optimised implementation (including curve-specific +assembly for some curves), like the one in OpenSSL 1.1.1d, provides following +performance numbers on the same machine. +Run `openssl speed ecdsa` and `openssl speed ecdh` to reproduce it: +``` + sign verify sign/s verify/s + 192 bits ecdsa (nistp192) 0.0002s 0.0002s 4785.6 5380.7 + 224 bits ecdsa (nistp224) 0.0000s 0.0001s 22475.6 9822.0 + 256 bits ecdsa (nistp256) 0.0000s 0.0001s 45069.6 14166.6 + 384 bits ecdsa (nistp384) 0.0008s 0.0006s 1265.6 1648.1 + 521 bits ecdsa (nistp521) 0.0003s 0.0005s 3753.1 1819.5 + 256 bits ecdsa (brainpoolP256r1) 0.0003s 0.0003s 2983.5 3333.2 + 384 bits ecdsa (brainpoolP384r1) 0.0008s 0.0007s 1258.8 1528.1 + 512 bits ecdsa (brainpoolP512r1) 0.0015s 0.0012s 675.1 860.1 + + op op/s + 192 bits ecdh (nistp192) 0.0002s 4853.4 + 224 bits ecdh (nistp224) 0.0001s 15252.1 + 256 bits ecdh (nistp256) 0.0001s 18436.3 + 384 bits ecdh (nistp384) 0.0008s 1292.7 + 521 bits ecdh (nistp521) 0.0003s 2884.7 + 256 bits ecdh (brainpoolP256r1) 0.0003s 3066.5 + 384 bits ecdh (brainpoolP384r1) 0.0008s 1298.0 + 512 bits ecdh (brainpoolP512r1) 0.0014s 694.8 +``` + +Keys and signature can be serialized in different ways (see Usage, below). +For a NIST192p key, the three basic representations require strings of the +following lengths (in bytes): + + to_string: signkey= 24, verifykey= 48, signature=48 + compressed: signkey=n/a, verifykey= 25, signature=n/a + DER: signkey=106, verifykey= 80, signature=55 + PEM: signkey=278, verifykey=162, (no support for PEM signatures) + +## History + +In 2006, Peter Pearson announced his pure-python implementation of ECDSA in a +[message to sci.crypt][1], available from his [download site][2]. In 2010, +Brian Warner wrote a wrapper around this code, to make it a bit easier and +safer to use. Hubert Kario then included an implementation of elliptic curve +cryptography that uses Jacobian coordinates internally, improving performance +about 20-fold. You are looking at the README for this wrapper. + +[1]: http://www.derkeiler.com/Newsgroups/sci.crypt/2006-01/msg00651.html +[2]: http://webpages.charter.net/curryfans/peter/downloads.html + +## Testing + +To run the full test suite, do this: + + tox -e coverage + +On an Intel Core i7 4790K @ 4.0GHz, the tests take about 16 seconds to execute. +The test suite uses +[`hypothesis`](https://github.com/HypothesisWorks/hypothesis) so there is some +inherent variability in the test suite execution time. + +One part of `test_pyecdsa.py` checks compatibility with OpenSSL, by +running the "openssl" CLI tool, make sure it's in your `PATH` if you want +to test compatibility with it. + +## Security + +This library was not designed with security in mind. If you are processing +data that needs to be protected we suggest you use a quality wrapper around +OpenSSL. [pyca/cryptography](https://cryptography.io) is one example of such +a wrapper. The primary use-case of this library is as a portable library for +interoperability testing and as a teaching tool. + +**This library does not protect against side channel attacks.** + +Do not allow attackers to measure how long it takes you to generate a keypair +or sign a message. Do not allow attackers to run code on the same physical +machine when keypair generation or signing is taking place (this includes +virtual machines). Do not allow attackers to measure how much power your +computer uses while generating the keypair or signing a message. Do not allow +attackers to measure RF interference coming from your computer while generating +a keypair or signing a message. Note: just loading the private key will cause +keypair generation. Other operations or attack vectors may also be +vulnerable to attacks. **For a sophisticated attacker observing just one +operation with a private key will be sufficient to completely +reconstruct the private key**. + +Please also note that any Pure-python cryptographic library will be vulnerable +to the same side channel attacks. This is because Python does not provide +side-channel secure primitives (with the exception of +[`hmac.compare_digest()`][3]), making side-channel secure programming +impossible. + +This library depends upon a strong source of random numbers. Do not use it on +a system where `os.urandom()` does not provide cryptographically secure +random numbers. + +[3]: https://docs.python.org/3/library/hmac.html#hmac.compare_digest + +## Usage + +You start by creating a `SigningKey`. You can use this to sign data, by passing +in data as a byte string and getting back the signature (also a byte string). +You can also ask a `SigningKey` to give you the corresponding `VerifyingKey`. +The `VerifyingKey` can be used to verify a signature, by passing it both the +data string and the signature byte string: it either returns True or raises +`BadSignatureError`. + +```python +from ecdsa import SigningKey +sk = SigningKey.generate() # uses NIST192p +vk = sk.verifying_key +signature = sk.sign(b"message") +assert vk.verify(signature, b"message") +``` + +Each `SigningKey`/`VerifyingKey` is associated with a specific curve, like +NIST192p (the default one). Longer curves are more secure, but take longer to +use, and result in longer keys and signatures. + +```python +from ecdsa import SigningKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +vk = sk.verifying_key +signature = sk.sign(b"message") +assert vk.verify(signature, b"message") +``` + +The `SigningKey` can be serialized into several different formats: the shortest +is to call `s=sk.to_string()`, and then re-create it with +`SigningKey.from_string(s, curve)` . This short form does not record the +curve, so you must be sure to pass to `from_string()` the same curve you used +for the original key. The short form of a NIST192p-based signing key is just 24 +bytes long. If a point encoding is invalid or it does not lie on the specified +curve, `from_string()` will raise `MalformedPointError`. + +```python +from ecdsa import SigningKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +sk_string = sk.to_string() +sk2 = SigningKey.from_string(sk_string, curve=NIST384p) +print(sk_string.hex()) +print(sk2.to_string().hex()) +``` + +Note: while the methods are called `to_string()` the type they return is +actually `bytes`, the "string" part is leftover from Python 2. + +`sk.to_pem()` and `sk.to_der()` will serialize the signing key into the same +formats that OpenSSL uses. The PEM file looks like the familiar ASCII-armored +`"-----BEGIN EC PRIVATE KEY-----"` base64-encoded format, and the DER format +is a shorter binary form of the same data. +`SigningKey.from_pem()/.from_der()` will undo this serialization. These +formats include the curve name, so you do not need to pass in a curve +identifier to the deserializer. In case the file is malformed `from_der()` +and `from_pem()` will raise `UnexpectedDER` or` MalformedPointError`. + +```python +from ecdsa import SigningKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +sk_pem = sk.to_pem() +sk2 = SigningKey.from_pem(sk_pem) +# sk and sk2 are the same key +``` + +Likewise, the `VerifyingKey` can be serialized in the same way: +`vk.to_string()/VerifyingKey.from_string()`, `to_pem()/from_pem()`, and +`to_der()/from_der()`. The same `curve=` argument is needed for +`VerifyingKey.from_string()`. + +```python +from ecdsa import SigningKey, VerifyingKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +vk = sk.verifying_key +vk_string = vk.to_string() +vk2 = VerifyingKey.from_string(vk_string, curve=NIST384p) +# vk and vk2 are the same key + +from ecdsa import SigningKey, VerifyingKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +vk = sk.verifying_key +vk_pem = vk.to_pem() +vk2 = VerifyingKey.from_pem(vk_pem) +# vk and vk2 are the same key +``` + +There are a couple of different ways to compute a signature. Fundamentally, +ECDSA takes a number that represents the data being signed, and returns a +pair of numbers that represent the signature. The `hashfunc=` argument to +`sk.sign()` and `vk.verify()` is used to turn an arbitrary string into +fixed-length digest, which is then turned into a number that ECDSA can sign, +and both sign and verify must use the same approach. The default value is +`hashlib.sha1`, but if you use NIST256p or a longer curve, you can use +`hashlib.sha256` instead. + +There are also multiple ways to represent a signature. The default +`sk.sign()` and `vk.verify()` methods present it as a short string, for +simplicity and minimal overhead. To use a different scheme, use the +`sk.sign(sigencode=)` and `vk.verify(sigdecode=)` arguments. There are helper +functions in the `ecdsa.util` module that can be useful here. + +It is also possible to create a `SigningKey` from a "seed", which is +deterministic. This can be used in protocols where you want to derive +consistent signing keys from some other secret, for example when you want +three separate keys and only want to store a single master secret. You should +start with a uniformly-distributed unguessable seed with about `curve.baselen` +bytes of entropy, and then use one of the helper functions in `ecdsa.util` to +convert it into an integer in the correct range, and then finally pass it +into `SigningKey.from_secret_exponent()`, like this: + +```python +import os +from ecdsa import NIST384p, SigningKey +from ecdsa.util import randrange_from_seed__trytryagain + +def make_key(seed): + secexp = randrange_from_seed__trytryagain(seed, NIST384p.order) + return SigningKey.from_secret_exponent(secexp, curve=NIST384p) + +seed = os.urandom(NIST384p.baselen) # or other starting point +sk1a = make_key(seed) +sk1b = make_key(seed) +# note: sk1a and sk1b are the same key +assert sk1a.to_string() == sk1b.to_string() +sk2 = make_key(b"2-"+seed) # different key +assert sk1a.to_string() != sk2.to_string() +``` + +In case the application will verify a lot of signatures made with a single +key, it's possible to precompute some of the internal values to make +signature verification significantly faster. The break-even point occurs at +about 100 signatures verified. + +To perform precomputation, you can call the `precompute()` method +on `VerifyingKey` instance: +```python +from ecdsa import SigningKey, NIST384p +sk = SigningKey.generate(curve=NIST384p) +vk = sk.verifying_key +vk.precompute() +signature = sk.sign(b"message") +assert vk.verify(signature, b"message") +``` + +Once `precompute()` was called, all signature verifications with this key will +be faster to execute. + +## OpenSSL Compatibility + +To produce signatures that can be verified by OpenSSL tools, or to verify +signatures that were produced by those tools, use: + +```python +# openssl ecparam -name prime256v1 -genkey -out sk.pem +# openssl ec -in sk.pem -pubout -out vk.pem +# echo "data for signing" > data +# openssl dgst -sha256 -sign sk.pem -out data.sig data +# openssl dgst -sha256 -verify vk.pem -signature data.sig data +# openssl dgst -sha256 -prverify sk.pem -signature data.sig data + +import hashlib +from ecdsa import SigningKey, VerifyingKey +from ecdsa.util import sigencode_der, sigdecode_der + +with open("vk.pem") as f: + vk = VerifyingKey.from_pem(f.read()) + +with open("data", "rb") as f: + data = f.read() + +with open("data.sig", "rb") as f: + signature = f.read() + +assert vk.verify(signature, data, hashlib.sha256, sigdecode=sigdecode_der) + +with open("sk.pem") as f: + sk = SigningKey.from_pem(f.read(), hashlib.sha256) + +new_signature = sk.sign_deterministic(data, sigencode=sigencode_der) + +with open("data.sig2", "wb") as f: + f.write(new_signature) + +# openssl dgst -sha256 -verify vk.pem -signature data.sig2 data +``` + +Note: if compatibility with OpenSSL 1.0.0 or earlier is necessary, the +`sigencode_string` and `sigdecode_string` from `ecdsa.util` can be used for +respectively writing and reading the signatures. + +The keys also can be written in format that openssl can handle: + +```python +from ecdsa import SigningKey, VerifyingKey + +with open("sk.pem") as f: + sk = SigningKey.from_pem(f.read()) +with open("sk.pem", "wb") as f: + f.write(sk.to_pem()) + +with open("vk.pem") as f: + vk = VerifyingKey.from_pem(f.read()) +with open("vk.pem", "wb") as f: + f.write(vk.to_pem()) +``` + +## Entropy + +Creating a signing key with `SigningKey.generate()` requires some form of +entropy (as opposed to +`from_secret_exponent`/`from_string`/`from_der`/`from_pem`, +which are deterministic and do not require an entropy source). The default +source is `os.urandom()`, but you can pass any other function that behaves +like `os.urandom` as the `entropy=` argument to do something different. This +may be useful in unit tests, where you want to achieve repeatable results. The +`ecdsa.util.PRNG` utility is handy here: it takes a seed and produces a strong +pseudo-random stream from it: + +```python +from ecdsa.util import PRNG +from ecdsa import SigningKey +rng1 = PRNG(b"seed") +sk1 = SigningKey.generate(entropy=rng1) +rng2 = PRNG(b"seed") +sk2 = SigningKey.generate(entropy=rng2) +# sk1 and sk2 are the same key +``` + +Likewise, ECDSA signature generation requires a random number, and each +signature must use a different one (using the same number twice will +immediately reveal the private signing key). The `sk.sign()` method takes an +`entropy=` argument which behaves the same as `SigningKey.generate(entropy=)`. + +## Deterministic Signatures + +If you call `SigningKey.sign_deterministic(data)` instead of `.sign(data)`, +the code will generate a deterministic signature instead of a random one. +This uses the algorithm from RFC6979 to safely generate a unique `k` value, +derived from the private key and the message being signed. Each time you sign +the same message with the same key, you will get the same signature (using +the same `k`). + +This may become the default in a future version, as it is not vulnerable to +failures of the entropy source. + +## Examples + +Create a NIST192p keypair and immediately save both to disk: + +```python +from ecdsa import SigningKey +sk = SigningKey.generate() +vk = sk.verifying_key +with open("private.pem", "wb") as f: + f.write(sk.to_pem()) +with open("public.pem", "wb") as f: + f.write(vk.to_pem()) +``` + +Load a signing key from disk, use it to sign a message (using SHA-1), and write +the signature to disk: + +```python +from ecdsa import SigningKey +with open("private.pem") as f: + sk = SigningKey.from_pem(f.read()) +with open("message", "rb") as f: + message = f.read() +sig = sk.sign(message) +with open("signature", "wb") as f: + f.write(sig) +``` + +Load the verifying key, message, and signature from disk, and verify the +signature (assume SHA-1 hash): + +```python +from ecdsa import VerifyingKey, BadSignatureError +vk = VerifyingKey.from_pem(open("public.pem").read()) +with open("message", "rb") as f: + message = f.read() +with open("signature", "rb") as f: + sig = f.read() +try: + vk.verify(sig, message) + print "good signature" +except BadSignatureError: + print "BAD SIGNATURE" +``` + +Create a NIST521p keypair: + +```python +from ecdsa import SigningKey, NIST521p +sk = SigningKey.generate(curve=NIST521p) +vk = sk.verifying_key +``` + +Create three independent signing keys from a master seed: + +```python +from ecdsa import NIST192p, SigningKey +from ecdsa.util import randrange_from_seed__trytryagain + +def make_key_from_seed(seed, curve=NIST192p): + secexp = randrange_from_seed__trytryagain(seed, curve.order) + return SigningKey.from_secret_exponent(secexp, curve) + +sk1 = make_key_from_seed("1:%s" % seed) +sk2 = make_key_from_seed("2:%s" % seed) +sk3 = make_key_from_seed("3:%s" % seed) +``` + +Load a verifying key from disk and print it using hex encoding in +uncompressed and compressed format (defined in X9.62 and SEC1 standards): + +```python +from ecdsa import VerifyingKey + +with open("public.pem") as f: + vk = VerifyingKey.from_pem(f.read()) + +print("uncompressed: {0}".format(vk.to_string("uncompressed").hex())) +print("compressed: {0}".format(vk.to_string("compressed").hex())) +``` + +Load a verifying key from a hex string from compressed format, output +uncompressed: + +```python +from ecdsa import VerifyingKey, NIST256p + +comp_str = '022799c0d0ee09772fdd337d4f28dc155581951d07082fb19a38aa396b67e77759' +vk = VerifyingKey.from_string(bytearray.fromhex(comp_str), curve=NIST256p) +print(vk.to_string("uncompressed").hex()) +``` + +ECDH key exchange with remote party + +```python +from ecdsa import ECDH, NIST256p + +ecdh = ECDH(curve=NIST256p) +ecdh.generate_private_key() +local_public_key = ecdh.get_public_key() +#send `local_public_key` to remote party and receive `remote_public_key` from remote party +with open("remote_public_key.pem") as e: + remote_public_key = e.read() +ecdh.load_received_public_key_pem(remote_public_key) +secret = ecdh.generate_sharedsecret_bytes() +``` + + diff --git a/freezed_deps/ecdsa-0.15.dist-info/RECORD b/freezed_deps/ecdsa-0.15.dist-info/RECORD new file mode 100644 index 0000000..0411a4f --- /dev/null +++ b/freezed_deps/ecdsa-0.15.dist-info/RECORD @@ -0,0 +1,52 @@ +ecdsa-0.15.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +ecdsa-0.15.dist-info/LICENSE,sha256=PsqYRXc9LluMydjBGdNF8ApIBuS9Zg1KPWzfnA6di7I,1147 +ecdsa-0.15.dist-info/METADATA,sha256=Vipd5pI4sqqaWMjmDzRNRkZCQaq1YDHOHkAJPlI92tw,24899 +ecdsa-0.15.dist-info/RECORD,, +ecdsa-0.15.dist-info/WHEEL,sha256=8zNYZbwQSXoB9IfXOjPfeNwvAsALAjffgk27FqvCWbo,110 +ecdsa-0.15.dist-info/top_level.txt,sha256=7ovPHfAPyTou19f8gOSbHm6B9dGjTibWolcCB7Zjovs,6 +ecdsa/__init__.py,sha256=3wbqSX9mkjn_sjkbx2vU-MJbKg0uz8DYLAZE5Jk4iyc,1219 +ecdsa/__pycache__/__init__.cpython-38.pyc,, +ecdsa/__pycache__/_compat.cpython-38.pyc,, +ecdsa/__pycache__/_rwlock.cpython-38.pyc,, +ecdsa/__pycache__/_version.cpython-38.pyc,, +ecdsa/__pycache__/curves.cpython-38.pyc,, +ecdsa/__pycache__/der.cpython-38.pyc,, +ecdsa/__pycache__/ecdh.cpython-38.pyc,, +ecdsa/__pycache__/ecdsa.cpython-38.pyc,, +ecdsa/__pycache__/ellipticcurve.cpython-38.pyc,, +ecdsa/__pycache__/keys.cpython-38.pyc,, +ecdsa/__pycache__/numbertheory.cpython-38.pyc,, +ecdsa/__pycache__/rfc6979.cpython-38.pyc,, +ecdsa/__pycache__/test_der.cpython-38.pyc,, +ecdsa/__pycache__/test_ecdh.cpython-38.pyc,, +ecdsa/__pycache__/test_ecdsa.cpython-38.pyc,, +ecdsa/__pycache__/test_ellipticcurve.cpython-38.pyc,, +ecdsa/__pycache__/test_jacobi.cpython-38.pyc,, +ecdsa/__pycache__/test_keys.cpython-38.pyc,, +ecdsa/__pycache__/test_malformed_sigs.cpython-38.pyc,, +ecdsa/__pycache__/test_numbertheory.cpython-38.pyc,, +ecdsa/__pycache__/test_pyecdsa.cpython-38.pyc,, +ecdsa/__pycache__/test_rw_lock.cpython-38.pyc,, +ecdsa/__pycache__/util.cpython-38.pyc,, +ecdsa/_compat.py,sha256=qmUf5lfl20-p8JleM4etlhplAEN37gbBqadBxXboomo,1108 +ecdsa/_rwlock.py,sha256=UVXDDwWF115oQroaHUtQo88uhhIoMLPIKfDQq3i7ETc,2848 +ecdsa/_version.py,sha256=J5ustrqphtIgbQXJKWGzATMRfq4koBTZ2UYvZuesnRw,496 +ecdsa/curves.py,sha256=Snq0JL6lydJunmSHeeycWvUQJ8Sj5N1tavcw6ZlZ4ik,4278 +ecdsa/der.py,sha256=rfV-KrVw10YAA2EWkVA4vZgbdeEhgsXaXfDd3S5qpp8,13864 +ecdsa/ecdh.py,sha256=qsUDPGMF9-tiqLaA9xUfhNBoUQ49gtMMFrc_O1YO_BQ,10459 +ecdsa/ecdsa.py,sha256=MB7v-2hUV982oOk-OzmKLtq-GXIPjNNK-Yd_dM4VcqU,17546 +ecdsa/ellipticcurve.py,sha256=wa3Om5WkW-HszXlBzyKdGaFfbQDsLABDCSXfrBzSMx0,24278 +ecdsa/keys.py,sha256=jeDeK5-G4C5jYebV0_sQGavRUQp5grNY7CV9eOH7o7I,52990 +ecdsa/numbertheory.py,sha256=FQiMnzY92Qi-Tt2z1czVd5MvaqqXzRgwlChZwPhwxEQ,15427 +ecdsa/rfc6979.py,sha256=7MR1nf19ZBD-EDgztlJ1SfSwLjlx3ePPb9BBFW7aEHo,2701 +ecdsa/test_der.py,sha256=XGZwUhZORvAZKEiWTLDDKlF_4JBplbUmTwkfdN-KGXU,12609 +ecdsa/test_ecdh.py,sha256=VlkuPt7fqwGh1nWwLVA-10Pguu5PYqWVaEOTDO7qlGM,13472 +ecdsa/test_ecdsa.py,sha256=zGC5L5vqc8nWNOKf0KOaUu3rJuLvpICioQ8tSypEjxs,18334 +ecdsa/test_ellipticcurve.py,sha256=odDCqwJm_sQgDFja9xSklpVskpXG5ebJ4xpBONU0duQ,6160 +ecdsa/test_jacobi.py,sha256=iGtWSMLpJ8HmJlrJkU7aiC5d50I8ahHKXFWfd0o_YP4,10778 +ecdsa/test_keys.py,sha256=NcnvEHsHJ0W-5T1F7M2RS9MzdR26ELlTv2LfAgMqEaU,12701 +ecdsa/test_malformed_sigs.py,sha256=6ow1rb-A-lbFD-TZjcl6a8VV9bwV2aL5Z0kwYJ4SJfk,10170 +ecdsa/test_numbertheory.py,sha256=KwC75hI2NfVPctlYki4JIUT8hUUcoK0x1AjcXDZQrow,9004 +ecdsa/test_pyecdsa.py,sha256=FqGtHsqwOpWz3Ne0Cmgib508pcEGv1b31eEBo-PQ5bE,64737 +ecdsa/test_rw_lock.py,sha256=5Gu_H73gU8Pb1_86X3AzkLMTYOtE4qdAwDOzBsEVbjk,6899 +ecdsa/util.py,sha256=CO6Jj3kUL28fIM3KnsevxYQJ1TCAAYDgCSacDAbSMu0,14007 diff --git a/freezed_deps/ecdsa-0.15.dist-info/WHEEL b/freezed_deps/ecdsa-0.15.dist-info/WHEEL new file mode 100644 index 0000000..8b701e9 --- /dev/null +++