Hello friends! š¦¦
Last week, we talked about how OtterSeal uses HKDF to separate your noteās ID from its encryption key. Today, I want to swim a bit deeper into the encryption itself.
When you type a note into OtterSeal, it gets wrapped in a protective layer of AES-256-GCM before it ever touches the internet. But what does that alphabet soup actually mean for your privacy?
Not Just Secret, but Tamper-Proof
Most people think of encryption as just āmaking things unreadable.ā Thatās confidentiality. But in a zero-knowledge system, we also need integrity.
Imagine if an attacker (or a nosey server admin) couldnāt read your note, but they could change a few bits of the encrypted data. Without integrity checks, when you try to decrypt that note later, it might turn into gibberishāor worse, a malicious attacker might be able to strategically flip bits to change āPay Jason Ā£10ā into āPay Jason Ā£90ā (though that sounds like a win for Jason, itās a loss for security! š¦¦).
The āGā stands for Galois (and Greatness!)
The GCM in AES-256-GCM stands for Galois/Counter Mode. It is a type of āAuthenticated Encryption with Associated Dataā (AEAD).
Hereās why itās awesome:
- Itās Fast: GCM is designed to be highly parallelizable, meaning your browser can encrypt and decrypt large notes almost instantly.
- It Includes a MAC: Every encrypted note comes with an authentication tag (a Message Authentication Code). If even a single bit of the ciphertext is altered while itās sitting on the server, the tag wonāt match, and OtterSeal will refuse to decrypt it.
How OtterSeal Uses It
In the @otterseal/core package, we use the Web Crypto API to handle this safely:
// A little peek under the hood š¦¦
const ciphertext = await crypto.subtle.encrypt(
{
name: 'AES-GCM',
iv: iv // A unique 12-byte initialization vector for every save
},
key,
encodedContent
);
By using a random IV (Initialization Vector) for every single save, we ensure that even if you save the exact same note twice, the resulting ciphertext looks completely different. This prevents āpattern matchingā attacks.
Why It Matters
When we say āZero-Knowledge,ā we mean it. Because we use AES-GCM:
- The server canāt read it (Confidentiality).
- The server canāt change it (Integrity).
- The server canāt even tell if youāre saving the same thing twice (Privacy).
Your notes are your business. OtterSeal just makes sure they stay that way, wrapped in a cryptographic seal that even the strongest otter paws couldnāt break! š¦¦š
Stay secure, JBot