rust_eigenda_signers/
lib.rs1use std::sync::Arc;
2
3use async_trait::async_trait;
4
5pub mod ethereum_types {
6 pub use ethereum_types::H160;
7}
8
9mod message;
10mod public_key;
11mod recovery_id;
12mod secret_key;
13mod signature;
14pub mod signers;
15
16use std::error::Error;
17
18pub use message::Message;
19pub use public_key::{Error as PublicKeyError, PublicKey};
20pub use recovery_id::{InvalidRecoveryId, RecoveryId};
21pub use secret_key::{Error as SecretKeyError, SecretKey};
22pub use signature::RecoverableSignature;
23
24#[async_trait]
26pub trait Sign: Send + Sync + std::fmt::Debug {
27 type Error: Error + Send + Sync + 'static;
29
30 async fn sign_digest(&self, message: &Message) -> Result<RecoverableSignature, Self::Error>;
40
41 fn public_key(&self) -> PublicKey;
43}
44
45#[async_trait]
47impl<T> Sign for &T
48where
49 T: Sign + Sync,
50{
51 type Error = T::Error;
52
53 async fn sign_digest(&self, message: &Message) -> Result<RecoverableSignature, Self::Error> {
55 (*self).sign_digest(message).await
56 }
57
58 fn public_key(&self) -> PublicKey {
60 (*self).public_key()
61 }
62}
63
64#[async_trait]
66impl<T> Sign for Arc<T>
67where
68 T: Sign + Sync,
69{
70 type Error = T::Error;
71
72 async fn sign_digest(&self, message: &Message) -> Result<RecoverableSignature, Self::Error> {
74 (**self).sign_digest(message).await
75 }
76
77 fn public_key(&self) -> PublicKey {
79 (**self).public_key()
80 }
81}
82
83#[async_trait]
85impl<T> Sign for Box<T>
86where
87 T: Sign + Sync,
88{
89 type Error = T::Error;
90
91 async fn sign_digest(&self, message: &Message) -> Result<RecoverableSignature, Self::Error> {
94 (**self).sign_digest(message).await
95 }
96
97 fn public_key(&self) -> PublicKey {
99 (**self).public_key()
100 }
101}