-
Notifications
You must be signed in to change notification settings - Fork 24
/
eddsa.go
65 lines (52 loc) · 871 Bytes
/
eddsa.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
55
56
57
58
59
60
61
62
63
64
65
package eddsa
import (
"crypto"
"crypto/ed25519"
)
type (
// 设置
Options = ed25519.Options
)
/**
* EdDSA
*
* @create 2022-4-3
* @author deatil
*/
type EdDSA struct {
// 私钥
privateKey ed25519.PrivateKey
// 公钥
publicKey ed25519.PublicKey
// 设置
options *Options
// [私钥/公钥]数据
keyData []byte
// 传入数据
data []byte
// 解析后的数据
parsedData []byte
// 验证结果
verify bool
// 错误
Errors []error
}
// 构造函数
func NewEdDSA() EdDSA {
return EdDSA{
options: &Options{
Hash: crypto.Hash(0),
Context: "",
},
verify: false,
Errors: make([]error, 0),
}
}
// 构造函数
func New() EdDSA {
return NewEdDSA()
}
var (
// 默认
defaultEdDSA = NewEdDSA()
)