feat: initial sea128 encrypt is working

This commit is contained in:
0xalivecow 2024-10-22 11:37:09 +02:00
parent c416547067
commit c21c11aed0
No known key found for this signature in database
5 changed files with 89 additions and 7 deletions

View file

@ -1,6 +1,6 @@
use std::{str::Bytes, string};
use crate::utils::poly::{self, get_coefficients};
use crate::utils::poly::{self, b64_2_num, get_coefficients};
use anyhow::Result;
use base64::prelude::*;
use serde_json::Value;
@ -9,11 +9,7 @@ pub fn block2poly(val: &Value) -> Result<Vec<u8>> {
// Convert JSON data in to a u128
// TODO: Transfer decoding into own function?
let string: String = serde_json::from_value(val["block"].clone())?;
let decoded: Vec<u8> = BASE64_STANDARD.decode(string)?;
let mut bytes: [u8; 16] = [0u8; 16];
bytes.copy_from_slice(&decoded);
let number: u128 = <u128>::from_ne_bytes(bytes);
let number = b64_2_num(&string)?;
let coefficients: Vec<u8> = get_coefficients(number);