@@ -404,8 +404,13 @@ impl<H: Digest<OutputSize = U32> + Clone, NG: AddTag> Frost<H, NG> {
404
404
. ok_or ( NewKeyGenError :: ZeroFrostKey ) ?
405
405
. into_point_with_even_y ( ) ;
406
406
407
- // TODO set keygen id
408
- let keygen_id = Scalar :: from_hash ( self . keygen_id_hash . clone ( ) . add ( joint_public_key) ) ;
407
+ let mut keygen_hash = self . keygen_id_hash . clone ( ) ;
408
+ for poly in point_polys. clone ( ) {
409
+ for point in poly. 0 . iter ( ) {
410
+ keygen_hash = keygen_hash. add ( point) ;
411
+ }
412
+ }
413
+ let keygen_id = Scalar :: from_hash ( keygen_hash) ;
409
414
410
415
let verification_shares = ( 1 ..=point_polys. len ( ) )
411
416
. map ( |i| joint_poly. eval ( i as u32 ) . normalize ( ) . mark :: < NonZero > ( ) )
@@ -672,13 +677,14 @@ impl<H: Digest<OutputSize = U32> + Clone, NG: NonceGen + AddTag> Frost<H, NG> {
672
677
impl < H : Digest < OutputSize = U32 > + Clone , NG : NonceGen + AddTag > Frost < H , NG > {
673
678
/// Generate nonces for secret shares
674
679
///
675
- /// It is very important to carefully consider the implications of your choice of underlying
676
- /// [`NonceGen`].
680
+ /// It is very important that you use a unique `sid` for this signing session and to also carefully
681
+ /// consider the implications of your choice of underlying [`NonceGen`].
677
682
///
678
- /// If you are generating nonces prior to KeyGen completion, use the static first coefficient
679
- /// for your `secret`. Otherwise you can use your secret share of the joint FROST key.
683
+ /// When choosing a `secret` to use, if you are generating nonces prior to KeyGen completion,
684
+ /// use the static first coefficient of your polynomial.
685
+ /// Otherwise you can use your secret share of the joint FROST key.
680
686
///
681
- /// The application must decide upon a unique `sid` (session id) for this FROST multisignature.
687
+ /// The application must decide upon a unique `sid` for this FROST multisignature.
682
688
/// For example, the concatenation of: my_signing_index, joint_key, verfication_shares
683
689
///
684
690
/// ## Return Value
@@ -799,8 +805,19 @@ mod test {
799
805
if signer_indexes. len( ) < threshold as usize {
800
806
dbg!( "pseudorandomly chose less signers than threshold.. skipping" ) ;
801
807
} else {
802
- let sid = frost_keys[ 0 ] . joint_public_key. to_bytes( ) ;
803
- let nonces: Vec <NonceKeyPair > = signer_indexes. iter( ) . map( |i| frost. gen_nonce( & secret_shares[ * i as usize ] , & sid) ) . collect( ) ;
808
+ let verification_shares_bytes: Vec <_> = frost_keys[ signer_indexes[ 0 ] ]
809
+ . verification_shares
810
+ . iter( )
811
+ . map( |share| share. to_bytes( ) )
812
+ . collect( ) ;
813
+
814
+ let sid = [
815
+ frost_keys[ signer_indexes[ 0 ] ] . joint_public_key. to_bytes( ) . as_slice( ) ,
816
+ verification_shares_bytes. concat( ) . as_slice( ) ,
817
+ b"frost-prop-test" . as_slice( ) ,
818
+ ]
819
+ . concat( ) ;
820
+ let nonces: Vec <NonceKeyPair > = signer_indexes. iter( ) . map( |i| frost. gen_nonce( & secret_shares[ * i as usize ] , & [ sid. as_slice( ) , [ * i as u8 ] . as_slice( ) ] . concat( ) ) ) . collect( ) ;
804
821
// dbg!(&nonces);
805
822
806
823
let mut recieved_nonces: Vec <_> = vec![ ] ;
@@ -913,15 +930,31 @@ mod test {
913
930
jk2 = jk2. tweak ( tweak. clone ( ) ) . expect ( "tweak worked" ) ;
914
931
jk3 = jk3. tweak ( tweak) . expect ( "tweak worked" ) ;
915
932
916
- // TODO USE PROPER SID
917
- // public => [ b"r2-frost", my_index.to_be_bytes(), frost_key.joint_public_key, &frost_key.verification_shares[..], sid]
918
- let sid = frost_key. joint_public_key . to_bytes ( ) ;
919
- // for share in frost_key.verification_shares {
920
- // // [sid, share].concat(share.to_bytes());
921
- // }
933
+ let verification_shares_bytes: Vec < _ > = frost_key
934
+ . verification_shares
935
+ . iter ( )
936
+ . map ( |share| share. to_bytes ( ) )
937
+ . collect ( ) ;
922
938
923
- let nonce1 = frost. gen_nonce ( & secret_share1, & sid) ;
924
- let nonce3 = frost. gen_nonce ( & secret_share3, & sid) ;
939
+ // Create unique session IDs for these signing sessions
940
+ let sid1 = [
941
+ frost_key. joint_public_key . to_bytes ( ) . as_slice ( ) ,
942
+ verification_shares_bytes. concat ( ) . as_slice ( ) ,
943
+ b"frost-end-to-end-test-1" . as_slice ( ) ,
944
+ b"0" . as_slice ( ) ,
945
+ ]
946
+ . concat ( ) ;
947
+
948
+ let sid2 = [
949
+ frost_key. joint_public_key . to_bytes ( ) . as_slice ( ) ,
950
+ verification_shares_bytes. concat ( ) . as_slice ( ) ,
951
+ b"frost-end-to-end-test-2" . as_slice ( ) ,
952
+ b"2" . as_slice ( ) ,
953
+ ]
954
+ . concat ( ) ;
955
+
956
+ let nonce1 = frost. gen_nonce ( & secret_share1, & sid1) ;
957
+ let nonce3 = frost. gen_nonce ( & secret_share3, & sid2) ;
925
958
let nonces = vec ! [ ( 0 , nonce1. public( ) ) , ( 2 , nonce3. public( ) ) ] ;
926
959
let nonces2 = vec ! [ ( 0 , nonce1. public( ) ) , ( 2 , nonce3. public( ) ) ] ;
927
960
0 commit comments