Problem it solves
Alice and Bob have never met. They want to have a private conversation over a network which is insecure. What they need:
- Shared secret to scramble their messages, something only they know.
- They need to make sure they are actually talking to each other and are not imposters.
Solution
- There is an agreed upon base key for everyone in the noise protocol
- They each generate their private keys, generate public keys.
- They share public keys
- Generate shared secret.
Blake 2
It derives two secret keys from the shared secret, where, A’s Incoming Key = B’s outgoing Key and vice-versa.
ChaCha20
Why do we need a nonce at all?
ChaCha uses the nonce and key to generate a keystream which is XORed with the plaintext to create a ciphertext.
<aside>
💡
Property of XOR: c1 XOR c2 gives p1 XOR p2
</aside>
That’s the reason why nonce always needs to be different.
Why not use a better algorithm?
AES-GCM was considered but:
- It runs only if the device has AES-NI
- It cannot run in pure software and is slowed down which makes it vulnerable to timing attacks