|
1 | 1 | use crate::{
|
2 |
| - crypto_helper::KESPeriod, |
| 2 | + crypto_helper::{KESPeriod, ProtocolOpCert, ProtocolSignerVerificationKeySignature}, |
3 | 3 | entities::{
|
4 | 4 | HexEncodedOpCert, HexEncodedVerificationKey, HexEncodedVerificationKeySignature, PartyId,
|
5 | 5 | SignerWithStake, Stake,
|
6 | 6 | },
|
7 | 7 | test_utils::fake_keys,
|
8 | 8 | StdResult,
|
9 | 9 | };
|
| 10 | +use anyhow::Context; |
10 | 11 | use serde::{Deserialize, Serialize};
|
11 | 12 | use std::fmt::{Debug, Formatter};
|
12 | 13 |
|
@@ -69,20 +70,26 @@ impl SignerWithStakeMessagePart {
|
69 | 70 | let mut signers: Vec<SignerWithStake> = Vec::new();
|
70 | 71 |
|
71 | 72 | for message in messages {
|
| 73 | + let verification_key_signature: Option<ProtocolSignerVerificationKeySignature> = message.verification_key_signature |
| 74 | + .map(|f| f.try_into()) |
| 75 | + .transpose() |
| 76 | + .with_context(|| format!("Error while parsing verification key signature message, party_id = '{}'", message.party_id))?; |
| 77 | + let operational_certificate: Option<ProtocolOpCert> = message |
| 78 | + .operational_certificate |
| 79 | + .map(|f| f.try_into()) |
| 80 | + .transpose() |
| 81 | + .with_context(|| { |
| 82 | + format!( |
| 83 | + "Error while parsing operational certificate message, party_id = '{}'.", |
| 84 | + message.party_id |
| 85 | + ) |
| 86 | + })?; |
72 | 87 | let value = SignerWithStake {
|
73 | 88 | party_id: message.party_id,
|
74 | 89 | verification_key: message.verification_key.try_into()?,
|
75 |
| - verification_key_signature: match message.verification_key_signature { |
76 |
| - Some(verification_key_signature) => { |
77 |
| - Some(verification_key_signature.try_into()?) |
78 |
| - } |
79 |
| - _ => None, |
80 |
| - }, |
| 90 | + verification_key_signature, |
81 | 91 | kes_period: message.kes_period,
|
82 |
| - operational_certificate: match message.operational_certificate { |
83 |
| - Some(operational_certificate) => Some(operational_certificate.try_into()?), |
84 |
| - _ => None, |
85 |
| - }, |
| 92 | + operational_certificate, |
86 | 93 | stake: message.stake,
|
87 | 94 | };
|
88 | 95 | signers.push(value);
|
|
0 commit comments