forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto.go
39 lines (28 loc) · 805 Bytes
/
crypto.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
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package crypto
import (
"github.com/haowang0402/avalanchego/ids"
)
type Factory interface {
NewPrivateKey() (PrivateKey, error)
ToPublicKey([]byte) (PublicKey, error)
ToPrivateKey([]byte) (PrivateKey, error)
}
type RecoverableFactory interface {
Factory
RecoverPublicKey(message, signature []byte) (PublicKey, error)
RecoverHashPublicKey(hash, signature []byte) (PublicKey, error)
}
type PublicKey interface {
Verify(message, signature []byte) bool
VerifyHash(hash, signature []byte) bool
Address() ids.ShortID
Bytes() []byte
}
type PrivateKey interface {
PublicKey() PublicKey
Sign(message []byte) ([]byte, error)
SignHash(hash []byte) ([]byte, error)
Bytes() []byte
}