feat: Add functionality to read path from stdin and rund tasks

This commit is contained in:
0xalivecow 2024-10-20 18:34:52 +02:00
parent 43bea77392
commit 52dca1bcaf
No known key found for this signature in database
5 changed files with 29 additions and 17 deletions

View file

@ -23,16 +23,7 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value, String> {
match testcase.action.as_str() {
"poly2block" => {
let coefficients: Vec<u8> = args["coefficients"]
.as_array()
.unwrap()
.into_iter()
.map(|x| x.as_u64().unwrap() as u8)
.collect();
//eprintln!("{:?}", &args["coefficients"]);
//eprintln!("{:?}", testcase);
//eprintln!("{:?}", coefficients);
let result = poly2block(coefficients);
let result = poly2block(args);
let json = json!({"block" : result});
Ok(json)
}
@ -43,7 +34,6 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value, String> {
}
}
// TODO: Is this obsolete? Might delete later.
pub fn task_distrubute(testcases: &Testcases) -> Responses {
let mut responses: HashMap<String, Value> = HashMap::new();

View file

@ -2,7 +2,12 @@ use crate::utils::poly::{self, coefficient_to_binary};
use base64::prelude::*;
use serde_json::Value;
pub fn poly2block(coefficients: Vec<u8>) -> String {
pub fn poly2block(args: &Value) -> String {
let coefficients: Vec<u8> = args["coefficients"]
.as_array()
.unwrap()
.into_iter()
.map(|x| x.as_u64().unwrap() as u8)
.collect();
BASE64_STANDARD.encode(poly::coefficient_to_binary(coefficients).to_ne_bytes())
}