diff options
author | Determinant <[email protected]> | 2024-08-23 17:52:45 -0700 |
---|---|---|
committer | Determinant <[email protected]> | 2024-08-23 17:52:45 -0700 |
commit | 59759fdde9f03a6c565df50472da5079f6ba745b (patch) | |
tree | b31fd55ed236fc2f69bb3c947142c82086a56963 | |
parent | c4bea62fbf5b3245cd5458181a41c942640197aa (diff) |
remove pysha3 from the dependency
-rw-r--r-- | README.rst | 3 | ||||
-rwxr-xr-x | frozen_deps/_pysha3.cpython-310-x86_64-linux-gnu.so | bin | 358248 -> 0 bytes | |||
-rw-r--r-- | frozen_deps/sha3.py | 24 | ||||
-rwxr-xr-x | keytree.py | 11 |
4 files changed, 7 insertions, 31 deletions
@@ -36,10 +36,9 @@ Security - The dependencies should be safe (but do your own check!) because the part under ``frozen_deps/`` only contains: - - Some standard AES provided by ``Cryptodome`` + - Some standard AES encryption and Keccak-256 hashing provided by ``Cryptodome`` - Curve manipulation provided by ``ecdsa`` - Base58 encoding provided by ``base58`` - - SHA3 calcuation provided by ``pysha3`` Whereas web3-specific modules are pretty short: diff --git a/frozen_deps/_pysha3.cpython-310-x86_64-linux-gnu.so b/frozen_deps/_pysha3.cpython-310-x86_64-linux-gnu.so Binary files differdeleted file mode 100755 index b075af6..0000000 --- a/frozen_deps/_pysha3.cpython-310-x86_64-linux-gnu.so +++ /dev/null diff --git a/frozen_deps/sha3.py b/frozen_deps/sha3.py deleted file mode 100644 index 5657f66..0000000 --- a/frozen_deps/sha3.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2012-2016 Christian Heimes ([email protected]) -# Licensed to PSF under a Contributor Agreement. -# - -# monkey patch _hashlib -import hashlib as _hashlib - -from _pysha3 import keccak_224, keccak_256, keccak_384, keccak_512 -from _pysha3 import sha3_224, sha3_256, sha3_384, sha3_512 -from _pysha3 import shake_128, shake_256 - - -__all__ = ("sha3_224", "sha3_256", "sha3_384", "sha3_512", - "keccak_224", "keccak_256", "keccak_384", "keccak_512", - "shake_128", "shake_256") - - -if not hasattr(_hashlib, "sha3_512"): - _hashlib.sha3_224 = sha3_224 - _hashlib.sha3_256 = sha3_256 - _hashlib.sha3_384 = sha3_384 - _hashlib.sha3_512 = sha3_512 - _hashlib.shake_128 = shake_128 - _hashlib.shake_256 = shake_256 @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.10 +#!/usr/bin/env python3 # MIT License # # Copyright (c) 2020 Ted Yin <[email protected]> @@ -55,10 +55,10 @@ from ecdsa import SigningKey, VerifyingKey, SECP256k1 from ecdsa.ecdsa import generator_secp256k1 from ecdsa.ellipticcurve import INFINITY from base58 import b58encode, b58decode -from sha3 import keccak_256 from uuid import uuid4 from Cryptodome.Cipher import AES from Cryptodome.Util import Counter +from Cryptodome.Hash import keccak import shamir @@ -206,7 +206,7 @@ class BIP32: def get_eth_addr(pk): pub_key = pk.to_string() - m = keccak_256() + m = keccak.new(digest_bits = 256) m.update(pub_key) return m.hexdigest()[24:] @@ -504,7 +504,7 @@ if __name__ == '__main__': recovered = mgen.to_mnemonic(shamir256_combine(verify)) if words != recovered: raise KeytreeError('Shamir sanity check failed: {} = {}'.format(case, recovered)) - print("checked {}".format(case)) + print("checked {}".format(','.join([str(i + 1) for i in case]))) else: shares = shamir256_split(seed, args.shamir_threshold, args.shamir_num) shares = [mgen.to_mnemonic(share[:32]) + ' ' + mgen.to_mnemonic(share[32:]) for share in shares] @@ -518,7 +518,8 @@ if __name__ == '__main__': recovered = shamir256_combine(verify) if seed != recovered: raise KeytreeError('Shamir sanity check failed: {} = {}'.format(case, recovered.hex())) - print("checked {}".format(case)) + print("checked {}".format(','.join([str(i + 1) for i in case]))) + for idx, share in enumerate(shares): print("KEEP THIS PRIVATE (share) #{} {}".format(idx + 1, share)) |