pub trait SparkSignerSecp256k1 {
// Required methods
fn get_identity_public_key(&self) -> Result<Vec<u8>, SparkSdkError>;
fn new_secp256k1_keypair(
&self,
keygen_method: KeygenMethod,
) -> Result<Vec<u8>, SparkSdkError>;
fn insert_secp256k1_keypair_from_secret_key<T>(
&self,
secret_key_bytes: T,
) -> Result<Vec<u8>, SparkSdkError>
where T: AsRef<[u8]>;
fn subtract_secret_keys_given_pubkeys<T, U>(
&self,
target_pubkey: T,
source_pubkey: U,
save_new_key: bool,
) -> Result<Vec<u8>, SparkSdkError>
where T: AsRef<[u8]>,
U: AsRef<[u8]>;
fn sensitive_expose_secret_key_from_pubkey<T>(
&self,
public_key: T,
delete_after_exposing: bool,
) -> Result<Vec<u8>, SparkSdkError>
where T: AsRef<[u8]>;
}Required Methods§
Sourcefn get_identity_public_key(&self) -> Result<Vec<u8>, SparkSdkError>
fn get_identity_public_key(&self) -> Result<Vec<u8>, SparkSdkError>
Sourcefn new_secp256k1_keypair(
&self,
keygen_method: KeygenMethod,
) -> Result<Vec<u8>, SparkSdkError>
fn new_secp256k1_keypair( &self, keygen_method: KeygenMethod, ) -> Result<Vec<u8>, SparkSdkError>
Generates a random secp256k1 keypair and persists it in the signer space.
The returned public key is returned in a 33-byte array of Vec<u8>.
§Arguments
use_derivation_index- Whether to use the derivation index for the keypair. If set to true, the derivation index will be incremented after the keypair is generated.
§Returns
The public key of the generated keypair in a 33-byte array of Vec<u8>.
Sourcefn insert_secp256k1_keypair_from_secret_key<T>(
&self,
secret_key_bytes: T,
) -> Result<Vec<u8>, SparkSdkError>
fn insert_secp256k1_keypair_from_secret_key<T>( &self, secret_key_bytes: T, ) -> Result<Vec<u8>, SparkSdkError>
Inserts a keypair into the signer by providing the private key. The function derives the public key from the private key and persists it in the signer space.
This function is used in the transfer flow, when the receiver needs to insert a secret key into the signer at the time of receiving funds.
§Arguments
secret_key_bytes- The secret key to insert (implementsAsRef<[u8]>; e.g.Vec<u8>,&[u8],std::sync::Arc<Vec<u8>>, etc.)
§Returns
The public key of the inserted keypair in a 33-byte array of Vec<u8>.
Sourcefn subtract_secret_keys_given_pubkeys<T, U>(
&self,
target_pubkey: T,
source_pubkey: U,
save_new_key: bool,
) -> Result<Vec<u8>, SparkSdkError>
fn subtract_secret_keys_given_pubkeys<T, U>( &self, target_pubkey: T, source_pubkey: U, save_new_key: bool, ) -> Result<Vec<u8>, SparkSdkError>
Subtracts the source secret key from a target secret key to get a new secret key. Returns the public key of the new secret key.
§Arguments
target_pubkey- The target public key (implementsAsRef<[u8]>)source_pubkey- The source public key (implementsAsRef<[u8]>)save_new_key- Whether to save the newly derived keypair in the signer space
§Returns
The public key of the resulting secret key in a 33-byte array of Vec<u8>.
Sourcefn sensitive_expose_secret_key_from_pubkey<T>(
&self,
public_key: T,
delete_after_exposing: bool,
) -> Result<Vec<u8>, SparkSdkError>
fn sensitive_expose_secret_key_from_pubkey<T>( &self, public_key: T, delete_after_exposing: bool, ) -> Result<Vec<u8>, SparkSdkError>
Exposes the secret key for a given public key. This is a highly sensitive operation from a security perspective because it reveals confidential material. Use it only when absolutely necessary, and handle the returned secret key with caution.
§Arguments
public_key- The public key to expose the secret key for (implementsAsRef<[u8]>)delete_after_exposing- Whether to delete the secret key after showing it
§Returns
The secret key of the given public key in a 32-byte array of Vec<u8>.
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.