-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Special squaring loop for use on elements in T_6(gfP2)
- Loading branch information
Showing
3 changed files
with
203 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package bn256 | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
) | ||
|
||
func TestGfP12SpecialSquare(t *testing.T) { | ||
in := gfP12Gen | ||
|
||
got := &gfP12{} | ||
expected := &gfP12{} | ||
|
||
got.SpecialSquare(in) | ||
expected.Square(in) | ||
|
||
if *got != *expected { | ||
t.Errorf("not same got=%v, expected=%v", got, expected) | ||
} | ||
} | ||
|
||
func TestGfp12SpecialPowV(t *testing.T) { | ||
in := gfP12Gen | ||
|
||
got := &gfP12{} | ||
expected := &gfP12{} | ||
|
||
got.SpecialPowV(in) | ||
expected.Exp(in, big.NewInt(1868033)) | ||
|
||
if *got != *expected { | ||
t.Errorf("not same got=%v, expected=%v", got, expected) | ||
} | ||
} | ||
|
||
func TestGfp12SpecialPowU(t *testing.T) { | ||
in := gfP12Gen | ||
|
||
got := &gfP12{} | ||
expected := &gfP12{} | ||
|
||
got.SpecialPowU(in) | ||
expected.Exp(in, u) | ||
|
||
if *got != *expected { | ||
t.Errorf("not same got=%v, expected=%v", got, expected) | ||
} | ||
} | ||
|
||
func BenchmarkGfp12Square(b *testing.B) { | ||
got := &gfP12{} | ||
b.ResetTimer() | ||
|
||
for i := 0; i < b.N; i++ { | ||
got.Square(gfP12Gen) | ||
} | ||
} | ||
|
||
func BenchmarkGfp12SpecialSquare(b *testing.B) { | ||
got := &gfP12{} | ||
b.ResetTimer() | ||
|
||
for i := 0; i < b.N; i++ { | ||
got.SpecialSquare(gfP12Gen) | ||
} | ||
} | ||
|
||
func BenchmarkGfp12ExpU(b *testing.B) { | ||
got := &gfP12{} | ||
b.ResetTimer() | ||
|
||
for i := 0; i < b.N; i++ { | ||
got.Exp(gfP12Gen, u) | ||
} | ||
} | ||
|
||
func BenchmarkGfp12SpecialPowU(b *testing.B) { | ||
got := &gfP12{} | ||
b.ResetTimer() | ||
|
||
for i := 0; i < b.N; i++ { | ||
got.SpecialPowU(gfP12Gen) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters