Trait SparkSigner

Source
pub trait SparkSigner:
    SparkSignerShamir
    + SparkSignerEcdsa
    + SparkSignerEcies
    + SparkSignerFrost
    + SparkSignerSecp256k1
    + SparkSignerFrostSigning
    + SparkSignerDerivationPath {
    type WrappedSigner: Sized;

    // Required methods
    fn from_mnemonic<'life0, 'async_trait>(
        mnemonic: &'life0 str,
        network: SparkNetwork,
    ) -> Pin<Box<dyn Future<Output = Result<Self::WrappedSigner, SparkSdkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn from_master_seed<'life0, 'async_trait>(
        master_seed: &'life0 [u8],
        network: SparkNetwork,
    ) -> Pin<Box<dyn Future<Output = Result<Self::WrappedSigner, SparkSdkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The main signer trait that aggregates all cryptographic capabilities required for the Spark wallet.

This trait is the primary interface for implementing a signer for the Spark Wallet SDK. It combines all the specialized sub-traits that handle different aspects of the cryptographic operations needed in the Spark protocol.

Implementors must provide all the functionality defined in each sub-trait:

§Security Considerations

The signer implementation is responsible for securely managing private keys and other sensitive cryptographic material. Implementors should:

  • Ensure proper isolation of private key material
  • Implement secure storage if keys are persisted
  • Follow best practices for cryptographic operations
  • Maintain Spark’s specific derivation path scheme for compatibility

Required Associated Types§

Source

type WrappedSigner: Sized

The constructed signer type, wrapped in a thread-safe reference-counted container.

This associated type allows implementors to define their own wrapped signer type, which typically is an Arc<parking_lot::RwLock<Self>> to enable thread-safe access and mutation of the signer state.

Required Methods§

Source

fn from_mnemonic<'life0, 'async_trait>( mnemonic: &'life0 str, network: SparkNetwork, ) -> Pin<Box<dyn Future<Output = Result<Self::WrappedSigner, SparkSdkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new signer instance from a BIP-39 mnemonic phrase.

This method initializes a signer using a mnemonic phrase, which is converted to a seed for deriving all necessary keys. This is the recommended way to create a signer for most applications.

§Arguments
  • mnemonic - The BIP-39 mnemonic phrase to derive keys from
  • network - The Spark network to use (affects key derivation)
§Returns

A wrapped signer instance or an error if initialization fails

§Example
    let mnemonic = "abandon ability able about above absent absorb abstract absurd abuse access accident";
    let signer = DefaultSigner::from_mnemonic(mnemonic, SparkNetwork::Regtest).await?;
Source

fn from_master_seed<'life0, 'async_trait>( master_seed: &'life0 [u8], network: SparkNetwork, ) -> Pin<Box<dyn Future<Output = Result<Self::WrappedSigner, SparkSdkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new signer instance from a raw seed.

This method initializes a signer using a raw seed byte array for deriving keys. This is an alternative to using a mnemonic phrase when the seed is already available.

§Arguments
  • master_seed - The seed bytes to derive keys from
  • network - The Spark network to use (affects key derivation)
§Returns

A wrapped signer instance or an error if initialization fails

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§