pub struct DefaultSigner {
pub nonce_commitments: Arc<RwLock<HashbrownMap<String, String>>>,
pub public_keys_to_secret_keys: Arc<RwLock<HashbrownMap<PublicKey, SecretKey>>>,
pub network: SparkNetwork,
/* private fields */
}
Expand description
A default, in-memory signer for Spark v1. Depending on the feature flags, it may store either a master seed (for self-signing) or remote wallet connection details (for third-party signing).
- If the
self-signing
feature is enabled, this signer keeps amaster_seed
and derives keypairs to carry out signing operations. - If the
self-signing
feature is not enabled, this signer relies on a remote wallet by storing a connection URL and an API key. - Keys are held in memory and not persisted unless a future update is made to store them to disk.
- Nonce commitments for each signing round remain ephemeral in memory, which is typically sufficient for short-lived signing sessions.
Fields§
§nonce_commitments: Arc<RwLock<HashbrownMap<String, String>>>
A map of references to nonce commitments, stored as strings. These are used per signing round and can remain in memory until the round completes.
public_keys_to_secret_keys: Arc<RwLock<HashbrownMap<PublicKey, SecretKey>>>
A map from public keys to secret keys, stored in memory only. This is necessary for self-signing or for local caching if not using remote keys.
network: SparkNetwork
The network that the signer is operating on.
Trait Implementations§
Source§impl Clone for DefaultSigner
impl Clone for DefaultSigner
Source§fn clone(&self) -> DefaultSigner
fn clone(&self) -> DefaultSigner
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl SparkSigner for DefaultSigner
impl SparkSigner for DefaultSigner
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,
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 wallet from a mnemonic (BIP-39).
- Converts the mnemonic to a 64-byte seed
- Calls
from_seed
to do the rest
Source§type WrappedSigner = Arc<DefaultSigner>
type WrappedSigner = Arc<DefaultSigner>
The constructed signer type, wrapped in a thread-safe reference-counted container. Read more
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,
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. Read more
Source§impl SparkSignerDerivationPath for DefaultSigner
impl SparkSignerDerivationPath for DefaultSigner
Source§fn get_deposit_signing_key(
&self,
network: Network,
) -> Result<PublicKey, SparkSdkError>
fn get_deposit_signing_key( &self, network: Network, ) -> Result<PublicKey, SparkSdkError>
Derives the deposit signing key for the user. Read more
Source§fn derive_spark_key(
leaf_id: Option<String>,
account: u32,
seed_bytes: &[u8],
key_type: SparkKeyType,
network: Network,
) -> Result<SecretKey, SparkSdkError>
fn derive_spark_key( leaf_id: Option<String>, account: u32, seed_bytes: &[u8], key_type: SparkKeyType, network: Network, ) -> Result<SecretKey, SparkSdkError>
Derives a Spark key for the specified key type, account, and optionally leaf ID. Read more
Source§fn get_identity_derivation_path(
account_index: u32,
) -> Result<SparkDerivationPath, SparkSdkError>
fn get_identity_derivation_path( account_index: u32, ) -> Result<SparkDerivationPath, SparkSdkError>
Returns the derivation path for the identity key. Read more
Source§impl SparkSignerEcdsa for DefaultSigner
impl SparkSignerEcdsa for DefaultSigner
Source§impl SparkSignerEcies for DefaultSigner
impl SparkSignerEcies for DefaultSigner
Source§fn encrypt_secret_key_with_ecies(
&self,
receiver_public_key: &PublicKey,
pubkey_for_sk_to_encrypt: &PublicKey,
) -> Result<Vec<u8>, SparkSdkError>
fn encrypt_secret_key_with_ecies( &self, receiver_public_key: &PublicKey, pubkey_for_sk_to_encrypt: &PublicKey, ) -> Result<Vec<u8>, SparkSdkError>
Encrypts a secret key using the ECIES algorithm. Read more
Source§fn decrypt_secret_key_with_ecies<T>(
&self,
ciphertext: T,
network: Network,
) -> Result<SecretKey, SparkSdkError>
fn decrypt_secret_key_with_ecies<T>( &self, ciphertext: T, network: Network, ) -> Result<SecretKey, SparkSdkError>
Decrypts a secret key using the ECIES algorithm. Read more
Source§impl SparkSignerFrost for DefaultSigner
impl SparkSignerFrost for DefaultSigner
Source§fn new_frost_signing_noncepair(
&self,
) -> Result<FrostSigningCommitments, SparkSdkError>
fn new_frost_signing_noncepair( &self, ) -> Result<FrostSigningCommitments, SparkSdkError>
Generates a new (commitments, nonces) pair for a FROST signing round. Read more
Source§fn sensitive_expose_nonces_from_commitments<T>(
&self,
signing_commitments: &T,
) -> Result<FrostSigningNonces, SparkSdkError>
fn sensitive_expose_nonces_from_commitments<T>( &self, signing_commitments: &T, ) -> Result<FrostSigningNonces, SparkSdkError>
Exposes the secret nonces corresponding to previously generated commitments. Read more
Source§fn sensitive_create_if_not_found_expose_nonces_from_commitments(
&self,
signing_commitments: Option<&[u8]>,
) -> Result<FrostSigningNonces, SparkSdkError>
fn sensitive_create_if_not_found_expose_nonces_from_commitments( &self, signing_commitments: Option<&[u8]>, ) -> Result<FrostSigningNonces, SparkSdkError>
Retrieves or generates nonces for the given commitments. Read more
Source§impl SparkSignerFrostSigning for DefaultSigner
impl SparkSignerFrostSigning for DefaultSigner
Source§fn sign_frost(
&self,
signing_jobs: Vec<FrostSigningJob>,
) -> Result<SignFrostResponse, SparkSdkError>
fn sign_frost( &self, signing_jobs: Vec<FrostSigningJob>, ) -> Result<SignFrostResponse, SparkSdkError>
Signs messages using the FROST threshold signature scheme. Read more
Source§fn aggregate_frost(
&self,
request: AggregateFrostRequest,
) -> Result<AggregateFrostResponse, SparkSdkError>
fn aggregate_frost( &self, request: AggregateFrostRequest, ) -> Result<AggregateFrostResponse, SparkSdkError>
Aggregates multiple FROST signature shares into a complete signature. Read more
Source§fn sign_created_tree_in_bfs_order(
&self,
tx: Transaction,
vout: u32,
internal_tree_root: Arc<RwLock<DepositAddressTree>>,
request_tree_root: CreationNode,
creation_result_tree_root: CreationResponseNode,
) -> Result<(Vec<NodeSignatures>, Vec<Vec<u8>>), SparkSdkError>
fn sign_created_tree_in_bfs_order( &self, tx: Transaction, vout: u32, internal_tree_root: Arc<RwLock<DepositAddressTree>>, request_tree_root: CreationNode, creation_result_tree_root: CreationResponseNode, ) -> Result<(Vec<NodeSignatures>, Vec<Vec<u8>>), SparkSdkError>
Signs all nodes in a deposit tree in breadth-first order. Read more
Source§fn sign_transfer_refunds(
&self,
leaf_data_map: &HashMap<String, LeafRefundSigningData>,
operator_signing_results: &Vec<LeafRefundTxSigningResult>,
adaptor_public_key: Vec<u8>,
) -> Result<Vec<NodeSignatures>, SparkSdkError>
fn sign_transfer_refunds( &self, leaf_data_map: &HashMap<String, LeafRefundSigningData>, operator_signing_results: &Vec<LeafRefundTxSigningResult>, adaptor_public_key: Vec<u8>, ) -> Result<Vec<NodeSignatures>, SparkSdkError>
Signs refund transactions for transfer leaves. Read more
Source§fn sign_for_lightning_swap(
&self,
leaves: &Vec<LeafKeyTweak>,
signing_commitments: &Vec<RequestedSigningCommitments>,
receiver_identity_pubkey: PublicKey,
) -> Result<(SignFrostResponse, Vec<Vec<u8>>, Vec<ProtoSigningCommitments>), SparkSdkError>
fn sign_for_lightning_swap( &self, leaves: &Vec<LeafKeyTweak>, signing_commitments: &Vec<RequestedSigningCommitments>, receiver_identity_pubkey: PublicKey, ) -> Result<(SignFrostResponse, Vec<Vec<u8>>, Vec<ProtoSigningCommitments>), SparkSdkError>
Signs transactions for a Lightning swap operation. Read more
Source§fn sign_root_creation(
&self,
signing_pubkey_bytes: Vec<u8>,
verifying_pubkey_bytes: Vec<u8>,
_root_tx_bytes: Vec<u8>,
_refund_tx_bytes: Vec<u8>,
root_tx_sighash: Vec<u8>,
refund_tx_sighash: Vec<u8>,
root_nonce_commitment: FrostSigningCommitments,
refund_nonce_commitment: FrostSigningCommitments,
tree_creation_response: StartTreeCreationResponse,
) -> Result<Vec<Vec<u8>>, SparkSdkError>
fn sign_root_creation( &self, signing_pubkey_bytes: Vec<u8>, verifying_pubkey_bytes: Vec<u8>, _root_tx_bytes: Vec<u8>, _refund_tx_bytes: Vec<u8>, root_tx_sighash: Vec<u8>, refund_tx_sighash: Vec<u8>, root_nonce_commitment: FrostSigningCommitments, refund_nonce_commitment: FrostSigningCommitments, tree_creation_response: StartTreeCreationResponse, ) -> Result<Vec<Vec<u8>>, SparkSdkError>
Signs root node and refund transactions during tree creation. Read more
Source§fn sign_frost_new(
&self,
message: Vec<u8>,
private_as_pubkey: Vec<u8>,
verifying_key: Vec<u8>,
self_commitment: FrostSigningCommitments,
spark_commitments: HashMap<String, SigningCommitment>,
adaptor_public_key: Option<Vec<u8>>,
) -> Result<Vec<u8>, SparkSdkError>
fn sign_frost_new( &self, message: Vec<u8>, private_as_pubkey: Vec<u8>, verifying_key: Vec<u8>, self_commitment: FrostSigningCommitments, spark_commitments: HashMap<String, SigningCommitment>, adaptor_public_key: Option<Vec<u8>>, ) -> Result<Vec<u8>, SparkSdkError>
Signs a message using the new FROST signing flow. Read more
Source§impl SparkSignerSecp256k1 for DefaultSigner
impl SparkSignerSecp256k1 for DefaultSigner
Source§fn get_identity_public_key(
&self,
account_index: u32,
network: Network,
) -> Result<PublicKey, SparkSdkError>
fn get_identity_public_key( &self, account_index: u32, network: Network, ) -> Result<PublicKey, SparkSdkError>
Returns the identity public key of the signer. Read more
Source§fn new_secp256k1_keypair(
&self,
leaf_id: String,
key_type: SparkKeyType,
account_index: u32,
network: Network,
) -> Result<PublicKey, SparkSdkError>
fn new_secp256k1_keypair( &self, leaf_id: String, key_type: SparkKeyType, account_index: u32, network: Network, ) -> Result<PublicKey, SparkSdkError>
Generates a random secp256k1 keypair and persists it in the signer space. Read more
Source§fn insert_secp256k1_keypair_from_secret_key(
&self,
secret_key: &SecretKey,
) -> Result<PublicKey, SparkSdkError>
fn insert_secp256k1_keypair_from_secret_key( &self, secret_key: &SecretKey, ) -> Result<PublicKey, SparkSdkError>
Inserts a keypair into the signer by providing the private key. Read more
Source§fn new_ephemeral_keypair(&self) -> Result<PublicKey, SparkSdkError>
fn new_ephemeral_keypair(&self) -> Result<PublicKey, SparkSdkError>
Generates a new ephemeral keypair for one-time use. Read more
Source§fn subtract_secret_keys_given_pubkeys(
&self,
target_pubkey: &PublicKey,
source_pubkey: &PublicKey,
save_new_key: bool,
) -> Result<PublicKey, SparkSdkError>
fn subtract_secret_keys_given_pubkeys( &self, target_pubkey: &PublicKey, source_pubkey: &PublicKey, save_new_key: bool, ) -> Result<PublicKey, SparkSdkError>
Subtracts one secret key from another to derive a new key. Read more
Source§fn sensitive_expose_secret_key_from_pubkey(
&self,
public_key: &PublicKey,
delete_after_exposing: bool,
) -> Result<SecretKey, SparkSdkError>
fn sensitive_expose_secret_key_from_pubkey( &self, public_key: &PublicKey, delete_after_exposing: bool, ) -> Result<SecretKey, SparkSdkError>
Exposes the secret key corresponding to a given public key. Read more
Source§fn expose_leaf_secret_key_for_transfer(
&self,
leaf_id: String,
key_type: SparkKeyType,
account_index: u32,
network: Network,
) -> Result<SecretKey, SparkSdkError>
fn expose_leaf_secret_key_for_transfer( &self, leaf_id: String, key_type: SparkKeyType, account_index: u32, network: Network, ) -> Result<SecretKey, SparkSdkError>
Exposes the secret key for a specific leaf, to be used during transfer operations. Read more
Source§impl SparkSignerShamir for DefaultSigner
impl SparkSignerShamir for DefaultSigner
Source§fn split_with_verifiable_secret_sharing(
&self,
message: Vec<u8>,
threshold: usize,
num_shares: usize,
) -> Result<Vec<VerifiableSecretShare>, SparkSdkError>
fn split_with_verifiable_secret_sharing( &self, message: Vec<u8>, threshold: usize, num_shares: usize, ) -> Result<Vec<VerifiableSecretShare>, SparkSdkError>
Splits a secret message into verifiable shares using Shamir’s Secret Sharing. Read more
Source§fn split_from_public_key_with_verifiable_secret_sharing(
&self,
public_key: &PublicKey,
threshold: usize,
num_shares: usize,
) -> Result<Vec<VerifiableSecretShare>, SparkSdkError>
fn split_from_public_key_with_verifiable_secret_sharing( &self, public_key: &PublicKey, threshold: usize, num_shares: usize, ) -> Result<Vec<VerifiableSecretShare>, SparkSdkError>
Splits a secret key identified by its public key into verifiable shares. Read more
Auto Trait Implementations§
impl Freeze for DefaultSigner
impl !RefUnwindSafe for DefaultSigner
impl Send for DefaultSigner
impl Sync for DefaultSigner
impl Unpin for DefaultSigner
impl !UnwindSafe for DefaultSigner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request