mithril_common/protocol/
mod.rs

1//! Protocol module
2//!
3//! This module contains types that standardize and make easier mithril protocol operations
4//! such as issuing single signatures, aggregating them as multi-signatures or computing
5//! aggregate verification keys.
6
7mod multi_signer;
8mod signer_builder;
9mod single_signer;
10
11pub use multi_signer::MultiSigner;
12pub use signer_builder::{SignerBuilder, SignerBuilderError};
13pub use single_signer::SingleSigner;
14
15use crate::entities::ProtocolMessage;
16
17/// Trait to convert a type to a message that can be signed or verified by the Mithril protocol.
18pub trait ToMessage: Sync + Send {
19    /// Return a String representation of the message.
20    fn to_message(&self) -> String;
21}
22
23impl ToMessage for String {
24    fn to_message(&self) -> String {
25        self.clone()
26    }
27}
28
29impl ToMessage for &str {
30    fn to_message(&self) -> String {
31        self.to_string()
32    }
33}
34
35impl ToMessage for ProtocolMessage {
36    fn to_message(&self) -> String {
37        self.compute_hash()
38    }
39}