I'm trying to implement a wallet reader in node.js. My goal is to move the core wallet RPC server to the node.js server, by implementing the monero-cli wallet decryption code.
Here are some resources I found on the community:
- How can I decrypt a Monero wallet to get a private key?
- What data do the wallet files contain?
- What encryption algorithm is used for the wallet.keys file?
I also looked into the old and current source of the
src/wallet/wallet2.cpp file, here are some important lines:
- information initially wasn't stored as JSON
- generate_chacha_key_from_secret_keys and generate_chacha_key_from_password
- ChaCha8 is still supported, but ChaCha20 is the new default
The RPC creates two files (assuming
sample is the wallet name):
- They're both encrypted with ChaCha20
Here are some resources on the ChaCha/Salsa algorithms (there aren't plenty online):
- Salsa20 - Wikipedia (has ChaCha as well)
- ChaCha test vectors
- Chacha Cipher - Computerphile
I've made a list of questions I have about the monero/boost implementation:
- How is the nonce is generated?
- Is the nonce stored? If so, where?
- If the key is less then 32 bytes is it padded with 0s, is it repeated/truncated or is it hashed to 32 bytes? If it's hashed, what algorithm is it used?
- How is the JSON of the decryted file structured?
PS: I can move it to the cryptographic stackexchange if admins find it more fitting.