ExternalSigner

Trait ExternalSigner 

Source
pub trait ExternalSigner: Send + Sync {
Show 20 methods // Required methods fn identity_public_key(&self) -> Result<PublicKeyBytes, SignerError>; fn derive_public_key<'life0, 'async_trait>( &'life0 self, path: String, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sign_ecdsa<'life0, 'async_trait>( &'life0 self, message: MessageBytes, path: String, ) -> Pin<Box<dyn Future<Output = Result<EcdsaSignatureBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sign_ecdsa_recoverable<'life0, 'async_trait>( &'life0 self, message: MessageBytes, path: String, ) -> Pin<Box<dyn Future<Output = Result<RecoverableEcdsaSignatureBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn encrypt_ecies<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn decrypt_ecies<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sign_hash_schnorr<'life0, 'async_trait>( &'life0 self, hash: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<SchnorrSignatureBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn hmac_sha256<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<HashedMessageBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn generate_random_signing_commitment<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostCommitments, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_public_key_for_node<'life0, 'async_trait>( &'life0 self, id: ExternalTreeNodeId, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn generate_random_secret<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ExternalEncryptedSecret, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn static_deposit_secret_encrypted<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<ExternalSecretSource, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn static_deposit_secret<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<SecretBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn static_deposit_signing_key<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subtract_secrets<'life0, 'async_trait>( &'life0 self, signing_key: ExternalSecretSource, new_signing_key: ExternalSecretSource, ) -> Pin<Box<dyn Future<Output = Result<ExternalSecretSource, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn split_secret_with_proofs<'life0, 'async_trait>( &'life0 self, secret: ExternalSecretToSplit, threshold: u32, num_shares: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<ExternalVerifiableSecretShare>, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn encrypt_secret_for_receiver<'life0, 'async_trait>( &'life0 self, encrypted_secret: ExternalEncryptedSecret, receiver_public_key: PublicKeyBytes, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn public_key_from_secret<'life0, 'async_trait>( &'life0 self, secret: ExternalSecretSource, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sign_frost<'life0, 'async_trait>( &'life0 self, request: ExternalSignFrostRequest, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostSignatureShare, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn aggregate_frost<'life0, 'async_trait>( &'life0 self, request: ExternalAggregateFrostRequest, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostSignature, SignerError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

External signer trait that can be implemented by users and passed to the SDK.

This trait mirrors the BreezSigner trait but uses FFI-compatible types (bytes, strings) instead of Rust-specific types. This allows it to be exposed through FFI and WASM bindings.

All methods accept and return simple types:

