@@ -15,7 +15,8 @@ use std::{cmp::min, fs, sync::Arc};
15
15
16
16
use std:: { collections:: HashMap , path:: PathBuf } ;
17
17
18
- fn setup_temp_directory_for_signer (
18
+ /// Create or retrieve a temporary directory for storing cryptographic material for a signer, use this for tests only.
19
+ pub fn setup_temp_directory_for_signer (
19
20
party_id : & ProtocolPartyId ,
20
21
auto_create : bool ,
21
22
) -> Option < PathBuf > {
@@ -62,8 +63,11 @@ pub fn setup_signers(
62
63
let stake_distribution = ( 0 ..total)
63
64
. into_iter ( )
64
65
. map ( |party_idx| {
65
- let party_id = if party_idx % 2 == 0 {
66
- // 50% of signers with key certification
66
+ let party_id = if party_idx % 2 == 0
67
+ || cfg ! ( not( feature = "allow_uncertified_signer_registration" ) )
68
+ {
69
+ // 50% of signers with key certification if allow unverified signer registration
70
+ // Or 100% of signers otherwise
67
71
let keypair = ColdKeyGenerator :: create_deterministic_keypair ( [ party_idx as u8 ; 32 ] ) ;
68
72
let ( kes_secret_key, kes_verification_key) = Sum6Kes :: keygen ( & mut kes_keys_seed) ;
69
73
let operational_certificate = OpCert :: new ( kes_verification_key, 0 , 0 , keypair) ;
@@ -77,14 +81,15 @@ pub fn setup_signers(
77
81
. to_file ( temp_dir. join ( "kes.sk" ) )
78
82
. expect ( "KES secret key file export should not fail" ) ;
79
83
}
80
- if !temp_dir. join ( "pool .cert" ) . exists ( ) {
84
+ if !temp_dir. join ( "opcert .cert" ) . exists ( ) {
81
85
operational_certificate
82
- . to_file ( temp_dir. join ( "pool .cert" ) )
86
+ . to_file ( temp_dir. join ( "opcert .cert" ) )
83
87
. expect ( "operational certificate file export should not fail" ) ;
84
88
}
85
89
party_id
86
90
} else {
87
- // 50% of signers without key certification (legacy)
91
+ // 50% of signers without key certification (legacy) if allow unverified signer registration
92
+ // Or 0% of signers otherwise
88
93
// TODO: Should be removed once the signer certification is fully deployed
89
94
format ! ( "{:<032}" , party_idx)
90
95
} ;
@@ -132,7 +137,7 @@ pub fn setup_signers_from_stake_distribution(
132
137
. for_each ( |( party_id, _stake, protocol_initializer) | {
133
138
let temp_dir = setup_temp_directory_for_signer ( party_id, false ) ;
134
139
let operational_certificate = temp_dir. as_ref ( ) . map ( |dir| {
135
- OpCert :: from_file ( dir. join ( "pool .cert" ) )
140
+ OpCert :: from_file ( dir. join ( "opcert .cert" ) )
136
141
. expect ( "operational certificate decoding should not fail" )
137
142
} ) ;
138
143
let verification_key = protocol_initializer. verification_key ( ) ;
@@ -154,7 +159,7 @@ pub fn setup_signers_from_stake_distribution(
154
159
. map ( |( party_id, stake, protocol_initializer) | {
155
160
let temp_dir = setup_temp_directory_for_signer ( & party_id, false ) ;
156
161
let operational_certificate: Option < OpCert > = temp_dir. as_ref ( ) . map ( |dir| {
157
- OpCert :: from_file ( dir. join ( "pool .cert" ) )
162
+ OpCert :: from_file ( dir. join ( "opcert .cert" ) )
158
163
. expect ( "operational certificate decoding should not fail" )
159
164
} ) ;
160
165
let kes_period = 0 ;
0 commit comments