Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/schnorr.py
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | while True: | ||||
# our purpose. | # our purpose. | ||||
V = hmac.HMAC(K, V, 'sha256').digest() | V = hmac.HMAC(K, V, 'sha256').digest() | ||||
T = V | T = V | ||||
assert len(T) >= 32 | assert len(T) >= 32 | ||||
k = int.from_bytes(T, 'big') | k = int.from_bytes(T, 'big') | ||||
if k > 0 and k < SECP256K1_ORDER: | if k > 0 and k < SECP256K1_ORDER: | ||||
break | break | ||||
K = hmac.HMAC(K, V+b'\x00', 'sha256').digest() | K = hmac.HMAC(K, V+b'\x00', 'sha256').digest() | ||||
V = HMAC_K(V) | V = hmac.HMAC(K, V, 'sha256').digest() | ||||
return k | return k | ||||
def sign(privkeybytes, msg32): | def sign(privkeybytes, msg32): | ||||
"""Create Schnorr signature (BIP-Schnorr convention).""" | """Create Schnorr signature (BIP-Schnorr convention).""" | ||||
assert len(privkeybytes) == 32 | assert len(privkeybytes) == 32 | ||||
assert len(msg32) == 32 | assert len(msg32) == 32 | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |