forked from cloudflare/bn256
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash_test.go
54 lines (45 loc) · 3.97 KB
/
hash_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package bn256
import (
"testing"
"bytes"
)
func TestKnownHashes(t *testing.T) {
for i, mh := range marshaledHashes {
g := HashG1([]byte{byte(i)}, nil)
if !bytes.Equal(mh[:], g.Marshal()) {
t.Fatal("hash doesn't match a known value")
}
}
}
var buf = make([]byte, 8192)
func benchmarkSize(b *testing.B, size int) {
b.SetBytes(int64(size))
for i := 0; i < b.N; i++ {
HashG1(buf[:size], nil)
}
}
func BenchmarkHashG1Size8bytes(b *testing.B) {
b.ResetTimer()
benchmarkSize(b, 8)
}
func BenchmarkHashG1Size1k(b *testing.B) {
b.ResetTimer()
benchmarkSize(b, 1024)
}
func BenchmarkHashG1Size8k(b *testing.B) {
b.ResetTimer()
benchmarkSize(b, 8192)
}
var marshaledHashes = [11][64]byte{
[64]byte{80, 233, 64, 52, 60, 233, 95, 49, 57, 115, 89, 101, 189, 182, 251, 43, 158, 186, 22, 10, 130, 128, 127, 143, 10, 158, 148, 102, 148, 86, 194, 111, 98, 232, 82, 178, 190, 193, 65, 1, 58, 126, 154, 37, 11, 185, 207, 250, 219, 202, 140, 196, 2, 35, 223, 87, 13, 60, 204, 201, 34, 231, 118, 206},
[64]byte{123, 250, 39, 222, 32, 210, 254, 221, 94, 5, 32, 6, 19, 120, 252, 162, 110, 53, 149, 185, 209, 83, 189, 194, 77, 40, 160, 168, 17, 143, 13, 121, 72, 31, 247, 190, 150, 8, 159, 57, 145, 45, 129, 145, 164, 29, 156, 159, 182, 177, 142, 145, 38, 236, 98, 84, 157, 8, 164, 38, 123, 73, 215, 23},
[64]byte{129, 78, 244, 19, 205, 198, 70, 100, 63, 152, 218, 52, 132, 20, 180, 241, 223, 109, 93, 80, 59, 6, 16, 183, 99, 5, 202, 77, 136, 165, 254, 32, 124, 242, 44, 52, 28, 76, 54, 116, 113, 243, 51, 101, 114, 70, 190, 124, 81, 194, 77, 8, 163, 135, 148, 175, 224, 248, 184, 44, 167, 124, 10, 30},
[64]byte{113, 140, 119, 103, 41, 163, 49, 69, 93, 208, 11, 126, 85, 100, 1, 11, 151, 207, 202, 144, 7, 154, 203, 84, 123, 255, 67, 107, 189, 188, 93, 14, 131, 167, 214, 27, 85, 82, 122, 220, 131, 237, 192, 206, 159, 132, 216, 254, 227, 52, 232, 216, 182, 154, 170, 46, 99, 78, 137, 79, 90, 30, 236, 16},
[64]byte{128, 205, 34, 132, 54, 241, 30, 185, 253, 248, 45, 227, 78, 202, 148, 137, 224, 86, 199, 253, 98, 156, 169, 132, 129, 141, 118, 247, 102, 200, 47, 231, 62, 4, 169, 180, 190, 184, 212, 40, 88, 118, 134, 129, 149, 108, 105, 153, 54, 153, 40, 159, 189, 245, 63, 172, 43, 49, 22, 246, 154, 57, 63, 57},
[64]byte{44, 243, 231, 191, 3, 107, 182, 73, 39, 43, 51, 20, 25, 235, 151, 112, 207, 24, 28, 96, 201, 60, 175, 210, 179, 42, 117, 101, 16, 196, 82, 238, 126, 198, 61, 68, 228, 96, 166, 130, 139, 167, 181, 195, 46, 10, 51, 83, 59, 165, 249, 111, 205, 113, 80, 43, 240, 194, 72, 240, 64, 235, 120, 34},
[64]byte{125, 159, 122, 73, 206, 48, 230, 111, 229, 18, 224, 100, 101, 149, 116, 190, 47, 116, 78, 156, 94, 87, 164, 157, 156, 211, 110, 229, 191, 250, 213, 83, 139, 111, 120, 241, 26, 131, 125, 200, 87, 166, 76, 136, 241, 37, 113, 44, 200, 158, 236, 122, 0, 33, 172, 198, 242, 255, 33, 101, 142, 245, 180, 243},
[64]byte{130, 99, 125, 203, 106, 197, 191, 151, 248, 98, 27, 76, 200, 122, 173, 139, 129, 31, 54, 51, 206, 49, 122, 51, 57, 88, 139, 191, 42, 22, 158, 125, 100, 87, 23, 89, 148, 160, 5, 224, 46, 35, 217, 254, 28, 247, 86, 227, 186, 200, 3, 206, 50, 134, 14, 193, 23, 58, 2, 161, 52, 1, 201, 136},
[64]byte{76, 28, 164, 59, 70, 75, 165, 57, 131, 109, 238, 103, 17, 89, 191, 194, 78, 248, 115, 8, 108, 206, 46, 235, 52, 219, 98, 231, 194, 252, 229, 98, 55, 45, 194, 177, 115, 176, 207, 167, 174, 12, 94, 199, 63, 175, 214, 137, 190, 168, 67, 247, 107, 64, 169, 74, 250, 174, 177, 141, 93, 207, 71, 147},
[64]byte{45, 115, 123, 118, 162, 144, 82, 134, 198, 17, 162, 200, 91, 168, 191, 115, 31, 66, 81, 201, 111, 250, 133, 16, 247, 62, 92, 251, 227, 234, 116, 183, 16, 117, 103, 177, 94, 201, 169, 155, 59, 218, 174, 242, 28, 66, 171, 113, 245, 247, 98, 236, 193, 26, 85, 62, 215, 101, 229, 214, 191, 153, 176, 168},
[64]byte{143, 123, 127, 149, 167, 27, 159, 25, 254, 211, 196, 88, 17, 185, 138, 237, 62, 140, 84, 177, 134, 58, 193, 141, 25, 152, 79, 6, 41, 39, 248, 117, 52, 208, 167, 215, 212, 60, 250, 228, 1, 232, 111, 254, 154, 18, 209, 55, 207, 200, 68, 60, 163, 106, 59, 27, 12, 72, 130, 141, 182, 103, 16, 80},
}