feat: Add testing runner for edf
This commit is contained in:
parent
905e905c35
commit
f7f3c44acb
2 changed files with 27 additions and 3 deletions
|
|
@ -9,9 +9,9 @@ use tasks01::{
|
||||||
gfmul::gfmul_task,
|
gfmul::gfmul_task,
|
||||||
pad_oracle::padding_oracle,
|
pad_oracle::padding_oracle,
|
||||||
pfmath::{
|
pfmath::{
|
||||||
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_factor_ddf, gfpoly_factor_sff,
|
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_factor_ddf, gfpoly_factor_edf,
|
||||||
gfpoly_gcd, gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod, gfpoly_sort,
|
gfpoly_factor_sff, gfpoly_gcd, gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod,
|
||||||
gfpoly_sqrt,
|
gfpoly_sort, gfpoly_sqrt,
|
||||||
},
|
},
|
||||||
poly2block::poly2block,
|
poly2block::poly2block,
|
||||||
sea128::sea128,
|
sea128::sea128,
|
||||||
|
|
@ -170,6 +170,12 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
|
||||||
|
|
||||||
Ok(json)
|
Ok(json)
|
||||||
}
|
}
|
||||||
|
"gfpoly_factor_edf" => {
|
||||||
|
let result = gfpoly_factor_edf(args)?;
|
||||||
|
let json = json!({"factors" : result});
|
||||||
|
|
||||||
|
Ok(json)
|
||||||
|
}
|
||||||
|
|
||||||
_ => Err(anyhow!(
|
_ => Err(anyhow!(
|
||||||
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
|
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use crate::{
|
||||||
utils::{
|
utils::{
|
||||||
self,
|
self,
|
||||||
dff::ddf,
|
dff::ddf,
|
||||||
|
edf::edf,
|
||||||
field::FieldElement,
|
field::FieldElement,
|
||||||
poly::{gcd, Polynomial},
|
poly::{gcd, Polynomial},
|
||||||
sff::{sff, Factors},
|
sff::{sff, Factors},
|
||||||
|
|
@ -159,6 +160,23 @@ pub fn gfpoly_factor_ddf(arsg: &Value) -> Result<Vec<(utils::dff::Factors)>> {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn gfpoly_factor_edf(arsg: &Value) -> Result<Vec<Vec<String>>> {
|
||||||
|
let poly_f = Polynomial::from_c_array(&arsg["F"].clone());
|
||||||
|
let d: u32 = serde_json::from_value(arsg["d"].clone())?;
|
||||||
|
|
||||||
|
let mut factors = edf(poly_f, d);
|
||||||
|
|
||||||
|
factors.sort();
|
||||||
|
|
||||||
|
let mut result: Vec<Vec<String>> = vec![];
|
||||||
|
|
||||||
|
for factor in factors {
|
||||||
|
result.push(factor.to_c_array())
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue