11. Encrypting the transaction log
March 18, 2019 ยท View on GitHub
Now that we know about encryption we are ready to make our bank's transaction log safe for data leaks.
Problem
What we want to do is similar to when we added digital signatures. Generate a new encryption key if one hasn't already been generated. Then every time we save the transaction log to disk encrypt it using the secret_box primitive. Remember to generate a new nonce every time you encrypt it and that you don't have to keep the nonce secret, it is perfectly safe to save this together with the ciphertext.
Then when the bank is starting up, read the transaction log from disk and decrypt it.
Solution
Again, test that the bank works similar to before but also check that the transaction log on disk is encrypted (looks garbled :)). Try modifying the ciphertext and see that the bank rejects it.