blob: d95d5fae926017a4e88c8a669fbde2687718730c (
plain)
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
55
56
57
58
59
60
61
62
63
64
|
package types
import (
"crypto"
"crypto/ed25519"
"crypto/rand"
"io"
"testing"
)
type testSigner struct {
PublicKey PublicKey
Signature Signature
Error error
}
func (ts *testSigner) Public() crypto.PublicKey {
return ed25519.PublicKey(ts.PublicKey[:])
}
func (ts *testSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
return ts.Signature[:], ts.Error
}
func newKeyPair(t *testing.T) (crypto.Signer, PublicKey) {
vk, sk, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
t.Fatal(err)
}
var pub PublicKey
copy(pub[:], vk[:])
return sk, pub
}
func newHashBufferInc(t *testing.T) *Hash {
t.Helper()
var buf Hash
for i := 0; i < len(buf); i++ {
buf[i] = byte(i)
}
return &buf
}
func newSigBufferInc(t *testing.T) *Signature {
t.Helper()
var buf Signature
for i := 0; i < len(buf); i++ {
buf[i] = byte(i)
}
return &buf
}
func newPubBufferInc(t *testing.T) *PublicKey {
t.Helper()
var buf PublicKey
for i := 0; i < len(buf); i++ {
buf[i] = byte(i)
}
return &buf
}
|