electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 120da2783b032be0a58d01c1ef40a23dcff88f2b
parent 1c07777e135d28fffa157019f90ccdaa002b614e
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat,  7 Nov 2020 19:26:30 +0100

util.randrange: use stdlib 'secrets' module instead of 'python-ecdsa'

Diffstat:
Melectrum/util.py | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/electrum/util.py b/electrum/util.py @@ -44,15 +44,15 @@ import ssl import ipaddress from ipaddress import IPv4Address, IPv6Address import random -import attr +import secrets +import attr import aiohttp from aiohttp_socks import ProxyConnector, ProxyType import aiorpcx from aiorpcx import TaskGroup import certifi import dns.resolver -import ecdsa from .i18n import _ from .logging import get_logger, Logger @@ -1306,7 +1306,9 @@ def resolve_dns_srv(host: str): def randrange(bound: int) -> int: """Return a random integer k such that 1 <= k < bound, uniformly distributed across that range.""" - return ecdsa.util.randrange(bound) + # secrets.randbelow(bound) returns a random int: 0 <= r < bound, + # hence transformations: + return secrets.randbelow(bound - 1) + 1 class CallbackManager: