chore: remove vendoring on request

This commit is contained in:
0xalivecow 2024-10-24 22:00:58 +02:00
parent 86936641f1
commit 1f8e2c75c8
No known key found for this signature in database
1882 changed files with 16 additions and 406530 deletions

View file

@ -7,14 +7,15 @@ use crate::utils::poly::{b64_2_num, coefficient_to_binary};
pub fn gfmul(args: &Value) -> Result<String> {
eprintln!("{args}");
// Generate reduction polynomial
let reduction_polynomial_coeffs: Vec<u8> = vec![127, 126, 125, 121];
let red_poly_num: u128 = coefficient_to_binary(reduction_polynomial_coeffs);
//eprintln!("{:?}", serde_json::from_value(args["a"].clone())?);
let reduction_polynomial_coeffs: Vec<u8> = vec![7, 2, 1, 0];
let red_poly_num: u128 = 340282366920938463463374607431768211591; //coefficient_to_binary(reduction_polynomial_coeffs);
//eprintln!("{:?}", serde_json::from_value(args["a"].clone())?);
let mut poly1: u128 = b64_2_num(&serde_json::from_value(args["a"].clone())?)?;
let poly2: u128 = b64_2_num(&serde_json::from_value(args["b"].clone())?)?;
eprintln!("poly1 is: {}", poly1);
eprintln!("poly2 is: {}", poly2);
/* Begin of magic algorithm
* poly1 = a = X = V ???
* poly2 = b
@ -23,20 +24,23 @@ pub fn gfmul(args: &Value) -> Result<String> {
let mut result: u128 = 0;
for i in 0..128 {
// If poly2 at pos i is 1 then...
if ((poly2 >> i) & 1) == 1 {
result ^= poly1;
}
if ((poly2 >> 1) & 1) == 1 {
eprintln!("ALHIGLIWhlighliwfhlihliawfhliawfhli");
result ^= poly1;
}
// If poly1 at pos 127 is 0 then...
if ((poly1 >> 127) & 0) == 0 {
poly1 = poly1 >> 1;
for i in 2..128 {
if ((poly2 >> i) & 1) == 1 {
poly1 = (poly1 << 1) ^ red_poly_num;
result ^= poly1;
} else {
poly1 = (poly1 >> 1) ^ red_poly_num;
poly1 = (poly1 << 1) ^ red_poly_num;
}
}
poly1 = (poly1 << 1) ^ red_poly_num;
result ^= poly1;
Ok(BASE64_STANDARD.encode(result.to_ne_bytes()))
}