mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
script, test: fix python linter E275 errors with flake8 5.0.4
This commit is contained in:
@@ -139,7 +139,7 @@ class EllipticCurve:
|
||||
See https://en.wikibooks.org/wiki/Cryptography/Prime_Curve/Jacobian_Coordinates - Point Addition (with affine point)"""
|
||||
x1, y1, z1 = p1
|
||||
x2, y2, z2 = p2
|
||||
assert(z2 == 1)
|
||||
assert z2 == 1
|
||||
# Adding to the point at infinity is a no-op
|
||||
if z1 == 0:
|
||||
return p2
|
||||
@@ -262,7 +262,7 @@ class ECPubKey():
|
||||
return self.valid
|
||||
|
||||
def get_bytes(self):
|
||||
assert(self.valid)
|
||||
assert self.valid
|
||||
p = SECP256K1.affine(self.p)
|
||||
if p is None:
|
||||
return None
|
||||
@@ -276,7 +276,7 @@ class ECPubKey():
|
||||
|
||||
See https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm for the
|
||||
ECDSA verifier algorithm"""
|
||||
assert(self.valid)
|
||||
assert self.valid
|
||||
|
||||
# Extract r and s from the DER formatted signature. Return false for
|
||||
# any DER encoding errors.
|
||||
@@ -349,7 +349,7 @@ class ECKey():
|
||||
|
||||
def set(self, secret, compressed):
|
||||
"""Construct a private key object with given 32-byte secret and compressed flag."""
|
||||
assert(len(secret) == 32)
|
||||
assert len(secret) == 32
|
||||
secret = int.from_bytes(secret, 'big')
|
||||
self.valid = (secret > 0 and secret < SECP256K1_ORDER)
|
||||
if self.valid:
|
||||
@@ -362,7 +362,7 @@ class ECKey():
|
||||
|
||||
def get_bytes(self):
|
||||
"""Retrieve the 32-byte representation of this key."""
|
||||
assert(self.valid)
|
||||
assert self.valid
|
||||
return self.secret.to_bytes(32, 'big')
|
||||
|
||||
@property
|
||||
@@ -375,7 +375,7 @@ class ECKey():
|
||||
|
||||
def get_pubkey(self):
|
||||
"""Compute an ECPubKey object for this secret key."""
|
||||
assert(self.valid)
|
||||
assert self.valid
|
||||
ret = ECPubKey()
|
||||
p = SECP256K1.mul([(SECP256K1_G, self.secret)])
|
||||
ret.p = p
|
||||
@@ -388,7 +388,7 @@ class ECKey():
|
||||
|
||||
See https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm for the
|
||||
ECDSA signer algorithm."""
|
||||
assert(self.valid)
|
||||
assert self.valid
|
||||
z = int.from_bytes(msg, 'big')
|
||||
# Note: no RFC6979 by default, but a simple random nonce (some tests rely on distinct transactions for the same operation)
|
||||
if rfc6979:
|
||||
|
||||
@@ -824,10 +824,10 @@ def taproot_tree_helper(scripts):
|
||||
if len(scripts) == 1:
|
||||
# One entry: treat as a leaf
|
||||
script = scripts[0]
|
||||
assert(not callable(script))
|
||||
assert not callable(script)
|
||||
if isinstance(script, list):
|
||||
return taproot_tree_helper(script)
|
||||
assert(isinstance(script, tuple))
|
||||
assert isinstance(script, tuple)
|
||||
version = LEAF_VERSION_TAPSCRIPT
|
||||
name = script[0]
|
||||
code = script[1]
|
||||
|
||||
@@ -31,7 +31,7 @@ def siphash_round(v0, v1, v2, v3):
|
||||
|
||||
|
||||
def siphash(k0, k1, data):
|
||||
assert(type(data) == bytes)
|
||||
assert type(data) == bytes
|
||||
v0 = 0x736f6d6570736575 ^ k0
|
||||
v1 = 0x646f72616e646f6d ^ k1
|
||||
v2 = 0x6c7967656e657261 ^ k0
|
||||
@@ -61,5 +61,5 @@ def siphash(k0, k1, data):
|
||||
|
||||
|
||||
def siphash256(k0, k1, num):
|
||||
assert(type(num) == int)
|
||||
assert type(num) == int
|
||||
return siphash(k0, k1, num.to_bytes(32, 'little'))
|
||||
|
||||
Reference in New Issue
Block a user