Browse Source
util.randrange: use stdlib 'secrets' module instead of 'python-ecdsa'
patch-4
SomberNight
4 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
5 additions and
3 deletions
-
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: |
|
|
|