Skip to content

Commit

Permalink
Add conformance tests for BLS scalar mulitplication periodicity
Browse files Browse the repository at this point in the history
  • Loading branch information
kwxm committed Mar 17, 2023
1 parent e0bd999 commit 3d89f5d
Show file tree
Hide file tree
Showing 53 changed files with 222 additions and 18 deletions.
44 changes: 26 additions & 18 deletions plutus-conformance/agda/Spec.hs
Expand Up @@ -62,15 +62,19 @@ failingTests = [
, "bls12_381_G1_equal/equal-false"
, "bls12_381_G1_equal/equal-true"
, "bls12_381_G1_hashToCurve/hash"
, "bls12_381_G1_mul/mul0"
, "bls12_381_G1_mul/mul4x11"
, "bls12_381_G1_mul/muladd"
, "bls12_381_G1_mul/mul1"
, "bls12_381_G1_mul/mul44"
, "bls12_381_G1_mul/addmul"
, "bls12_381_G1_mul/mulneg44"
, "bls12_381_G1_mul/mul19+25"
, "bls12_381_G1_mul/mulneg1"
, "bls12_381_G1_scalarMul/mul0"
, "bls12_381_G1_scalarMul/mul4x11"
, "bls12_381_G1_scalarMul/muladd"
, "bls12_381_G1_scalarMul/mul1"
, "bls12_381_G1_scalarMul/mul44"
, "bls12_381_G1_scalarMul/addmul"
, "bls12_381_G1_scalarMul/mulneg44"
, "bls12_381_G1_scalarMul/mul19+25"
, "bls12_381_G1_scalarMul/mulneg1"
, "bls12_381_G1_scalarMul/mulperiodic1"
, "bls12_381_G1_scalarMul/mulperiodic2"
, "bls12_381_G1_scalarMul/mulperiodic3"
, "bls12_381_G1_scalarMul/mulperiodic4"
, "bls12_381_G1_neg/neg"
, "bls12_381_G1_neg/add-neg"
, "bls12_381_G1_neg/neg-zero"
Expand All @@ -93,15 +97,19 @@ failingTests = [
, "bls12_381_G2_equal/equal-false"
, "bls12_381_G2_equal/equal-true"
, "bls12_381_G2_hashToCurve/hash"
, "bls12_381_G2_mul/mul0"
, "bls12_381_G2_mul/mul4x11"
, "bls12_381_G2_mul/muladd"
, "bls12_381_G2_mul/mul1"
, "bls12_381_G2_mul/mul44"
, "bls12_381_G2_mul/addmul"
, "bls12_381_G2_mul/mulneg44"
, "bls12_381_G2_mul/mul19+25"
, "bls12_381_G2_mul/mulneg1"
, "bls12_381_G2_scalarMul/mul0"
, "bls12_381_G2_scalarMul/mul4x11"
, "bls12_381_G2_scalarMul/muladd"
, "bls12_381_G2_scalarMul/mul1"
, "bls12_381_G2_scalarMul/mul44"
, "bls12_381_G2_scalarMul/addmul"
, "bls12_381_G2_scalarMul/mulneg44"
, "bls12_381_G2_scalarMul/mul19+25"
, "bls12_381_G2_scalarMul/mulneg1"
, "bls12_381_G2_scalarMul/mulperiodic1"
, "bls12_381_G2_scalarMul/mulperiodic2"
, "bls12_381_G2_scalarMul/mulperiodic3"
, "bls12_381_G2_scalarMul/mulperiodic4"
, "bls12_381_G2_neg/neg"
, "bls12_381_G2_neg/add-neg"
, "bls12_381_G2_neg/neg-zero"
Expand Down
@@ -0,0 +1,13 @@
-- Scalar multiplication by the group size should give you the zero element of the group.
(program 1.0.0
[
[ (builtin bls12_381_G1_equal)
[
(builtin bls12_381_G1_scalarMul)
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513 )
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
(con bls12_381_G1_element 0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
]
)
@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,23 @@
-- Scalar multiplication should be periodic modulo the group size
(program 1.0.0
[
[
(builtin bls12_381_G1_equal)
[
[
(builtin bls12_381_G1_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
[
[ (builtin bls12_381_G1_scalarMul) (con integer 123) ]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,27 @@
-- Scalar multiplication should be periodic modulo the group size
(program
1.0.0
[
[
(builtin bls12_381_G1_equal)
[
[
(builtin bls12_381_G1_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
[
[ (builtin multiplyInteger) (con integer 987654321) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
[
[ (builtin bls12_381_G1_scalarMul) (con integer 123) ]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,27 @@
-- Scalar multiplication should be periodic modulo the group size
(program
1.0.0
[
[
(builtin bls12_381_G1_equal)
[
[
(builtin bls12_381_G1_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
[
[ (builtin multiplyInteger) (con integer -987654321) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
[
[ (builtin bls12_381_G1_scalarMul) (con integer 123) ]
(con bls12_381_G1_element 0xabd61864f519748032551e42e0ac417fd828f079454e3e3c9891c5c29ed7f10bdecc046854e3931cb7002779bd76d71f)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,14 @@
-- Scalar multiplication by the group size should give you the zero element of the group.
(program 1.0.0
[
[ (builtin bls12_381_G2_equal)
[
(builtin bls12_381_G2_scalarMul)
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513 )
(con bls12_381_G2_element 0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
(con bls12_381_G2_element
0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
]
)
@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,26 @@
-- Scalar multiplication should be periodic modulo the group size
(program
1.0.0
[
[
(builtin bls12_381_G2_equal)
[
[
(builtin bls12_381_G2_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
[
[ (builtin bls12_381_G2_scalarMul) (con integer 123) ]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,29 @@
-- Scalar multiplication should be periodic modulo the group size
(program
1.0.0
[
[
(builtin bls12_381_G2_equal)
[
[
(builtin bls12_381_G2_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
[
[ (builtin multiplyInteger) (con integer 987654321) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
[
[ (builtin bls12_381_G2_scalarMul) (con integer 123) ]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
@@ -0,0 +1,29 @@
-- Scalar multiplication should be periodic modulo the group size
(program
1.0.0
[
[
(builtin bls12_381_G2_equal)
[
[
(builtin bls12_381_G2_scalarMul)
[
[ (builtin addInteger) (con integer 123) ]
[
[ (builtin multiplyInteger) (con integer -987654321) ]
(con integer 52435875175126190479447740508185965837690552500527637822603658699938581184513)
]
]
]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
[
[ (builtin bls12_381_G2_scalarMul) (con integer 123) ]
(con bls12_381_G2_element
0xb0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1)
]
]
)

@@ -0,0 +1 @@
(program 1.0.0 (con bool True))

0 comments on commit 3d89f5d

Please sign in to comment.