vanten-s.com/content/posts/yali/2024-08-06.md
vanten-s bfaf32e639
All checks were successful
/ build (push) Successful in 28s
Published yali devlog
2024-08-06 22:47:55 +02:00

1.7 KiB

+++ title = 'Yali Devlog: Intro' date = 2024-08-06T22:45:00+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 from scratch. And I am finally able to perform 1024-bit RSA decryption under 500 ms on my desktop computer :)

[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<u8>, 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<u8> 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:

My current goal is reaching <100 ms.

Bye bye :33