forked from onflow/crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno_cgo.go
More file actions
194 lines (153 loc) · 5.15 KB
/
no_cgo.go
File metadata and controls
194 lines (153 loc) · 5.15 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//go:build !cgo && no_cgo
package crypto
// This file enables the build of the library when cgo is disabled, i.e when the environment
// variable `CGO_ENABLED` is set to `0`.
// The build without cgo succeeds but disables all algorithms working with
// the BLS12-381 curve (BLS signature, BLS threshold signature, BLS-based DKG and BLS-SPoCK).
// Any call to any of these algorithms would panic.
import (
"fmt"
"github.com/onflow/crypto/hash"
)
const (
SignatureLenBLSBLS12381 = 0
PubKeyLenBLSBLS12381 = 0
PrKeyLenBLSBLS12381 = 0
)
func initBLS12381() {}
func withFeature(feature string) string {
return fmt.Sprintf("%s is only supported with cgo, rebuild with CGO_ENABLED=1\n", feature)
}
type blsBLS12381Algo struct {
algo SigningAlgorithm
}
// BLS context on the BLS 12-381 curve
var blsInstance *blsBLS12381Algo
func (a *blsBLS12381Algo) generatePrivateKey(ikm []byte) (PrivateKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) decodePrivateKey(privateKeyBytes []byte) (PrivateKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) decodePublicKey(publicKeyBytes []byte) (PublicKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) decodePublicKeyCompressed(publicKeyBytes []byte) (PublicKey, error) {
panic(withFeature("BLS signature"))
}
func NewExpandMsgXOFKMAC128(domainTag string) hash.Hasher {
panic(withFeature("BLS hasher"))
}
func IsBLSSignatureIdentity(s Signature) bool {
panic(withFeature("BLS signature"))
}
func BLSInvalidSignature() Signature {
panic(withFeature("BLS signature"))
}
func isG2Compressed() bool {
panic(withFeature("BLS12-381 curve"))
}
func NewBLSThresholdSignatureParticipant(
groupPublicKey PublicKey,
sharePublicKeys []PublicKey,
threshold int,
myIndex int,
myPrivateKey PrivateKey,
message []byte,
dsTag string,
) (ThresholdSignatureParticipant, error) {
panic(withFeature("BLS threshold signature"))
}
func NewBLSThresholdSignatureInspector(
groupPublicKey PublicKey,
sharePublicKeys []PublicKey,
threshold int,
message []byte,
dsTag string,
) (ThresholdSignatureInspector, error) {
panic(withFeature("BLS threshold signature"))
}
func BLSReconstructThresholdSignature(size int, threshold int,
shares []Signature, signers []int) (Signature, error) {
_ = duplicatedSignerErrorf("")
_ = notEnoughSharesErrorf("")
panic(withFeature("BLS threshold signature"))
}
func EnoughShares(threshold int, sharesNumber int) (bool, error) {
panic(withFeature("BLS threshold signature"))
}
func BLSThresholdKeyGen(size int, threshold int, seed []byte) ([]PrivateKey,
[]PublicKey, PublicKey, error) {
panic(withFeature("BLS threshold signature"))
}
func NewFeldmanVSS(size int, threshold int, myIndex int,
processor DKGProcessor, dealerIndex int) (DKGState, error) {
_, _ = newDKGCommon(size, threshold, myIndex,
processor, dealerIndex)
panic(withFeature("BLS-DKG"))
}
func NewFeldmanVSSQual(size int, threshold int, myIndex int,
processor DKGProcessor, dealerIndex int) (DKGState, error) {
_ = dkgFailureErrorf("")
_ = dkgInvalidStateTransitionErrorf("")
panic(withFeature("BLS-DKG"))
}
func NewJointFeldman(size int, threshold int, myIndex int,
processor DKGProcessor) (DKGState, error) {
_ = feldmanVSSShare | feldmanVSSVerifVec | feldmanVSSComplaint | feldmanVSSComplaintAnswer
panic(withFeature("BLS-DKG"))
}
func SPOCKProve(sk PrivateKey, data []byte, kmac hash.Hasher) (Signature, error) {
panic(withFeature("BLS-SPoCK"))
}
func SPOCKVerifyAgainstData(pk PublicKey, proof Signature, data []byte, kmac hash.Hasher) (bool, error) {
panic(withFeature("BLS-SPoCK"))
}
func SPOCKVerify(pk1 PublicKey, proof1 Signature, pk2 PublicKey, proof2 Signature) (bool, error) {
panic(withFeature("BLS-SPoCK"))
}
func BLSGeneratePOP(sk PrivateKey) (Signature, error) {
panic(withFeature("BLS multi-sig"))
}
func BLSVerifyPOP(pk PublicKey, s Signature) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSSignatures(sigs []Signature) (Signature, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSPrivateKeys(keys []PrivateKey) (PrivateKey, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSPublicKeys(keys []PublicKey) (PublicKey, error) {
panic(withFeature("BLS multi-sig"))
}
func IdentityBLSPublicKey() PublicKey {
panic(withFeature("BLS multi-sig"))
}
func RemoveBLSPublicKeys(aggKey PublicKey, keysToRemove []PublicKey) (PublicKey, error) {
panic(withFeature("BLS multi-sig"))
}
func VerifyBLSSignatureOneMessage(
pks []PublicKey, s Signature, message []byte, kmac hash.Hasher,
) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func VerifyBLSSignatureManyMessages(
pks []PublicKey, s Signature, messages [][]byte, kmac []hash.Hasher,
) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func BatchVerifyBLSSignaturesOneMessage(
pks []PublicKey, sigs []Signature, message []byte, kmac hash.Hasher,
) ([]bool, error) {
panic(withFeature("BLS multi-sig"))
}
func IsBLSAggregateEmptyListError(err error) bool {
panic(withFeature("BLS multi-sig"))
}
func IsNotBLSKeyError(err error) bool {
panic(withFeature("BLS multi-sig"))
}
func IsInvalidSignatureError(err error) bool {
panic(withFeature("BLS multi-sig"))
}