spark_sdk/signer/traits/ecies.rs
1use crate::error::SparkSdkError;
2
3pub trait SparkSignerEcies {
4 /// Encrypts a secret key using the ECIES algorithm.
5 ///
6 /// # Arguments
7 /// * `receiver_public_key` - The public key to encrypt the secret key with (implements `AsRef<[u8]>`)
8 /// * `plaintext` - The plaintext to encrypt (implements `AsRef<[u8]>`)
9 ///
10 /// # Returns
11 /// The encrypted secret key in a 64 bytes array of [`Vec<u8>`].
12 fn encrypt_secret_key_with_ecies<T, U>(
13 &self,
14 receiver_public_key: T,
15 pubkey_for_sk_to_encrypt: U,
16 ) -> Result<Vec<u8>, SparkSdkError>
17 where
18 T: AsRef<[u8]>,
19 U: AsRef<[u8]>;
20
21 /// Decrypts a secret key using the ECIES algorithm.
22 ///
23 /// # Arguments
24 /// * `ciphertext` - The ciphertext to decrypt (implements `AsRef<[u8]>`)
25 ///
26 /// # Returns
27 /// The decrypted secret key in a 32 bytes array of [`Vec<u8>`].
28 fn decrypt_secret_key_with_ecies<T>(&self, ciphertext: T) -> Result<Vec<u8>, SparkSdkError>
29 where
30 T: AsRef<[u8]>;
31}