@@ -199,17 +199,27 @@ impl KeyRegWrapper {
199
199
opcert
200
200
. validate ( )
201
201
. map_err ( |_| ProtocolRegistrationErrorWrapper :: OpCertInvalid ) ?;
202
- kes_sig
203
- . ok_or ( ProtocolRegistrationErrorWrapper :: KesSignatureMissing ) ?
204
- . verify (
205
- kes_period. ok_or ( ProtocolRegistrationErrorWrapper :: KesPeriodMissing ) ?,
206
- & opcert. kes_vk ,
207
- & pk. to_bytes ( ) ,
208
- )
209
- . map_err ( |_| ProtocolRegistrationErrorWrapper :: KesSignatureInvalid ) ?;
210
- opcert
211
- . compute_protocol_party_id ( )
212
- . map_err ( |_| ProtocolRegistrationErrorWrapper :: PoolAddressEncoding ) ?
202
+ // TODO: List of eligible indices to be defined by CurrentKesPeriod and StartKesPeriod
203
+ let mut pool_id = None ;
204
+ let sig = kes_sig. ok_or ( ProtocolRegistrationErrorWrapper :: KesSignatureMissing ) ?;
205
+ for kes_period_try in 0 ..64 {
206
+ if sig
207
+ . verify ( kes_period_try, & opcert. kes_vk , & pk. to_bytes ( ) )
208
+ . is_ok ( )
209
+ {
210
+ println ! (
211
+ "WARNING: KES Signature verified for TryKesPeriod={}, CurrentKesPeriod={:?}, and StartKesPeriod={}" ,
212
+ kes_period_try, kes_period, & opcert. start_kes_period
213
+ ) ;
214
+ pool_id = Some (
215
+ opcert
216
+ . compute_protocol_party_id ( )
217
+ . map_err ( |_| ProtocolRegistrationErrorWrapper :: PoolAddressEncoding ) ?,
218
+ ) ;
219
+ break ;
220
+ }
221
+ }
222
+ pool_id. ok_or ( ProtocolRegistrationErrorWrapper :: KesSignatureInvalid ) ?
213
223
} else {
214
224
println ! ( "WARNING: Signer certification is skipped! {:?}" , party_id) ;
215
225
party_id. ok_or ( ProtocolRegistrationErrorWrapper :: PartyIdMissing ) ?
@@ -221,7 +231,6 @@ impl KeyRegWrapper {
221
231
. map_err ( ProtocolRegistrationErrorWrapper :: CoreRegister ) ?;
222
232
return Ok ( pool_id_bech32) ;
223
233
}
224
-
225
234
Err ( ProtocolRegistrationErrorWrapper :: PartyIdNonExisting )
226
235
}
227
236
0 commit comments