-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathno_cgo.go
More file actions
195 lines (153 loc) · 5.4 KB
/
Copy pathno_cgo.go
File metadata and controls
195 lines (153 loc) · 5.4 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
195
//go:build !cgo && no_cgo
// +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"
"github.com/onflow/crypto/sign"
)
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 sign.SigningAlgorithm
}
func (a *blsBLS12381Algo) GeneratePrivateKey(ikm []byte) (sign.PrivateKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) DecodePrivateKey(privateKeyBytes []byte) (sign.PrivateKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) DecodePublicKey(publicKeyBytes []byte) (sign.PublicKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) DecodePublicKeyCompressed(publicKeyBytes []byte) (sign.PublicKey, error) {
panic(withFeature("BLS signature"))
}
func (a *blsBLS12381Algo) SignatureFormatCheck(sig sign.Signature) (bool, error) {
panic(withFeature("BLS signature"))
}
func NewExpandMsgXOFKMAC128(domainTag string) hash.Hasher {
panic(withFeature("BLS hasher"))
}
func IsBLSSignatureIdentity(s sign.Signature) bool {
panic(withFeature("BLS signature"))
}
func BLSInvalidSignature() sign.Signature {
panic(withFeature("BLS signature"))
}
func NewBLSThresholdSignatureParticipant(
groupPublicKey sign.PublicKey,
sharePublicKeys []sign.PublicKey,
threshold int,
myIndex int,
myPrivateKey sign.PrivateKey,
message []byte,
dsTag string,
) (ThresholdSignatureParticipant, error) {
panic(withFeature("BLS threshold signature"))
}
func NewBLSThresholdSignatureInspector(
groupPublicKey sign.PublicKey,
sharePublicKeys []sign.PublicKey,
threshold int,
message []byte,
dsTag string,
) (ThresholdSignatureInspector, error) {
panic(withFeature("BLS threshold signature"))
}
func BLSReconstructThresholdSignature(size int, threshold int,
shares []sign.Signature, signers []int) (sign.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) ([]sign.PrivateKey,
[]sign.PublicKey, sign.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 sign.PrivateKey, data []byte, kmac hash.Hasher) (sign.Signature, error) {
panic(withFeature("BLS-SPoCK"))
}
func SPOCKVerifyAgainstData(pk sign.PublicKey, proof sign.Signature, data []byte, kmac hash.Hasher) (bool, error) {
panic(withFeature("BLS-SPoCK"))
}
func SPOCKVerify(pk1 sign.PublicKey, proof1 sign.Signature, pk2 sign.PublicKey, proof2 sign.Signature) (bool, error) {
panic(withFeature("BLS-SPoCK"))
}
func BLSGeneratePOP(sk sign.PrivateKey) (sign.Signature, error) {
panic(withFeature("BLS multi-sig"))
}
func BLSVerifyPOP(pk sign.PublicKey, s sign.Signature) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSSignatures(sigs []sign.Signature) (sign.Signature, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSPrivateKeys(keys []sign.PrivateKey) (sign.PrivateKey, error) {
panic(withFeature("BLS multi-sig"))
}
func AggregateBLSPublicKeys(keys []sign.PublicKey) (sign.PublicKey, error) {
panic(withFeature("BLS multi-sig"))
}
func IdentityBLSPublicKey() sign.PublicKey {
panic(withFeature("BLS multi-sig"))
}
func RemoveBLSPublicKeys(aggKey sign.PublicKey, keysToRemove []sign.PublicKey) (sign.PublicKey, error) {
panic(withFeature("BLS multi-sig"))
}
func VerifyBLSSignatureOneMessage(
pks []sign.PublicKey, s sign.Signature, message []byte, kmac hash.Hasher,
) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func VerifyBLSSignatureManyMessages(
pks []sign.PublicKey, s sign.Signature, messages [][]byte, kmac []hash.Hasher,
) (bool, error) {
panic(withFeature("BLS multi-sig"))
}
func BatchVerifyBLSSignaturesOneMessage(
pks []sign.PublicKey, sigs []sign.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"))
}