Skip to content

Commit

Permalink
feat: add fn vault_key_from_signature_hex
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Dec 20, 2024
1 parent 45f8426 commit 968ddc6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions autonomi/src/client/vault/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ pub fn derive_vault_key(evm_sk_hex: &str) -> Result<VaultSecretKey, VaultKeyErro
Ok(vault_sk)
}

/// Derives the vault secret key from a signature hex string
pub fn vault_key_from_signature_hex(signature_hex: &str) -> Result<VaultSecretKey, VaultKeyError> {
let signature_bytes = hex::decode(signature_hex)
.map_err(|e| VaultKeyError::FailedToGenerateVaultSecretKey(e.to_string()))?;

let blst_key = derive_secret_key_from_seed(&signature_bytes)?;
let vault_sk = blst_to_blsttc(&blst_key)?;

Ok(vault_sk)
}

/// Convert a blst secret key to a blsttc secret key and pray that endianness is the same
pub(crate) fn blst_to_blsttc(sk: &BlstSecretKey) -> Result<bls::SecretKey, VaultKeyError> {
let sk_bytes = sk.to_bytes();
Expand Down

0 comments on commit 968ddc6

Please sign in to comment.