@@ -72,6 +72,10 @@ type revocationPublicKey struct {
72
72
pubKey * ecdsa.PublicKey
73
73
}
74
74
75
+ func NewRevocationPublicKey (pubKey * ecdsa.PublicKey ) * revocationPublicKey {
76
+ return & revocationPublicKey {pubKey : pubKey }
77
+ }
78
+
75
79
// Bytes converts this key to its byte representation,
76
80
// if this operation is allowed.
77
81
func (k * revocationPublicKey ) Bytes () (raw []byte , err error ) {
@@ -120,7 +124,7 @@ type RevocationKeyGen struct {
120
124
Revocation Revocation
121
125
}
122
126
123
- func (g * RevocationKeyGen ) KeyGen (opts bccsp.KeyGenOpts ) (k bccsp.Key , err error ) {
127
+ func (g * RevocationKeyGen ) KeyGen (opts bccsp.KeyGenOpts ) (bccsp.Key , error ) {
124
128
// Create a new key pair
125
129
key , err := g .Revocation .NewKey ()
126
130
if err != nil {
@@ -129,3 +133,61 @@ func (g *RevocationKeyGen) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error
129
133
130
134
return & revocationSecretKey {exportable : g .Exportable , privKey : key }, nil
131
135
}
136
+
137
+ type CriSigner struct {
138
+ Revocation Revocation
139
+ }
140
+
141
+ func (s * CriSigner ) Sign (k bccsp.Key , digest []byte , opts bccsp.SignerOpts ) ([]byte , error ) {
142
+ revocationSecretKey , ok := k .(* revocationSecretKey )
143
+ if ! ok {
144
+ return nil , errors .New ("invalid key, expected *revocationSecretKey" )
145
+ }
146
+ criOpts , ok := opts .(* bccsp.IdemixCRISignerOpts )
147
+ if ! ok {
148
+ return nil , errors .New ("invalid options, expected *IdemixCRISignerOpts" )
149
+ }
150
+ if len (digest ) != 0 {
151
+ return nil , errors .New ("invalid digest, it must be empty" )
152
+ }
153
+
154
+ return s .Revocation .Sign (
155
+ revocationSecretKey .privKey ,
156
+ criOpts .UnrevokedHandles ,
157
+ criOpts .Epoch ,
158
+ criOpts .RevocationAlgorithm ,
159
+ )
160
+ }
161
+
162
+ type CriVerifier struct {
163
+ Revocation Revocation
164
+ }
165
+
166
+ func (v * CriVerifier ) Verify (k bccsp.Key , signature , digest []byte , opts bccsp.SignerOpts ) (bool , error ) {
167
+ revocationPublicKey , ok := k .(* revocationPublicKey )
168
+ if ! ok {
169
+ return false , errors .New ("invalid key, expected *revocationPublicKey" )
170
+ }
171
+ criOpts , ok := opts .(* bccsp.IdemixCRISignerOpts )
172
+ if ! ok {
173
+ return false , errors .New ("invalid options, expected *IdemixCRISignerOpts" )
174
+ }
175
+ if len (digest ) != 0 {
176
+ return false , errors .New ("invalid digest, it must be empty" )
177
+ }
178
+ if len (signature ) == 0 {
179
+ return false , errors .New ("invalid signature, it must not be empty" )
180
+ }
181
+
182
+ err := v .Revocation .Verify (
183
+ revocationPublicKey .pubKey ,
184
+ signature ,
185
+ criOpts .Epoch ,
186
+ criOpts .RevocationAlgorithm ,
187
+ )
188
+ if err != nil {
189
+ return false , err
190
+ }
191
+
192
+ return true , nil
193
+ }
0 commit comments