Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asanso committed Feb 29, 2024
1 parent ab81330 commit 69b45fb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
G1,
FQ,
add,
multiply
multiply,
neg,
is_inf
)

from py_ecc.bls.hash_to_curve import hash_to_G2
Expand Down Expand Up @@ -103,6 +105,13 @@ def case01_add_G1():
result_comm1 = add(G1,P1)
result_comm2 = add(P1,G1)
assert result_comm1 == result_comm2

# Additive negation
result_neg_G1 = add(G1,neg(G1))
assert(is_inf(result_neg_G1))
result_neg_P1 = add(P1,neg(P1))
assert(is_inf(result_neg_P1))

# Doubling
result_doubling_G1 = add(G1,G1)
assert result_doubling_G1 == multiply(G1,2)
Expand All @@ -125,6 +134,13 @@ def case01_add_G1():
"NoBenchmark": False
},
{
"Input": int_to_hex(int(G1[0]),64)+(int_to_hex(int(G1[1]),64))+int_to_hex(int(neg(G1)[0]),64)+(int_to_hex(int(neg(G1)[1]),64)),
"Name": "bls_g1add_(g1-g1=0)",
"Expected": int_to_hex(0,64)+int_to_hex(0,64),
"Gas": BLS12_G1ADD_GAS,
"NoBenchmark": False
},
{
"Input": int_to_hex(int(G1[0]),64)+(int_to_hex(int(G1[1]),64))+int_to_hex(int(G1[0]),64)+(int_to_hex(int(G1[1]),64)),
"Name": "bls_g1add_(g1+g1=2*g1)",
"Expected": int_to_hex(int(result_doubling_G1[0]),64)+(int_to_hex(int(result_doubling_G1[1]),64)),
Expand Down

0 comments on commit 69b45fb

Please sign in to comment.