Trait SparkSignerSecp256k1

Source
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§

Source

fn get_identity_public_key(&self) -> Result<Vec<u8>, SparkSdkError>

Returns the identity public key of the signer. Identity keypair in Spark is the first derived key from the master seed (using child index 0).

§Returns

The identity public key of the signer in a 33-byte array of Vec<u8>.

Source

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>.

Source

fn insert_secp256k1_keypair_from_secret_key<T>( &self, secret_key_bytes: T, ) -> Result<Vec<u8>, SparkSdkError>
where T: AsRef<[u8]>,

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
§Returns

The public key of the inserted keypair in a 33-byte array of Vec<u8>.

Source

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]>,

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 (implements AsRef<[u8]>)
  • source_pubkey - The source public key (implements AsRef<[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>.

Source

fn sensitive_expose_secret_key_from_pubkey<T>( &self, public_key: T, delete_after_exposing: bool, ) -> Result<Vec<u8>, SparkSdkError>
where T: AsRef<[u8]>,

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 (implements AsRef<[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.

Implementors§