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,
|
||||
pad_oracle::padding_oracle,
|
||||
pfmath::{
|
||||
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_factor_ddf, gfpoly_factor_sff,
|
||||
gfpoly_gcd, gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod, gfpoly_sort,
|
||||
gfpoly_sqrt,
|
||||
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_factor_ddf, gfpoly_factor_edf,
|
||||
gfpoly_factor_sff, gfpoly_gcd, gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod,
|
||||
gfpoly_sort, gfpoly_sqrt,
|
||||
},
|
||||
poly2block::poly2block,
|
||||
sea128::sea128,
|
||||
|
|
@ -170,6 +170,12 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
|
|||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_factor_edf" => {
|
||||
let result = gfpoly_factor_edf(args)?;
|
||||
let json = json!({"factors" : result});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
_ => Err(anyhow!(
|
||||
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
utils::{
|
||||
self,
|
||||
dff::ddf,
|
||||
edf::edf,
|
||||
field::FieldElement,
|
||||
poly::{gcd, Polynomial},
|
||||
sff::{sff, Factors},
|
||||
|
|
@ -159,6 +160,23 @@ pub fn gfpoly_factor_ddf(arsg: &Value) -> Result<Vec<(utils::dff::Factors)>> {
|
|||
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)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue