@@ -7,9 +7,8 @@ use crate as frost;
7
7
use crate :: round2:: SignatureShare ;
8
8
use crate :: {
9
9
keys:: PublicKeyPackage , Error , Field , Group , Identifier , Signature , SigningKey , SigningPackage ,
10
- VerifyingKey ,
10
+ SigningTarget , VerifyingKey ,
11
11
} ;
12
- use alloc:: borrow:: ToOwned ;
13
12
use alloc:: vec:: Vec ;
14
13
use rand_core:: { CryptoRng , RngCore } ;
15
14
@@ -103,7 +102,8 @@ pub fn check_share_generation_fails_with_invalid_signers<C: Ciphersuite, R: RngC
103
102
/// Test FROST signing with trusted dealer with a Ciphersuite.
104
103
pub fn check_sign_with_dealer < C : Ciphersuite , R : RngCore + CryptoRng > (
105
104
mut rng : R ,
106
- ) -> ( Vec < u8 > , Signature < C > , VerifyingKey < C > ) {
105
+ signing_target : SigningTarget < C > ,
106
+ ) -> ( SigningTarget < C > , Signature < C > , VerifyingKey < C > ) {
107
107
////////////////////////////////////////////////////////////////////////////
108
108
// Key generation
109
109
////////////////////////////////////////////////////////////////////////////
@@ -147,10 +147,11 @@ pub fn check_sign_with_dealer<C: Ciphersuite, R: RngCore + CryptoRng>(
147
147
. collect ( ) ,
148
148
& mut rng,
149
149
pubkeys. clone ( ) ,
150
+ signing_target. clone ( ) ,
150
151
) ;
151
152
assert_eq ! ( r, Err ( Error :: InvalidSignature ) ) ;
152
153
153
- check_sign ( min_signers, key_packages, rng, pubkeys) . unwrap ( )
154
+ check_sign ( min_signers, key_packages, rng, pubkeys, signing_target ) . unwrap ( )
154
155
}
155
156
156
157
/// Test FROST signing with trusted dealer fails with invalid numbers of signers.
@@ -195,7 +196,8 @@ pub fn check_sign<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
195
196
key_packages : BTreeMap < frost:: Identifier < C > , frost:: keys:: KeyPackage < C > > ,
196
197
mut rng : R ,
197
198
pubkey_package : PublicKeyPackage < C > ,
198
- ) -> Result < ( Vec < u8 > , Signature < C > , VerifyingKey < C > ) , Error < C > > {
199
+ signing_target : SigningTarget < C > ,
200
+ ) -> Result < ( SigningTarget < C > , Signature < C > , VerifyingKey < C > ) , Error < C > > {
199
201
let mut nonces_map: BTreeMap < frost:: Identifier < C > , frost:: round1:: SigningNonces < C > > =
200
202
BTreeMap :: new ( ) ;
201
203
let mut commitments_map: BTreeMap < frost:: Identifier < C > , frost:: round1:: SigningCommitments < C > > =
@@ -223,8 +225,7 @@ pub fn check_sign<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
223
225
// - decide what message to sign
224
226
// - take one (unused) commitment per signing participant
225
227
let mut signature_shares = BTreeMap :: new ( ) ;
226
- let message = "message to sign" . as_bytes ( ) ;
227
- let signing_package = SigningPackage :: new ( commitments_map, message) ;
228
+ let signing_package = frost:: SigningPackage :: new ( commitments_map, signing_target. clone ( ) ) ;
228
229
229
230
////////////////////////////////////////////////////////////////////////////
230
231
// Round 2: each participant generates their signature share
@@ -266,11 +267,18 @@ pub fn check_sign<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
266
267
// Aggregate (also verifies the signature shares)
267
268
let group_signature = frost:: aggregate ( & signing_package, & signature_shares, & pubkey_package) ?;
268
269
270
+ // Check that the effective verifying key can be verified against the raw message,
271
+ // without exposing the SigningParameters.
272
+ pubkey_package
273
+ . verifying_key
274
+ . effective_key ( signing_target. sig_params ( ) )
275
+ . verify ( signing_target. message ( ) , & group_signature) ?;
276
+
269
277
// Check that the threshold signature can be verified by the group public
270
278
// key (the verification key).
271
279
pubkey_package
272
280
. verifying_key
273
- . verify ( message , & group_signature) ?;
281
+ . verify ( signing_target . clone ( ) , & group_signature) ?;
274
282
275
283
// Check that the threshold signature can be verified by the group public
276
284
// key (the verification key) from KeyPackage.verifying_key
@@ -279,11 +287,11 @@ pub fn check_sign<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
279
287
280
288
key_package
281
289
. verifying_key
282
- . verify ( message , & group_signature) ?;
290
+ . verify ( signing_target . clone ( ) , & group_signature) ?;
283
291
}
284
292
285
293
Ok ( (
286
- message . to_owned ( ) ,
294
+ signing_target ,
287
295
group_signature,
288
296
pubkey_package. verifying_key ,
289
297
) )
@@ -303,7 +311,7 @@ fn check_sign_errors<C: Ciphersuite + PartialEq>(
303
311
. find ( |& & id| id != key_package. identifier )
304
312
. unwrap ( ) ;
305
313
commitments. remove ( & id) ;
306
- let signing_package = frost:: SigningPackage :: new ( commitments, signing_package. message ( ) ) ;
314
+ let signing_package = frost:: SigningPackage :: new ( commitments, signing_package. sig_target ) ;
307
315
308
316
let r = frost:: round2:: sign ( & signing_package, & signing_nonces, & key_package) ;
309
317
assert_eq ! ( r, Err ( Error :: IncorrectNumberOfCommitments ) ) ;
@@ -376,7 +384,8 @@ fn check_aggregate_invalid_share_identifier_for_verifying_shares<C: Ciphersuite
376
384
/// Test FROST signing with DKG with a Ciphersuite.
377
385
pub fn check_sign_with_dkg < C : Ciphersuite + PartialEq , R : RngCore + CryptoRng > (
378
386
mut rng : R ,
379
- ) -> ( Vec < u8 > , Signature < C > , VerifyingKey < C > )
387
+ signing_target : SigningTarget < C > ,
388
+ ) -> ( SigningTarget < C > , Signature < C > , VerifyingKey < C > )
380
389
where
381
390
C :: Group : core:: cmp:: PartialEq ,
382
391
{
@@ -533,7 +542,7 @@ where
533
542
let pubkeys = frost:: keys:: PublicKeyPackage :: new ( verifying_keys, verifying_key. unwrap ( ) ) ;
534
543
535
544
// Proceed with the signing test.
536
- check_sign ( min_signers, key_packages, rng, pubkeys) . unwrap ( )
545
+ check_sign ( min_signers, key_packages, rng, pubkeys, signing_target ) . unwrap ( )
537
546
}
538
547
539
548
/// Check that calling dkg::part3() with distinct sets of participants fail.
@@ -577,7 +586,8 @@ fn check_part3_different_participants<C: Ciphersuite>(
577
586
/// Identifiers.
578
587
pub fn check_sign_with_dealer_and_identifiers < C : Ciphersuite , R : RngCore + CryptoRng > (
579
588
mut rng : R ,
580
- ) -> ( Vec < u8 > , Signature < C > , VerifyingKey < C > ) {
589
+ signing_target : SigningTarget < C > ,
590
+ ) -> ( SigningTarget < C > , Signature < C > , VerifyingKey < C > ) {
581
591
// Check error cases first
582
592
// Check repeated identifiers
583
593
@@ -643,7 +653,7 @@ pub fn check_sign_with_dealer_and_identifiers<C: Ciphersuite, R: RngCore + Crypt
643
653
let key_package = frost:: keys:: KeyPackage :: try_from ( v) . unwrap ( ) ;
644
654
key_packages. insert ( k, key_package) ;
645
655
}
646
- check_sign ( min_signers, key_packages, rng, pubkeys) . unwrap ( )
656
+ check_sign ( min_signers, key_packages, rng, pubkeys, signing_target ) . unwrap ( )
647
657
}
648
658
649
659
fn check_part2_error < C : Ciphersuite > (
0 commit comments