Key backup and restoration
Overview
HieraChain does not have a security/key_backup_manager.py or MasterKeyProvider. Key backup is operator managed and has two real paths: plain JSON key files created by the CLI and the optional encrypted FileVaultProvider vault. There is no automatic AES-256-GCM multi-vault distribution or SHA-512 integrity chain in the code.
Actual paths
1. CLI plain backup (default)
File: hierachain/cli/key.py
python -m hierachain key generate --output validator_key.json # Ed25519 hex JSON
python -m hierachain key show --input validator_key.json
python -m hierachain key verify --input validator_key.json
- Output is
{private_key, public_key}hex. Backup means copyingvalidator_key.jsonto secure external storage. Restore means copying it back and settingHRC_VALIDATOR_IDENTITY=validator_key.json. - No encryption, no hash, no auto-rotation. The operator handles rotation by running
generateagain.
2. Encrypted vault (dev/test)
File: hierachain/security/key_provider.py (FileVaultProvider)
- Creates a
.vaultfile encrypted withPBKDF2HMAC(SHA256, 310k iter)that leads toFernet(AES-128-CBC with HMAC, not AES-256-GCM). The password comes fromHRC_VAULT_*or the constructor argument. - This provider is documented as dev/test only. Production should implement
KeyProviderwith HSM or KMS. - There is no distribution to multiple vaults, no
metadata.json, noretention_periodand noauto_restore_threshold.
sequenceDiagram
participant CLI as CLI generate
participant File as validator_key.json / .vault
participant Op as Operator / HSM
CLI->>File: write private_key/public_key hex
File->>Op: manual copy to backup / KMS
Op-->>File: restore copy back
File->>CLI: verify / LocalKeyProvider.from_file()
What is not implemented
| Documented claim (removed) | Reality |
|---|---|
KeyBackupManager.backup_keys() / _encrypt_backup_data() / SHA-512 / _distribute_to_locations() |
No such class/methods exist |
| AES-256-GCM + nonce||ciphertext + 3-vault failover | Vault uses Fernet; multi-location is manual copy |
MasterKeyProvider.get_master_key() |
No such provider; master key is HRC_MASTER_KEY_FILE/HRC_MASTER_KEY_SOURCE + HRC_VAULT_TOKEN/HRC_VAULT_PATH envs |
| Auto backup on MSP cert issue or consensus rotation | No hook; certs in security/msp.py are in-memory only |
Operator checklist
- Generate:
python -m hierachain key generate -o validator_key.json - Backup:
cp validator_key.json /secure/backup/(encrypt externally if needed) - Restore:
cp /secure/backup/validator_key.json ./ && python -m hierachain key verify - For encrypted vault:
FileVaultProvider.create_vault(vault_path, password)then store password in vault/KMS atHRC_VAULT_TOKEN.
Related
- MSP Identity:
security/msp.pyissues in-memory certs; no trigger to key backup - Cluster Lockdown: no automatic key rotation
- Encryption & Keys: corrected description of
msp.py/key_provider.py