spark_rust/signer/traits/
mod.rs

1use crate::error::SparkSdkError;
2
3// Signer traits
4use crate::signer::traits::derivation_path::SparkSignerDerivationPath;
5use crate::signer::traits::ecdsa::SparkSignerEcdsa;
6use crate::signer::traits::ecies::SparkSignerEcies;
7use crate::signer::traits::frost::SparkSignerFrost;
8use crate::signer::traits::frost_signing::SparkSignerFrostSigning;
9use crate::signer::traits::secp256k1::SparkSignerSecp256k1;
10use crate::signer::traits::shamir::SparkSignerShamir;
11
12use crate::SparkNetwork;
13
14use tonic::async_trait;
15
16pub mod derivation_path;
17pub mod ecdsa;
18pub mod ecies;
19pub mod frost;
20pub mod frost_signing;
21pub mod secp256k1;
22pub mod shamir;
23
24#[async_trait]
25pub trait SparkSigner:
26    SparkSignerShamir
27    + SparkSignerEcdsa
28    + SparkSignerEcies
29    + SparkSignerFrost
30    + SparkSignerSecp256k1
31    + SparkSignerFrostSigning
32    + SparkSignerDerivationPath
33{
34    /// The constructed signer type, wrapped in an Arc<parking_lot::RwLock<>>
35    type WrappedSigner: Sized;
36
37    /// Creates a new signer instance from a mnemonic (BIP-39).
38    ///
39    /// # Arguments
40    /// * `mnemonic` - The mnemonic to derive keys from
41    ///
42    /// # Returns
43    /// A new instance of Self
44    #[cfg(feature = "self-signing")]
45    async fn from_mnemonic(
46        mnemonic: &str,
47        network: SparkNetwork,
48    ) -> Result<Self::WrappedSigner, SparkSdkError>;
49
50    /// Creates a new signer instance from a seed.
51    ///
52    /// # Arguments
53    /// * `seed` - The seed bytes to derive keys from
54    ///
55    /// # Returns
56    /// A new instance of Self
57    #[cfg(feature = "self-signing")]
58    async fn from_master_seed(
59        master_seed: &[u8],
60        network: SparkNetwork,
61    ) -> Result<Self::WrappedSigner, SparkSdkError>;
62
63    /// Creates a new signer instance from a remote signer.
64    ///
65    /// # Returns
66    /// The remote signer returns the wallet public key as well as a user identifier for the wallet. The function constructs a new instance of Self using the public key.
67    #[cfg(not(feature = "self-signing"))]
68    async fn new_remote(
69        signer_url: &str,
70        wallet_id: &str,
71        user_public_key_hex: &str,
72    ) -> Result<Self::WrappedSigner, SparkSdkError>;
73}