feat: ready test runner for monic and sqrt tasks

This commit is contained in:
Alivecow 2024-11-22 21:16:53 +01:00
parent f75e7de733
commit 5bb9bcebff
4 changed files with 53 additions and 30 deletions

View file

@ -9,7 +9,8 @@ use tasks01::{
gfmul::gfmul_task,
pad_oracle::padding_oracle,
pfmath::{
gfdiv, gfpoly_add, gfpoly_divmod, gfpoly_mul, gfpoly_pow, gfpoly_powmod, gfpoly_sort,
gfdiv, gfpoly_add, gfpoly_divmod, gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod,
gfpoly_sort, gfpoly_sqrt,
},
poly2block::poly2block,
sea128::sea128,
@ -132,6 +133,18 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
Ok(json)
}
"gfpoly_make_monic" => {
let result = gfpoly_make_monic(args)?;
let json = json!({"S" : result.to_c_array()});
Ok(json)
}
"gfpoly_sqrt" => {
let result = gfpoly_sqrt(args)?;
let json = json!({"S" : result.to_c_array()});
Ok(json)
}
_ => Err(anyhow!(
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",

View file

@ -81,6 +81,22 @@ pub fn gfpoly_sort(args: &Value) -> Result<Vec<Polynomial>> {
Ok(polys)
}
pub fn gfpoly_make_monic(args: &Value) -> Result<Polynomial> {
let mut poly_a = Polynomial::from_c_array(&args["A"].clone());
poly_a.monic();
Ok(poly_a)
}
pub fn gfpoly_sqrt(args: &Value) -> Result<Polynomial> {
let poly_a = Polynomial::from_c_array(&args["Q"].clone());
let result = poly_a.sqrt();
Ok(result)
}
#[cfg(test)]
mod tests {
use super::*;