eth2.0-specs/test_libs/pyspec/eth2spec/utils/bls.py

40 lines
1.0 KiB
Python
Raw Normal View History

2019-05-13 21:15:02 +00:00
from py_ecc import bls
# Flag to make BLS active or not. Used for testing, do not ignore BLS in production unless you know what you are doing.
bls_active = True
def bls_verify(pubkey, message_hash, signature, domain):
if bls_active:
return bls.verify(message_hash=message_hash, pubkey=pubkey, signature=signature, domain=domain)
else:
return True
def bls_verify_multiple(pubkeys, message_hashes, signature, domain):
if bls_active:
return bls.verify_multiple(pubkeys, message_hashes, signature, domain)
else:
return True
def bls_aggregate_pubkeys(pubkeys):
if bls_active:
return bls.aggregate_pubkeys(pubkeys)
else:
2019-05-15 16:37:11 +00:00
return b'\xaa' * 48
def bls_aggregate_signatures(signatures):
if bls_active:
return bls.aggregate_signatures(signatures)
else:
return b'\x22' * 96
def bls_sign(message_hash, privkey, domain):
if bls_active:
return bls.sign(message_hash=message_hash, privkey=privkey, domain=domain)
else:
return b'\x11' * 96