KeyVault
Bonança stores the seed to your HD wallet in what is called a KeyVault,
which can be serialized into a json file. This takes inspiration from
keystore files, if you are unfamiliar with them consider reading
this post.
When serialized, your HD wallet seed is encrypted using a password you
define. An example key vault json file structure is as follows:
{
"vault": {
"cipher": "aes256-gcm",
"cipher_params": { "nonce": "287189f34a1433d2de201d08" },
"cipher_text": "7a34170003c0a7b3ccb75bac28757801a7d9b5e1ff062afa4af5f3c03e7d8982eb1f36ccce87436e42b44ffea6bcf39eba8c15d4e79ee0bf012811fca81ae1e112c0f8ae5d8e43ac8cad1ae961b11207",
"kdf": "pbkdf2",
"kdf_params": {
"key_length": 32,
"n": 600000,
"salt": "M6lWvNAGuZBSp9fBGAUEqw"
}
},
"chain_keys": {
"m/44'/501'/0'/0'": "AbwHhAquPXvDfxvWEh1b4mG969DQF9wJQSK5k8XKSKtG",
"m/44'/60'/0'/0/0": "0x50940F0C5779BE15F7ACB12E9b75128e1415BFec"
}
}
Breaking down the components:
cipheris the encryption algorithm used to encrypt your HD wallet seed- Within
cipher_paramsyou findnonce, a unique initialization vector for the AES-256-GCM algorithm cipher_textis your encrypted seedkdfis the key derivation function used (PBKDF2)kdf_paramsare the parameters used in the key derivation functionkey_lengthis the length in bytes of the derived keynis the number of iterations in the algorithm, where 600,000 is used to make encrypting/decrypting time consuming to slow down brute force attackssaltis the salt used for key derivation
chain_keysmaps derivation paths to the public keys derived for those paths (for example, Solana and EVM addresses)
There is no separate password verifier stored in the file. The AES-GCM
authentication tag on cipher_text is used to detect a wrong password or
tampered ciphertext (the two cannot be distinguished).
Changes to any of these fields can result in failure to decrypt the seed, and possibly permanent loss of access to funds derived from it.
The only point of weakness within the KeyVault encryption is your choice
of password. If a malicious actor were to get a hold of your json file,
they could try to decrypt it by guessing the password or the seed. Guessing
the seed is extremely difficult and unlikely, whereas guessing a password is
more feasible. This means picking a strong password is crucial.
KeyVault includes your public keys within the chain_keys field, which
allows you to view your accounts without having to decrypt your KeyVault.
There are positives and negatives to this approach, with the main benefit
being that you can check wallet balances without supplying your password.
The main drawback is that if a malicious actor were to get this file, they
would know which addresses are associated with it and how valuable breaking
the encryption may be.