-
Notifications
You must be signed in to change notification settings - Fork 25
/
elgamal.go
64 lines (50 loc) · 886 Bytes
/
elgamal.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
package elgamal
import (
"hash"
"crypto/sha256"
"github.com/deatil/go-cryptobin/elgamal"
)
type (
// HashFunc
HashFunc = func() hash.Hash
)
/**
* EIGamal
*
* @create 2023-6-22
* @author deatil
*/
type EIGamal struct {
// 私钥
privateKey *elgamal.PrivateKey
// 公钥
publicKey *elgamal.PublicKey
// 签名验证类型
signHash HashFunc
// [私钥/公钥]数据
keyData []byte
// 传入数据
data []byte
// 解析后的数据
parsedData []byte
// 验证结果
verify bool
// 错误
Errors []error
}
// 构造函数
func NewEIGamal() EIGamal {
return EIGamal{
signHash: sha256.New,
verify: false,
Errors: make([]error, 0),
}
}
// 构造函数
func New() EIGamal {
return NewEIGamal()
}
var (
// 默认
defaultEIGamal = NewEIGamal()
)