diff --git a/content/posts/yali/2024-08-06.md b/content/posts/yali/2024-08-06.md new file mode 100644 index 0000000..548fc05 --- /dev/null +++ b/content/posts/yali/2024-08-06.md @@ -0,0 +1,41 @@ ++++ +title = 'Yali Devlog: Intro' +date = 2024-08-06T23:59:59+02:00 +tags = ["encryption", "rust"] +categories = ["yali"] +draft = false +summary = "*Blazingly* 🚀 fast large #️⃣ numbers written in 100% safe Rust 🦀" ++++ + +## Introduction + +I have always been fascinated by modern encryption. I have tried multiple times to implement RSA. +But I have failed every single time. Why? Because ~~I wrote it in Python~~ I didn't make it *blazingly* fast by writing it from scratch in 100% safe Rust. + +So I started writing my own [large int library](https://github.com/vanten-s/yali) from scratch. And I am finally able to perform 1024-bit RSA decryption under 500 ms on my desktop computer :) +```text +[svante@desktop-nixos ~/development/yali]$ time target/release/yali +target/release/yali 0,25s user 0,00s system 99% cpu 0,250 total +``` + +## How did I get here +I started out, thinking it was easy, by just storing all data in a simple `Vec`, and using a lot of greedy algorithms. +This was extremely slow, taking multiple seconds just performing RSA encryption. + +As I continued, I made a couple of optimisations: +1. Implement a more efficient multiplication alogorithm +2. Implement a more efficient exponetiation algorithm +3. Implement a more efficient division algorithm + +And one of the most effective changes was: +Changing the underlying datatype from `Vec` to `[u8; N]`. This avoids allocating memory on the heap every time you perform an operation. + +## Future plans +In the future, I'm planning to implement: +- [Toom-Cook multiplication](https://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication) +- [Montgomery modular multiplication](https://en.wikipedia.org/wiki/Montgomery_modular_multiplication) + +My current goal is reaching <100 ms. + +Bye bye :33 + diff --git a/content/posts/yali/time.png b/content/posts/yali/time.png new file mode 100644 index 0000000..f260f52 Binary files /dev/null and b/content/posts/yali/time.png differ