-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyMock.go
47 lines (37 loc) · 1.14 KB
/
keyMock.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
package mock
import (
"crypto/rand"
crypto "github.com/kalyan3104/k-crypto-core-go"
libp2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
)
// privateKeyMock implements common PrivateKey interface
type privateKeyMock struct {
privateKey libp2pCrypto.PrivKey
}
// NewPrivateKeyMock will create a new PrivateKeyMock instance
func NewPrivateKeyMock() *privateKeyMock {
privateKey, _, _ := libp2pCrypto.GenerateSecp256k1Key(rand.Reader)
return &privateKeyMock{
privateKey: privateKey,
}
}
// ToByteArray returns the byte array representation of the key
func (p *privateKeyMock) ToByteArray() ([]byte, error) {
return p.privateKey.Raw()
}
// GeneratePublic builds a public key for the current private key
func (p *privateKeyMock) GeneratePublic() crypto.PublicKey {
return nil
}
// Suite returns the suite used by this key
func (p *privateKeyMock) Suite() crypto.Suite {
return nil
}
// Scalar returns the Scalar corresponding to this Private Key
func (p *privateKeyMock) Scalar() crypto.Scalar {
return nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (p *privateKeyMock) IsInterfaceNil() bool {
return p == nil
}