From dceece1cda9bb21ec8544b2ab88876277ed6f45a Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 20 Mar 2026 15:48:37 +0000 Subject: [PATCH] mv os.urandom sanity check to main __init__.py cool check but I am going to delete rsakey.py --- electrum/__init__.py | 7 +++++++ electrum/rsakey.py | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/electrum/__init__.py b/electrum/__init__.py index 793f2930c..e94ac78ac 100644 --- a/electrum/__init__.py +++ b/electrum/__init__.py @@ -46,3 +46,10 @@ except AssertionError: else: raise ImportError("Running with asserts disabled. Refusing to continue. Exiting...") + +# Check that os.urandom works +import zlib +length = len(zlib.compress(os.urandom(1000))) +if length <= 900: + raise ImportError("Broken PRNG. Refusing to continue. Exiting...") + diff --git a/electrum/rsakey.py b/electrum/rsakey.py index da87076fe..5266e9cf9 100644 --- a/electrum/rsakey.py +++ b/electrum/rsakey.py @@ -46,10 +46,6 @@ def SHA1(x): # PRNG Functions # ************************************************************************** -# Check that os.urandom works -import zlib -length = len(zlib.compress(os.urandom(1000))) -assert length > 900 def getRandomBytes(howMany): b = bytearray(os.urandom(howMany))