Poly2Block; Block2Poly; SEA128 tasks working #2
5 changed files with 29 additions and 17 deletions
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.90"
|
||||
base64 = "0.22.1"
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
mod tasks;
|
||||
mod utils;
|
||||
pub mod tasks;
|
||||
pub mod utils;
|
||||
|
|
|
|||
20
src/main.rs
20
src/main.rs
|
|
@ -1,3 +1,19 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use std::{
|
||||
env::{self, args},
|
||||
fs,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let path_to_workload = &args[1];
|
||||
|
||||
let json = fs::read_to_string(path_to_workload).unwrap();
|
||||
let workload = kauma::utils::parse::parse_json(json)?;
|
||||
|
||||
let response = kauma::tasks::task_distrubute(&workload);
|
||||
println!("{}", serde_json::to_string(&response)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue