mithril_common/signable_builder/
interface.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use async_trait::async_trait;
use std::fmt::Debug;

use crate::{
    entities::{ProtocolMessage, ProtocolMessagePartValue},
    StdResult,
};

#[cfg(test)]
use mockall::automock;

/// Beacon trait
pub trait Beacon: Send + Sync {}

/// Artifact is a trait for types that represent signed artifacts
#[typetag::serde(tag = "type")]
pub trait Artifact: Debug + Send + Sync {
    /// Get artifact identifier
    fn get_id(&self) -> String;
}

/// SignableBuilder is a trait for building a protocol message for a beacon
#[cfg_attr(test, automock)]
#[async_trait]
pub trait SignableBuilder<U>: Send + Sync
where
    U: Beacon,
{
    /// Compute a protocol message
    async fn compute_protocol_message(&self, beacon: U) -> StdResult<ProtocolMessage>;
}

/// SignableSeedBuilder is a trait for building seed protocol message part values
#[cfg_attr(test, automock)]
#[async_trait]
pub trait SignableSeedBuilder: Send + Sync {
    /// Compute next aggregate verification key protocol message part value
    async fn compute_next_aggregate_verification_key(&self) -> StdResult<ProtocolMessagePartValue>;

    /// Compute next protocol parameters protocol message part value
    async fn compute_next_protocol_parameters(&self) -> StdResult<ProtocolMessagePartValue>;

    /// Compute current epoch protocol message part value
    async fn compute_current_epoch(&self) -> StdResult<ProtocolMessagePartValue>;
}