2
2
3
3
use crate :: { Error , Result } ;
4
4
5
- #[ cfg( feature = "signing " ) ]
5
+ #[ cfg( feature = "signature " ) ]
6
6
use {
7
- crate :: { SigningKey , hazmat:: sign_prehashed_rfc6979} ,
8
- elliptic_curve:: { FieldBytes , subtle:: CtOption } ,
9
- signature:: {
10
- DigestSigner , MultipartSigner , RandomizedDigestSigner , Signer ,
11
- digest:: { FixedOutput , Update } ,
12
- hazmat:: { PrehashSigner , RandomizedPrehashSigner } ,
13
- rand_core:: TryCryptoRng ,
7
+ crate :: {
8
+ EcdsaCurve , Signature , SignatureSize , SigningKey , VerifyingKey ,
9
+ hazmat:: { DigestAlgorithm , bits2field, sign_prehashed_rfc6979, verify_prehashed} ,
14
10
} ,
15
- } ;
16
-
17
- #[ cfg( feature = "verifying" ) ]
18
- use {
19
- crate :: { VerifyingKey , hazmat:: verify_prehashed} ,
20
11
elliptic_curve:: {
21
12
AffinePoint , FieldBytesEncoding , FieldBytesSize , Group , PrimeField , ProjectivePoint ,
22
13
bigint:: CheckedAdd ,
23
14
ops:: { LinearCombination , Reduce } ,
24
15
point:: DecompressPoint ,
25
16
sec1:: { self , FromEncodedPoint , ToEncodedPoint } ,
26
17
} ,
27
- } ;
28
-
29
- #[ cfg( any( feature = "signing" , feature = "verifying" ) ) ]
30
- use {
31
- crate :: {
32
- EcdsaCurve , Signature , SignatureSize ,
33
- hazmat:: { DigestAlgorithm , bits2field} ,
18
+ elliptic_curve:: {
19
+ CurveArithmetic , FieldBytes , Scalar , array:: ArraySize , ops:: Invert , subtle:: CtOption ,
20
+ } ,
21
+ rfc6979:: hmac:: EagerHash ,
22
+ signature:: {
23
+ DigestSigner , MultipartSigner , RandomizedDigestSigner , Signer ,
24
+ digest:: Digest ,
25
+ hazmat:: { PrehashSigner , RandomizedPrehashSigner } ,
26
+ rand_core:: TryCryptoRng ,
34
27
} ,
35
- elliptic_curve:: { CurveArithmetic , Scalar , array:: ArraySize , ops:: Invert } ,
36
- signature:: digest:: Digest ,
37
28
} ;
38
29
39
30
/// Recovery IDs, a.k.a. "recid".
@@ -89,7 +80,7 @@ impl RecoveryId {
89
80
}
90
81
}
91
82
92
- #[ cfg( feature = "verifying " ) ]
83
+ #[ cfg( feature = "signature " ) ]
93
84
impl RecoveryId {
94
85
/// Given a public key, message, and signature, use trial recovery
95
86
/// to determine if a suitable recovery ID exists, or return an error
@@ -118,7 +109,7 @@ impl RecoveryId {
118
109
) -> Result < Self >
119
110
where
120
111
C : EcdsaCurve + CurveArithmetic ,
121
- D : Digest ,
112
+ D : EagerHash ,
122
113
AffinePoint < C > : DecompressPoint < C > + FromEncodedPoint < C > + ToEncodedPoint < C > ,
123
114
FieldBytesSize < C > : sec1:: ModulusSize ,
124
115
SignatureSize < C > : ArraySize ,
@@ -176,7 +167,7 @@ impl From<RecoveryId> for u8 {
176
167
}
177
168
}
178
169
179
- #[ cfg( feature = "signing " ) ]
170
+ #[ cfg( feature = "signature " ) ]
180
171
impl < C > SigningKey < C >
181
172
where
182
173
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
@@ -213,7 +204,7 @@ where
213
204
/// Sign the given message digest, returning a signature and recovery ID.
214
205
pub fn sign_digest_recoverable < D > ( & self , msg_digest : D ) -> Result < ( Signature < C > , RecoveryId ) >
215
206
where
216
- D : Digest ,
207
+ D : EagerHash ,
217
208
{
218
209
self . sign_prehash_recoverable ( & msg_digest. finalize ( ) )
219
210
}
@@ -225,11 +216,11 @@ where
225
216
}
226
217
}
227
218
228
- #[ cfg( feature = "signing " ) ]
219
+ #[ cfg( feature = "signature " ) ]
229
220
impl < C , D > DigestSigner < D , ( Signature < C > , RecoveryId ) > for SigningKey < C >
230
221
where
231
222
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
232
- D : Digest + Update ,
223
+ D : EagerHash + digest :: Update ,
233
224
Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
234
225
SignatureSize < C > : ArraySize ,
235
226
{
@@ -243,7 +234,7 @@ where
243
234
}
244
235
}
245
236
246
- #[ cfg( feature = "signing " ) ]
237
+ #[ cfg( feature = "signature " ) ]
247
238
impl < C > RandomizedPrehashSigner < ( Signature < C > , RecoveryId ) > for SigningKey < C >
248
239
where
249
240
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
@@ -259,11 +250,11 @@ where
259
250
}
260
251
}
261
252
262
- #[ cfg( feature = "signing " ) ]
253
+ #[ cfg( feature = "signature " ) ]
263
254
impl < C , D > RandomizedDigestSigner < D , ( Signature < C > , RecoveryId ) > for SigningKey < C >
264
255
where
265
256
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
266
- D : Digest + FixedOutput ,
257
+ D : EagerHash + digest :: Update ,
267
258
Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
268
259
SignatureSize < C > : ArraySize ,
269
260
{
@@ -274,11 +265,11 @@ where
274
265
) -> Result < ( Signature < C > , RecoveryId ) > {
275
266
let mut digest = D :: new ( ) ;
276
267
f ( & mut digest) ?;
277
- self . sign_prehash_with_rng ( rng, & digest. finalize_fixed ( ) )
268
+ self . sign_prehash_with_rng ( rng, & digest. finalize ( ) )
278
269
}
279
270
}
280
271
281
- #[ cfg( feature = "signing " ) ]
272
+ #[ cfg( feature = "signature " ) ]
282
273
impl < C > PrehashSigner < ( Signature < C > , RecoveryId ) > for SigningKey < C >
283
274
where
284
275
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
@@ -290,7 +281,7 @@ where
290
281
}
291
282
}
292
283
293
- #[ cfg( feature = "signing " ) ]
284
+ #[ cfg( feature = "signature " ) ]
294
285
impl < C > Signer < ( Signature < C > , RecoveryId ) > for SigningKey < C >
295
286
where
296
287
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
@@ -302,7 +293,7 @@ where
302
293
}
303
294
}
304
295
305
- #[ cfg( feature = "signing " ) ]
296
+ #[ cfg( feature = "signature " ) ]
306
297
impl < C > MultipartSigner < ( Signature < C > , RecoveryId ) > for SigningKey < C >
307
298
where
308
299
C : EcdsaCurve + CurveArithmetic + DigestAlgorithm ,
@@ -311,13 +302,12 @@ where
311
302
{
312
303
fn try_multipart_sign ( & self , msg : & [ & [ u8 ] ] ) -> Result < ( Signature < C > , RecoveryId ) > {
313
304
let mut digest = C :: Digest :: new ( ) ;
314
- msg. iter ( )
315
- . for_each ( |slice| Digest :: update ( & mut digest, slice) ) ;
305
+ msg. iter ( ) . for_each ( |slice| digest. update ( slice) ) ;
316
306
self . sign_digest_recoverable ( digest)
317
307
}
318
308
}
319
309
320
- #[ cfg( feature = "verifying " ) ]
310
+ #[ cfg( feature = "signature " ) ]
321
311
impl < C > VerifyingKey < C >
322
312
where
323
313
C : EcdsaCurve + CurveArithmetic ,
@@ -348,7 +338,7 @@ where
348
338
recovery_id : RecoveryId ,
349
339
) -> Result < Self >
350
340
where
351
- D : Digest ,
341
+ D : EagerHash ,
352
342
{
353
343
Self :: recover_from_prehash ( & msg_digest. finalize ( ) , signature, recovery_id)
354
344
}
0 commit comments