Merge sff runner adaption #24
6 changed files with 62 additions and 24 deletions
|
|
@ -9,8 +9,8 @@ use tasks01::{
|
|||
gfmul::gfmul_task,
|
||||
pad_oracle::padding_oracle,
|
||||
pfmath::{
|
||||
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_gcd, gfpoly_make_monic, gfpoly_mul,
|
||||
gfpoly_pow, gfpoly_powmod, gfpoly_sort, gfpoly_sqrt,
|
||||
gfdiv, gfpoly_add, gfpoly_diff, gfpoly_divmod, gfpoly_factor_sff, gfpoly_gcd,
|
||||
gfpoly_make_monic, gfpoly_mul, gfpoly_pow, gfpoly_powmod, gfpoly_sort, gfpoly_sqrt,
|
||||
},
|
||||
poly2block::poly2block,
|
||||
sea128::sea128,
|
||||
|
|
@ -157,6 +157,12 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
|
|||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_factor_sff" => {
|
||||
let result = gfpoly_factor_sff(args)?;
|
||||
let json = json!({"factors" : result});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
_ => Err(anyhow!(
|
||||
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use serde_json::Value;
|
|||
use crate::utils::{
|
||||
field::FieldElement,
|
||||
poly::{gcd, Polynomial},
|
||||
sff::{sff, Factors},
|
||||
};
|
||||
|
||||
pub fn gfpoly_add(args: &Value) -> Result<Polynomial> {
|
||||
|
|
@ -117,6 +118,23 @@ pub fn gfpoly_gcd(args: &Value) -> Result<Polynomial> {
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn gfpoly_factor_sff(arsg: &Value) -> Result<Vec<(Factors)>> {
|
||||
let poly_f = Polynomial::from_c_array(&arsg["F"].clone());
|
||||
|
||||
let mut factors = sff(poly_f);
|
||||
factors.sort();
|
||||
let mut result: Vec<Factors> = vec![];
|
||||
|
||||
for (factor, exponent) in factors {
|
||||
result.push(Factors {
|
||||
factor: factor.to_c_array(),
|
||||
exponent,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
use super::poly::Polynomial;
|
||||
|
||||
pub fn dff(f: Polynomial) {
|
||||
let q = 2u128.pow(128);
|
||||
let z: Vec<(Polynomial, u32)> = vec![];
|
||||
let d = 1;
|
||||
let f_start = f.clone();
|
||||
|
||||
while f_start.degree() >= 2 * d {}
|
||||
}
|
||||
|
|
@ -22,6 +22,10 @@ impl Polynomial {
|
|||
Self { polynomial }
|
||||
}
|
||||
|
||||
pub fn degree(&self) -> usize {
|
||||
self.polynomial.len()
|
||||
}
|
||||
|
||||
pub fn from_c_array(array: &Value) -> Self {
|
||||
let mut polynomial: Vec<FieldElement> = vec![];
|
||||
let c_array: Vec<String> = array
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ use crate::utils::{
|
|||
use super::poly::Polynomial;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Factors {
|
||||
factor: Vec<String>,
|
||||
exponent: u32,
|
||||
pub struct Factors {
|
||||
pub factor: Vec<String>,
|
||||
pub exponent: u32,
|
||||
}
|
||||
|
||||
pub fn sff(mut f: Polynomial) -> Vec<(Polynomial, u32)> {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
{
|
||||
"testcases": {
|
||||
"sandbox": {
|
||||
"action": "gfpoly_gcd",
|
||||
"action": "gfpoly_factor_sff",
|
||||
"arguments": {
|
||||
"A": [
|
||||
"DNWpXnnY24XecPa7a8vrEA==",
|
||||
"I8uYpCbsiPaVvUznuv1IcA==",
|
||||
"wsbiU432ARWuO93He3vbvA==",
|
||||
"zp0g3o8iNz7Y+8oUxw1vJw==",
|
||||
"J0GekE3uendpN6WUAuJ4AA==",
|
||||
"wACd0e6u1ii4AAAAAAAAAA==",
|
||||
"ACAAAAAAAAAAAAAAAAAAAA=="
|
||||
],
|
||||
"B": [
|
||||
"I20VjJmlSnRSe88gaDiLRQ==",
|
||||
"0Cw5HxJm/pfybJoQDf7/4w==",
|
||||
"8ByrMMf+vVj5r3YXUNCJ1g==",
|
||||
"rEU/f2UZRXqmZ6V7EPKfBA==",
|
||||
"LfdALhvCrdhhGZWl9l9DSg==",
|
||||
"KSUKhN0n6/DZmHPozd1prw==",
|
||||
"DQrRkuA9Zx279wAAAAAAAA==",
|
||||
"AhCEAAAAAAAAAAAAAAAAAA=="
|
||||
"F": [
|
||||
"vL77UwAAAAAAAAAAAAAAAA==",
|
||||
"mEHchYAAAAAAAAAAAAAAAA==",
|
||||
"9WJa0MAAAAAAAAAAAAAAAA==",
|
||||
"akHfwWAAAAAAAAAAAAAAAA==",
|
||||
"E12o/QAAAAAAAAAAAAAAAA==",
|
||||
"vKJ/FgAAAAAAAAAAAAAAAA==",
|
||||
"yctWwAAAAAAAAAAAAAAAAA==",
|
||||
"c1BXYAAAAAAAAAAAAAAAAA==",
|
||||
"o0AtAAAAAAAAAAAAAAAAAA==",
|
||||
"AbP2AAAAAAAAAAAAAAAAAA==",
|
||||
"k2YAAAAAAAAAAAAAAAAAAA==",
|
||||
"vBYAAAAAAAAAAAAAAAAAAA==",
|
||||
"dSAAAAAAAAAAAAAAAAAAAA==",
|
||||
"69gAAAAAAAAAAAAAAAAAAA==",
|
||||
"VkAAAAAAAAAAAAAAAAAAAA==",
|
||||
"a4AAAAAAAAAAAAAAAAAAAA==",
|
||||
"gAAAAAAAAAAAAAAAAAAAAA=="
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue