From 5b01ccc53e1e26c0219ec028ede382c1c22a107f Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Tue, 6 Oct 2020 00:37:54 +0800 Subject: [PATCH 1/5] current behavior --- test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index fc04336..740a032 100644 --- a/test.py +++ b/test.py @@ -7,6 +7,7 @@ G1, G2, multiply, + Z1 ) from py_ecc.bls.g2_primatives import ( G1_to_pubkey, @@ -94,6 +95,8 @@ def test_fast_aggregate_verify(SKs, message): def test_weird_cases(): - bad_signature = b'\x00' * 96 + bad_signature = b'\xc0' + b'\x00' * 95 assert not bls.AggregateVerify([], [], bad_signature) - assert bls.Aggregate([]) == b'\xc0' + b'\x00' * 95 + assert bls.Aggregate([]) == bad_signature + bls.Sign(to_bytes(0), b'abcd') + assert bls.FastAggregateVerify([G1_to_pubkey(Z1)], b'abcd', bad_signature) From 23a65c0ed15e17214af9403d8d30698faade7cda Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Tue, 6 Oct 2020 00:38:44 +0800 Subject: [PATCH 2/5] desired behavior name properly --- test.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test.py b/test.py index 740a032..5a4cd11 100644 --- a/test.py +++ b/test.py @@ -7,7 +7,6 @@ G1, G2, multiply, - Z1 ) from py_ecc.bls.g2_primatives import ( G1_to_pubkey, @@ -95,8 +94,10 @@ def test_fast_aggregate_verify(SKs, message): def test_weird_cases(): - bad_signature = b'\xc0' + b'\x00' * 95 - assert not bls.AggregateVerify([], [], bad_signature) - assert bls.Aggregate([]) == bad_signature - bls.Sign(to_bytes(0), b'abcd') - assert bls.FastAggregateVerify([G1_to_pubkey(Z1)], b'abcd', bad_signature) + Z1_PUBKEY = b'\xc0' + b'\x00' * 47 + Z2_SIGNATURE = b'\xc0' + b'\x00' * 95 + assert not bls.AggregateVerify([], [], Z2_SIGNATURE) + assert bls.Aggregate([]) == Z2_SIGNATURE + with pytest.raises(ValueError): + bls.Sign(to_bytes(0), b'abcd') + assert not bls.FastAggregateVerify([Z1_PUBKEY], b'abcd', Z2_SIGNATURE) From 509f63c0c1e68e516574a88ec38f8a2e5f547a50 Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Tue, 6 Oct 2020 01:36:10 +0800 Subject: [PATCH 3/5] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 126567d..8ca4ecc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "milagro-bls-binding" -version = "1.4.0" +version = "1.5.0" edition = "2018" authors = ["chihchengliang@gmail.com"] From 1a2be5642268cffdd1eee5a14a86e6b197271b24 Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Tue, 6 Oct 2020 02:02:17 +0800 Subject: [PATCH 4/5] fix sign/verify 0 test --- test.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/test.py b/test.py index 5a4cd11..44cd44c 100644 --- a/test.py +++ b/test.py @@ -59,14 +59,6 @@ def test_sign_verify(privkey_int): assert bls.Verify(pub, msg, sig) -def test_sign_verify_zero(): - privkey = to_bytes(0) - msg = "foooooo".encode('utf-8') - pub = bls.SkToPk(privkey) - sig = bls.Sign(privkey, msg) - assert not bls.Verify(pub, msg, sig) - - @pytest.mark.parametrize( 'signature_points,result_point', [ @@ -100,4 +92,5 @@ def test_weird_cases(): assert bls.Aggregate([]) == Z2_SIGNATURE with pytest.raises(ValueError): bls.Sign(to_bytes(0), b'abcd') + assert not bls.Verify(Z1_PUBKEY, b'abcd', Z2_SIGNATURE) assert not bls.FastAggregateVerify([Z1_PUBKEY], b'abcd', Z2_SIGNATURE) From 1cfd96941083dc43ce10813b0f833a219abb8d1e Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Tue, 6 Oct 2020 13:55:51 +0800 Subject: [PATCH 5/5] bump milagro_bls to v1.3.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8ca4ecc..66b2533 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,4 +23,4 @@ crate-type = ["cdylib"] [dependencies] pyo3 = { version = "0.10.1", features = ["extension-module"] } -milagro_bls = {git = "https://github.com/sigp/milagro_bls", tag= "v1.2.0" } +milagro_bls = {git = "https://github.com/sigp/milagro_bls", tag= "v1.3.0" }