breez_sdk_spark/signer/
mod.rs1use crate::SdkError;
2use bitcoin::bip32::DerivationPath;
3use bitcoin::secp256k1;
4
5#[macros::async_trait]
6pub trait BreezSigner: Send + Sync {
7 fn identity_public_key(&self) -> Result<secp256k1::PublicKey, SdkError>;
9
10 async fn sign_ecdsa(
11 &self,
12 message: &[u8],
13 path: &DerivationPath,
14 ) -> Result<secp256k1::ecdsa::Signature, SdkError>;
15
16 async fn sign_ecdsa_recoverable(
17 &self,
18 message: &[u8],
19 path: &DerivationPath,
20 ) -> Result<Vec<u8>, SdkError>;
21
22 async fn ecies_encrypt(
23 &self,
24 message: &[u8],
25 path: &DerivationPath,
26 ) -> Result<Vec<u8>, SdkError>;
27
28 async fn ecies_decrypt(
29 &self,
30 message: &[u8],
31 path: &DerivationPath,
32 ) -> Result<Vec<u8>, SdkError>;
33
34 async fn sign_hash_schnorr(
35 &self,
36 hash: &[u8],
37 path: &DerivationPath,
38 ) -> Result<secp256k1::schnorr::Signature, SdkError>;
39
40 async fn derive_public_key(
41 &self,
42 path: &DerivationPath,
43 ) -> Result<secp256k1::PublicKey, SdkError>;
44
45 async fn generate_frost_signing_commitments(
46 &self,
47 ) -> Result<spark_wallet::FrostSigningCommitmentsWithNonces, SdkError>;
48
49 async fn get_public_key_for_node(
50 &self,
51 id: &spark_wallet::TreeNodeId,
52 ) -> Result<secp256k1::PublicKey, SdkError>;
53
54 async fn generate_random_key(&self) -> Result<spark_wallet::PrivateKeySource, SdkError>;
55
56 async fn get_static_deposit_private_key_source(
57 &self,
58 index: u32,
59 ) -> Result<spark_wallet::PrivateKeySource, SdkError>;
60
61 async fn get_static_deposit_private_key(
62 &self,
63 index: u32,
64 ) -> Result<secp256k1::SecretKey, SdkError>;
65
66 async fn get_static_deposit_public_key(
67 &self,
68 index: u32,
69 ) -> Result<secp256k1::PublicKey, SdkError>;
70
71 async fn subtract_private_keys(
72 &self,
73 signing_key: &spark_wallet::PrivateKeySource,
74 new_signing_key: &spark_wallet::PrivateKeySource,
75 ) -> Result<spark_wallet::PrivateKeySource, SdkError>;
76
77 async fn split_secret_with_proofs(
78 &self,
79 secret: &spark_wallet::SecretToSplit,
80 threshold: u32,
81 num_shares: usize,
82 ) -> Result<Vec<spark_wallet::VerifiableSecretShare>, SdkError>;
83
84 async fn encrypt_private_key_for_receiver(
85 &self,
86 private_key: &spark_wallet::EncryptedPrivateKey,
87 receiver_public_key: &secp256k1::PublicKey,
88 ) -> Result<Vec<u8>, SdkError>;
89
90 async fn get_public_key_from_private_key_source(
91 &self,
92 private_key: &spark_wallet::PrivateKeySource,
93 ) -> Result<secp256k1::PublicKey, SdkError>;
94
95 async fn sign_frost<'a>(
96 &self,
97 request: spark_wallet::SignFrostRequest<'a>,
98 ) -> Result<frost_secp256k1_tr::round2::SignatureShare, SdkError>;
99
100 async fn aggregate_frost<'a>(
101 &self,
102 request: spark_wallet::AggregateFrostRequest<'a>,
103 ) -> Result<frost_secp256k1_tr::Signature, SdkError>;
104}
105
106pub(crate) mod breez;
108pub(crate) mod nostr;
109pub(crate) mod rtsync;
110pub(crate) mod spark;
111
112mod adapter;
114mod default_external;
115
116pub mod external;
118pub mod external_types;
119
120pub use external::ExternalSigner;
122pub use external_types::*;
123
124pub(crate) use adapter::ExternalSignerAdapter;
126pub(crate) use default_external::DefaultExternalSigner;