Struct DefaultSigner

Source
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 a master_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

Source§

fn clone(&self) -> DefaultSigner

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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,

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>

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,

Creates a new signer instance from a raw seed. Read more
Source§

impl SparkSignerDerivationPath for DefaultSigner

Source§

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>

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>

Returns the derivation path for the identity key. Read more
Source§

impl SparkSignerEcdsa for DefaultSigner

Source§

fn sign_message_ecdsa_with_identity_key<T: AsRef<[u8]>>( &self, message: T, apply_hashing: bool, network: Network, ) -> Result<Signature, SparkSdkError>

Signs a message using the wallet’s identity private key. Read more
Source§

fn sign_message_ecdsa_with_key<T: AsRef<[u8]>>( &self, message: T, public_key_for_signing_key: &PublicKey, apply_hashing: bool, ) -> Result<Signature, SparkSdkError>

Signs a message using a specified key in the wallet. Read more
Source§

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>

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>
where T: AsRef<[u8]>,

Decrypts a secret key using the ECIES algorithm. Read more
Source§

impl SparkSignerFrost for DefaultSigner

Source§

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>
where T: AsRef<[u8]>,

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>

Retrieves or generates nonces for the given commitments. Read more
Source§

impl SparkSignerFrostSigning for DefaultSigner

Source§

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>

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>

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>

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>

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>

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>

Signs a message using the new FROST signing flow. Read more
Source§

impl SparkSignerSecp256k1 for DefaultSigner

Source§

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>

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>

Inserts a keypair into the signer by providing the private key. Read more
Source§

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>

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>

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>

Exposes the secret key for a specific leaf, to be used during transfer operations. Read more
Source§

impl SparkSignerShamir for DefaultSigner

Source§

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>

Splits a secret key identified by its public key into verifiable shares. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T