mithril_common/crypto_helper/cardano/kes/interface.rs
1use std::fmt::Debug;
2
3use kes_summed_ed25519::kes::Sum6KesSig;
4
5use crate::{
6 StdResult,
7 crypto_helper::{KesPeriod, OpCert},
8};
9
10/// Trait for KES (Key Evolving Signature) signing operation.
11#[cfg_attr(test, mockall::automock)]
12pub trait KesSigner: Send + Sync {
13 /// Return signed bytes with the KES secret key and the associated Operational Certificate
14 ///
15 /// current_kes_period: The KES period used to sign the message (absolute period computed from the chain at the moment of signature)
16 fn sign(
17 &self,
18 message: &[u8],
19 current_kes_period: KesPeriod,
20 ) -> StdResult<(Sum6KesSig, OpCert)>;
21}
22
23/// Trait for KES (Key Evolving Signature) verification operation.
24#[cfg_attr(test, mockall::automock)]
25pub trait KesVerifier: Send + Sync + Debug {
26 /// Verify the signed message and return the original message.
27 ///
28 /// kes_evolutions: The KES evolutions used to verify the signature (computed from the current KES period at the time of signing minus the start KES period in the operational certificate)
29 fn verify(
30 &self,
31 message: &[u8],
32 signature: &Sum6KesSig,
33 operational_certificate: &OpCert,
34 kes_evolutions: KesPeriod,
35 ) -> StdResult<()>;
36}