forked from vuvuzela/vuvuzela
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noise_test.go
54 lines (46 loc) · 942 Bytes
/
noise_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 vuvuzela
import (
"crypto/rand"
"flag"
"os"
"runtime"
"testing"
"golang.org/x/crypto/nacl/box"
)
var mu = 100000
const numKeys = 2
func BenchmarkFillWithFakeSingles(b *testing.B) {
noise := make([][]byte, mu)
keys := genKeys(numKeys)
nonce := new([24]byte)
b.ResetTimer()
for i := 0; i < b.N; i++ {
FillWithFakeSingles(noise, nonce, keys)
}
}
func BenchmarkFillWithFakeDoubles(b *testing.B) {
noise := make([][]byte, mu)
keys := genKeys(numKeys)
nonce := new([24]byte)
b.ResetTimer()
for i := 0; i < b.N; i++ {
FillWithFakeDoubles(noise, nonce, keys)
}
}
func TestMain(m *testing.M) {
runtime.GOMAXPROCS(runtime.NumCPU())
flag.IntVar(&mu, "mu", 100000, "mu value")
flag.Parse()
os.Exit(m.Run())
}
func genKeys(i int) []*[32]byte {
keys := make([]*[32]byte, i)
for i := range keys {
pub, _, err := box.GenerateKey(rand.Reader)
if err != nil {
panic(err)
}
keys[i] = pub
}
return keys
}