Skip to content

Commit

Permalink
test verify empty_pubkey_and_signature
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihChengLiang committed Jul 5, 2019
1 parent e5b8792 commit ef39f75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py_ecc/bls/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from py_ecc.optimized_bls12_381 import (
field_modulus as q,
)
from eth_typing import (
BLSPubkey,
BLSSignature,
)

G2_cofactor = 305502333931268344200999753193121504214466019254188142667664032982267604182971884026507427359259977847832272839041616661285803823378372096355777062779109 # noqa: E501
FQ2_order = q ** 2 - 1
Expand All @@ -15,3 +19,6 @@
POW_2_381 = 2**381
POW_2_382 = 2**382
POW_2_383 = 2**383

EMPTY_SIGNATURE = BLSSignature(b'\xc0' + b'\x00' * 95)
EMPTY_PUBKEY = BLSPubkey(b'\xc0' + b'\x00' * 47)
12 changes: 12 additions & 0 deletions tests/test_bls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
normalize,
field_modulus as q,
)
from py_ecc.bls.constants import (
EMPTY_PUBKEY,
EMPTY_SIGNATURE,
)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -78,6 +82,14 @@ def test_decompress_G2_with_no_modular_square_root_found():
signature_to_G2(b'\x11' * 96)


def test_verify_empty_pubkey_and_signature():
"""
`verify` returns True for an empty public key and an empty signature.
The behavior is accepted for now and should be revisited in the future.
"""
assert verify(b'\x11' * 32, EMPTY_PUBKEY, EMPTY_SIGNATURE, 1000)


@pytest.mark.parametrize(
'pt,on_curve,is_infinity',
[
Expand Down

0 comments on commit ef39f75

Please sign in to comment.