-
Notifications
You must be signed in to change notification settings - Fork 25
/
get.go
116 lines (87 loc) · 2.32 KB
/
get.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package ecdsa
import (
"crypto/ecdsa"
"crypto/elliptic"
"github.com/deatil/go-cryptobin/tool"
)
// 获取 PrivateKey
func (this ECDSA) GetPrivateKey() *ecdsa.PrivateKey {
return this.privateKey
}
// 获取 PrivateKeyCurve
func (this ECDSA) GetPrivateKeyCurve() elliptic.Curve {
return this.privateKey.Curve
}
// 获取 PrivateKeyD
func (this ECDSA) GetPrivateKeyDHexString() string {
data := this.privateKey.D
dataHex := tool.HexEncode(data.Bytes())
return dataHex
}
// 获取私钥明文
func (this ECDSA) GetPrivateKeyString() string {
return this.GetPrivateKeyDHexString()
}
// 获取 PublicKey
func (this ECDSA) GetPublicKey() *ecdsa.PublicKey {
return this.publicKey
}
// 获取 PublicKeyCurve
func (this ECDSA) GetPublicKeyCurve() elliptic.Curve {
return this.publicKey.Curve
}
// 获取 PublicKeyX
func (this ECDSA) GetPublicKeyXHexString() string {
data := this.publicKey.X
dataHex := tool.HexEncode(data.Bytes())
return dataHex
}
// 获取 PublicKeyY
func (this ECDSA) GetPublicKeyYHexString() string {
data := this.publicKey.Y
dataHex := tool.HexEncode(data.Bytes())
return dataHex
}
// 获取 PublicKeyXYHex
func (this ECDSA) GetPublicKeyXYHexString() string {
dataHex := this.GetPublicKeyXHexString() + this.GetPublicKeyYHexString()
return dataHex
}
// 获取未压缩公钥
func (this ECDSA) GetPublicKeyUncompressString() string {
key := elliptic.Marshal(this.publicKey.Curve, this.publicKey.X, this.publicKey.Y)
return tool.HexEncode(key)
}
// 获取压缩公钥
func (this ECDSA) GetPublicKeyCompressString() string {
key := elliptic.MarshalCompressed(this.publicKey.Curve, this.publicKey.X, this.publicKey.Y)
return tool.HexEncode(key)
}
// 获取 Curve
func (this ECDSA) GetCurve() elliptic.Curve {
return this.curve
}
// 获取 hash 类型
func (this ECDSA) GetSignHash() HashFunc {
return this.signHash
}
// 获取 keyData
func (this ECDSA) GetKeyData() []byte {
return this.keyData
}
// 获取 data
func (this ECDSA) GetData() []byte {
return this.data
}
// 获取 parsedData
func (this ECDSA) GetParsedData() []byte {
return this.parsedData
}
// 获取验证后情况
func (this ECDSA) GetVerify() bool {
return this.verify
}
// 获取错误
func (this ECDSA) GetErrors() []error {
return this.Errors
}