Skip to content

Commit 3f31c35

Browse files
authored
Merge pull request #549 from input-output-hk/ensemble/548-fix-signer-registration-kes-period
Fix KES signature verification
2 parents dd45b4e + 4fc2843 commit 3f31c35

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

mithril-common/src/crypto_helper/cardano/key_certification.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,27 @@ impl KeyRegWrapper {
199199
opcert
200200
.validate()
201201
.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)?
213223
} else {
214224
println!("WARNING: Signer certification is skipped! {:?}", party_id);
215225
party_id.ok_or(ProtocolRegistrationErrorWrapper::PartyIdMissing)?
@@ -221,7 +231,6 @@ impl KeyRegWrapper {
221231
.map_err(ProtocolRegistrationErrorWrapper::CoreRegister)?;
222232
return Ok(pool_id_bech32);
223233
}
224-
225234
Err(ProtocolRegistrationErrorWrapper::PartyIdNonExisting)
226235
}
227236

0 commit comments

Comments
 (0)