refactor: externalise function to get coefficients

This commit is contained in:
0xalivecow 2024-10-20 20:55:23 +02:00
parent 963239903e
commit 24611a2357
No known key found for this signature in database
3 changed files with 24 additions and 25 deletions

View file

@ -1,6 +1,6 @@
use std::{str::Bytes, string};
use crate::utils::poly;
use crate::utils::poly::{self, get_coefficients};
use anyhow::Result;
use base64::prelude::*;
use serde_json::Value;
@ -16,15 +16,7 @@ pub fn block2poly(val: &Value) -> Result<Vec<u8>> {
bytes.copy_from_slice(&decoded);
let number: u128 = <u128>::from_ne_bytes(bytes);
let mut coefficients: Vec<u8> = vec![];
for shift in 0..128 {
//println!("{:?}", ((num >> shift) & 1));
if ((number >> shift) & 1) == 1 {
println!("Shift success");
coefficients.push(shift);
}
}
let coefficients: Vec<u8> = get_coefficients(number);
Ok(coefficients)
}