diff --git a/setup.py b/setup.py index 350f4aedd..451da1b73 100644 --- a/setup.py +++ b/setup.py @@ -537,7 +537,7 @@ setup( "eth-typing>=2.1.0,<3.0.0", "pycryptodome==3.9.4", "py_ecc==5.0.0", - "milagro_bls_binding==1.3.0", + "milagro_bls_binding==1.4.0", "dataclasses==0.6", "remerkleable==0.1.17", "ruamel.yaml==0.16.5", diff --git a/tests/core/pyspec/eth2spec/utils/bls.py b/tests/core/pyspec/eth2spec/utils/bls.py index dd3172b4b..88edbac61 100644 --- a/tests/core/pyspec/eth2spec/utils/bls.py +++ b/tests/core/pyspec/eth2spec/utils/bls.py @@ -10,6 +10,7 @@ bls = py_ecc_bls STUB_SIGNATURE = b'\x11' * 96 STUB_PUBKEY = b'\x22' * 48 +Z1_PUBKEY = b'\xc0' + b'\x00' * 47 Z2_SIGNATURE = b'\xc0' + b'\x00' * 95 STUB_COORDINATES = _signature_to_G2(Z2_SIGNATURE) @@ -66,6 +67,11 @@ def AggregateVerify(pubkeys, messages, signature): @only_with_bls(alt_return=True) def FastAggregateVerify(pubkeys, message, signature): + # TODO: remove it when milagro_bls_binding is fixed + # https://github.com/ChihChengLiang/milagro_bls_binding/issues/19 + if Z1_PUBKEY in pubkeys: + return False + try: result = bls.FastAggregateVerify(list(pubkeys), message, signature) except Exception: @@ -81,6 +87,9 @@ def Aggregate(signatures): @only_with_bls(alt_return=STUB_SIGNATURE) def Sign(SK, message): + # TODO: remove it when https://github.com/sigp/milagro_bls/issues/39 is fixed + if SK == 0: + raise Exception("SK should not be zero") if bls == py_ecc_bls: return bls.Sign(SK, message) else: diff --git a/tests/generators/bls/main.py b/tests/generators/bls/main.py index 32edc1c41..8cdc2a94b 100644 --- a/tests/generators/bls/main.py +++ b/tests/generators/bls/main.py @@ -83,7 +83,8 @@ def case01_sign(): } # Edge case: privkey == 0 expect_exception(bls.Sign, ZERO_PRIVKEY, message) - # expect_exception(milagro_bls.Sign, ZERO_PRIVKEY_BYTES, message) # TODO: enable it when milagro is ready + # TODO enable it when milagro_bls is ready for IETF BLS draft 04 + # expect_exception(milagro_bls.Sign, ZERO_PRIVKEY_BYTES, message) yield f'sign_case_zero_privkey', { 'input': { 'privkey': encode_hex(ZERO_PRIVKEY_BYTES), @@ -147,7 +148,7 @@ def case02_verify(): # Invalid pubkey and signature with the point at infinity assert not bls.Verify(Z1_PUBKEY, SAMPLE_MESSAGE, Z2_SIGNATURE) - # assert not milagro_bls.Verify(Z1_PUBKEY, SAMPLE_MESSAGE, Z2_SIGNATURE) # TODO: enable it when milagro is ready + assert not milagro_bls.Verify(Z1_PUBKEY, SAMPLE_MESSAGE, Z2_SIGNATURE) yield f'verify_infinity_pubkey_and_infinity_signature', { 'input': { 'pubkey': encode_hex(Z1_PUBKEY), @@ -266,7 +267,7 @@ def case04_fast_aggregate_verify(): signatures = [bls.Sign(privkey, SAMPLE_MESSAGE) for privkey in PRIVKEYS] aggregate_signature = bls.Aggregate(signatures) assert not bls.FastAggregateVerify(pubkeys_with_infinity, SAMPLE_MESSAGE, aggregate_signature) - # TODO: enable it when milagro is ready + # TODO enable it when milagro_bls is ready for IETF BLS draft 04 # assert not milagro_bls.FastAggregateVerify(pubkeys_with_infinity, SAMPLE_MESSAGE, aggregate_signature) yield f'fast_aggregate_verify_infinity_pubkey', { 'input': { @@ -345,8 +346,7 @@ def case05_aggregate_verify(): pubkeys_with_infinity = pubkeys + [Z1_PUBKEY] messages_with_sample = messages + [SAMPLE_MESSAGE] assert not bls.AggregateVerify(pubkeys_with_infinity, messages_with_sample, aggregate_signature) - # TODO: enable it when milagro is ready - # assert not milagro_bls.AggregateVerify(pubkeys_with_infinity, messages_with_sample, aggregate_signature) + assert not milagro_bls.AggregateVerify(pubkeys_with_infinity, messages_with_sample, aggregate_signature) yield f'aggregate_verify_infinity_pubkey', { 'input': { 'pubkeys': [encode_hex(pubkey) for pubkey in pubkeys_with_infinity],