-
Notifications
You must be signed in to change notification settings - Fork 23
/
eddsa_helper.go
58 lines (46 loc) · 1013 Bytes
/
eddsa_helper.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
package eddsa
// 构造函数
func NewEdDSA() EdDSA {
return EdDSA{
verify: false,
Errors: make([]error, 0),
}
}
// 构造函数
func New() EdDSA {
return NewEdDSA()
}
// ==========
// 私钥
func FromPrivateKey(key []byte) EdDSA {
return NewEdDSA().FromPrivateKey(key)
}
// 私钥
func FromPrivateKeyWithPassword(key []byte, password string) EdDSA {
return NewEdDSA().FromPrivateKeyWithPassword(key, password)
}
// 公钥
func FromPublicKey(key []byte) EdDSA {
return NewEdDSA().FromPublicKey(key)
}
// 生成密钥
func GenerateKey() EdDSA {
return NewEdDSA().GenerateKey()
}
// ==========
// 字节
func FromBytes(data []byte) EdDSA {
return NewEdDSA().FromBytes(data)
}
// 字符
func FromString(data string) EdDSA {
return NewEdDSA().FromString(data)
}
// Base64
func FromBase64String(data string) EdDSA {
return NewEdDSA().FromBase64String(data)
}
// Hex
func FromHexString(data string) EdDSA {
return NewEdDSA().FromHexString(data)
}