[vault] Identity: the Domi root key in the vault, mnemonic typestate, signs only certs
This commit is contained in:
@@ -66,3 +66,18 @@ pub fn hkdf(ikm: &[u8], salt: &[u8], info: &[u8]) -> Zeroizing<[u8; KEY_LEN]> {
|
||||
pub fn open(key: &[u8; KEY_LEN], n: &[u8; NONCE_LEN], ciphertext: &[u8], aad: &[u8]) -> Option<Zeroizing<Vec<u8>>> {
|
||||
cipher(key).decrypt(&nonce(n), Payload { msg: ciphertext, aad }).ok().map(Zeroizing::new)
|
||||
}
|
||||
|
||||
/// The Domi root secret from a 24-word mnemonic (docs/IDENTITY.md): HKDF-SHA256 over its BIP39 seed.
|
||||
pub fn domi_root_secret(mnemonic: &bip39::Mnemonic) -> Zeroizing<[u8; KEY_LEN]> {
|
||||
let seed = Zeroizing::new(mnemonic.to_seed_normalized(""));
|
||||
hkdf(seed.as_ref(), b"tessera root v1", b"ed25519")
|
||||
}
|
||||
|
||||
pub fn ed25519_public(secret: &[u8; KEY_LEN]) -> [u8; 32] {
|
||||
ed25519_dalek::SigningKey::from_bytes(secret).verifying_key().to_bytes()
|
||||
}
|
||||
|
||||
pub fn ed25519_sign(secret: &[u8; KEY_LEN], msg: &[u8]) -> [u8; 64] {
|
||||
use ed25519_dalek::Signer;
|
||||
ed25519_dalek::SigningKey::from_bytes(secret).sign(msg).to_bytes()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user