From 91f55f55b532eaa422459702153876b961844dfb Mon Sep 17 00:00:00 2001 From: protolambda Date: Sun, 30 Jun 2019 16:07:54 +0200 Subject: [PATCH] make BLS test format and output consistent with spec --- specs/test_formats/bls/msg_hash_g2_compressed.md | 2 +- specs/test_formats/bls/msg_hash_g2_uncompressed.md | 4 ++-- specs/test_formats/bls/sign_msg.md | 2 +- test_generators/bls/main.py | 9 +++------ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/specs/test_formats/bls/msg_hash_g2_compressed.md b/specs/test_formats/bls/msg_hash_g2_compressed.md index 2feeb92ba..44ea8ded7 100644 --- a/specs/test_formats/bls/msg_hash_g2_compressed.md +++ b/specs/test_formats/bls/msg_hash_g2_compressed.md @@ -7,7 +7,7 @@ A BLS compressed-hash to G2. ```yaml input: message: bytes32, - domain: bytes -- any number + domain: uint64 -- the BLS domain output: List[bytes48] -- length of two ``` diff --git a/specs/test_formats/bls/msg_hash_g2_uncompressed.md b/specs/test_formats/bls/msg_hash_g2_uncompressed.md index 792fe1f03..847b5f61d 100644 --- a/specs/test_formats/bls/msg_hash_g2_uncompressed.md +++ b/specs/test_formats/bls/msg_hash_g2_uncompressed.md @@ -6,8 +6,8 @@ A BLS uncompressed-hash to G2. ```yaml input: - message: bytes32, - domain: bytes -- any number + message: bytes32 + domain: uint64 -- the BLS domain output: List[List[bytes48]] -- 3 lists, each a length of two ``` diff --git a/specs/test_formats/bls/sign_msg.md b/specs/test_formats/bls/sign_msg.md index 9916f2cc2..b17e6246d 100644 --- a/specs/test_formats/bls/sign_msg.md +++ b/specs/test_formats/bls/sign_msg.md @@ -8,7 +8,7 @@ Message signing with BLS should produce a signature. input: privkey: bytes32 -- the private key used for signing message: bytes32 -- input message to sign (a hash) - domain: bytes -- BLS domain + domain: uint64 -- the BLS domain output: bytes96 -- expected signature ``` diff --git a/test_generators/bls/main.py b/test_generators/bls/main.py index 8a6a7dafe..a792dda9a 100644 --- a/test_generators/bls/main.py +++ b/test_generators/bls/main.py @@ -27,9 +27,6 @@ def hex_to_int(x: str) -> int: return int(x, 16) -# Note: even though a domain is only an uint64, -# To avoid issues with YAML parsers that are limited to 53-bit (JS language limit) -# It is serialized as an hex string as well. DOMAINS = [ 0, 1, @@ -92,7 +89,7 @@ def case01_message_hash_G2_uncompressed(): yield { 'input': { 'message': '0x' + msg.hex(), - 'domain': int_to_hex(domain) + 'domain': domain }, 'output': hash_message(msg, domain) } @@ -104,7 +101,7 @@ def case02_message_hash_G2_compressed(): yield { 'input': { 'message': '0x' + msg.hex(), - 'domain': int_to_hex(domain) + 'domain': domain }, 'output': hash_message_compressed(msg, domain) } @@ -129,7 +126,7 @@ def case04_sign_messages(): 'input': { 'privkey': int_to_hex(privkey), 'message': '0x' + message.hex(), - 'domain': int_to_hex(domain) + 'domain': domain }, 'output': '0x' + sig.hex() }