  • Derivation paths as strings (e.g., “m/44’/0’/0’”)
  • Public keys, signatures, and other crypto primitives as Vec
  • Spark-specific types as serialized representations

Errors are returned as SignerError for FFI compatibility.

Required Methods§

Source

fn identity_public_key(&self) -> Result<PublicKeyBytes, SignerError>

Returns the identity public key as 33 bytes (compressed secp256k1 key).

See also: JavaScript getIdentityPublicKey

Source

fn derive_public_key<'life0, 'async_trait>( &'life0 self, path: String, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Derives a public key for the given BIP32 derivation path.

§Arguments
  • path - BIP32 derivation path as a string (e.g., “m/44’/0’/0’/0/0”)
§Returns

The derived public key as 33 bytes, or a SignerError

See also: JavaScript getPublicKeyFromDerivation

Source

fn sign_ecdsa<'life0, 'async_trait>( &'life0 self, message: MessageBytes, path: String, ) -> Pin<Box<dyn Future<Output = Result<EcdsaSignatureBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Signs a message using ECDSA at the given derivation path.

The message should be a 32-byte digest (typically a hash of the original data).

§Arguments
  • message - The 32-byte message digest to sign
  • path - BIP32 derivation path as a string
§Returns

64-byte compact ECDSA signature, or a SignerError

Source

fn sign_ecdsa_recoverable<'life0, 'async_trait>( &'life0 self, message: MessageBytes, path: String, ) -> Pin<Box<dyn Future<Output = Result<RecoverableEcdsaSignatureBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Signs a message using recoverable ECDSA at the given derivation path.

The message should be a 32-byte digest (typically a hash of the original data).

§Arguments
  • message - The 32-byte message digest to sign
  • path - BIP32 derivation path as a string
§Returns

65 bytes: recovery ID (31 + recovery_id) + 64-byte signature, or a SignerError

Source

fn encrypt_ecies<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Encrypts a message using ECIES at the given derivation path.

§Arguments
  • message - The message to encrypt
  • path - BIP32 derivation path for the encryption key
§Returns

Encrypted data, or a SignerError

Source

fn decrypt_ecies<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Decrypts a message using ECIES at the given derivation path.

§Arguments
  • message - The encrypted message
  • path - BIP32 derivation path for the decryption key
§Returns

Decrypted data, or a SignerError

See also: JavaScript decryptEcies

Source

fn sign_hash_schnorr<'life0, 'async_trait>( &'life0 self, hash: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<SchnorrSignatureBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Signs a hash using Schnorr signature at the given derivation path.

§Arguments
  • hash - The 32-byte hash to sign (must be 32 bytes)
  • path - BIP32 derivation path as a string
§Returns

64-byte Schnorr signature, or a SignerError

Source

fn hmac_sha256<'life0, 'async_trait>( &'life0 self, message: Vec<u8>, path: String, ) -> Pin<Box<dyn Future<Output = Result<HashedMessageBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

HMAC-SHA256 of a message at the given derivation path.

§Arguments
  • message - The message to hash
  • path - BIP32 derivation path as a string
§Returns

32-byte HMAC-SHA256, or a SignerError

See also: JavaScript htlcHMAC

Source

fn generate_random_signing_commitment<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostCommitments, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generates Frost signing commitments for multi-party signing.

§Returns

Frost commitments with nonces, or a SignerError

See also: JavaScript getRandomSigningCommitment

Source

fn get_public_key_for_node<'life0, 'async_trait>( &'life0 self, id: ExternalTreeNodeId, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the public key for a specific tree node in the Spark wallet.

§Arguments
  • id - The tree node identifier
§Returns

The public key for the node, or a SignerError

Source

fn generate_random_secret<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ExternalEncryptedSecret, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generates a random secret that is encrypted and known only to the signer.

This method creates a new random secret and returns it in encrypted form. The plaintext secret never leaves the signer boundary, providing a secure way to create secrets that can be referenced in subsequent operations without exposing them.

This is conceptually similar to Spark’s key derivation system where secrets are represented by opaque references (like tree node IDs or Random) rather than raw values. The encrypted secret can be passed to other signer methods that need to operate on it, while keeping the actual secret material protected within the signer.

§Returns

An encrypted secret that can be used in subsequent signer operations, or a SignerError if generation fails.

See also: Key Derivation System

Source

fn static_deposit_secret_encrypted<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<ExternalSecretSource, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets an encrypted static deposit secret by index.

§Arguments
  • index - The index of the static deposit secret
§Returns

The encrypted secret, or a SignerError

This is the encrypted version of: JavaScript getStaticDepositSecretKey

Source

fn static_deposit_secret<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<SecretBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets a static deposit secret by index.

§Arguments
  • index - The index of the static deposit secret
§Returns

The 32-byte secret, or a SignerError

See also: JavaScript getStaticDepositSecretKey

Source

fn static_deposit_signing_key<'life0, 'async_trait>( &'life0 self, index: u32, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets a static deposit signing public key by index.

§Arguments
  • index - The index of the static deposit public signing key
§Returns

The 33-byte public key, or a SignerError

See also: JavaScript getStaticDepositSigningKey

Source

fn subtract_secrets<'life0, 'async_trait>( &'life0 self, signing_key: ExternalSecretSource, new_signing_key: ExternalSecretSource, ) -> Pin<Box<dyn Future<Output = Result<ExternalSecretSource, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subtracts one secret from another.

§Arguments
  • signing_key - The first secret
  • new_signing_key - The second secret to subtract
§Returns

The resulting secret, or a SignerError

See also: JavaScript subtractSplitAndEncrypt (this method provides the subtraction step of that higher-level operation)

Source

fn split_secret_with_proofs<'life0, 'async_trait>( &'life0 self, secret: ExternalSecretToSplit, threshold: u32, num_shares: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<ExternalVerifiableSecretShare>, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Splits a secret with proofs using Shamir’s Secret Sharing.

§Arguments
  • secret - The secret to split
  • threshold - Minimum number of shares needed to reconstruct
  • num_shares - Total number of shares to create
§Returns

Vector of verifiable secret shares, or a SignerError

See also: JavaScript splitSecretWithProofs

Source

fn encrypt_secret_for_receiver<'life0, 'async_trait>( &'life0 self, encrypted_secret: ExternalEncryptedSecret, receiver_public_key: PublicKeyBytes, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Encrypts a secret for a specific receiver’s public key.

§Arguments
  • encrypted_secret - The encrypted secret to re-encrypt
  • receiver_public_key - The receiver’s 33-byte public key
§Returns

Encrypted data for the receiver, or a SignerError

Source

fn public_key_from_secret<'life0, 'async_trait>( &'life0 self, secret: ExternalSecretSource, ) -> Pin<Box<dyn Future<Output = Result<PublicKeyBytes, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the public key from a secret.

§Arguments
  • secret - The secret
§Returns

The corresponding 33-byte public key, or a SignerError

See also: JavaScript getPublicKeyFromDerivation

Source

fn sign_frost<'life0, 'async_trait>( &'life0 self, request: ExternalSignFrostRequest, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostSignatureShare, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Signs using Frost protocol (multi-party signing).

§Arguments
  • request - The Frost signing request
§Returns

A signature share, or a SignerError

See also: JavaScript signFrost

Source

fn aggregate_frost<'life0, 'async_trait>( &'life0 self, request: ExternalAggregateFrostRequest, ) -> Pin<Box<dyn Future<Output = Result<ExternalFrostSignature, SignerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Aggregates Frost signature shares into a final signature.

§Arguments
  • request - The Frost aggregation request
§Returns

The aggregated Frost signature, or a SignerError

See also: JavaScript aggregateFrost

Implementors§