Added yali post
All checks were successful
/ build (push) Successful in 20s

This commit is contained in:
vanten-s 2024-08-06 00:26:54 +02:00
parent 7fa671ad3c
commit f94680319f
Signed by: vanten-s
GPG key ID: DE3060396884D3F2
2 changed files with 41 additions and 0 deletions

View file

@ -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<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:
- [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

BIN
content/posts/yali/time.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB