From 968ddc6cb9a0248fc1decdec7729e2a493bf16a1 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Fri, 20 Dec 2024 18:51:52 +0100 Subject: [PATCH] feat: add fn `vault_key_from_signature_hex` --- autonomi/src/client/vault/key.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autonomi/src/client/vault/key.rs b/autonomi/src/client/vault/key.rs index e452eddfab..c87669907f 100644 --- a/autonomi/src/client/vault/key.rs +++ b/autonomi/src/client/vault/key.rs @@ -39,6 +39,17 @@ pub fn derive_vault_key(evm_sk_hex: &str) -> Result Result { + 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 { let sk_bytes = sk.to_bytes();