Add fixes for powmod and sorting of polynomials #17

Merged
0xalivecow merged 2 commits from dev into main 2024-11-21 16:22:15 +00:00
Showing only changes of commit 81fe06941d - Show all commits

View file

@ -85,13 +85,12 @@ impl Polynomial {
}
if exponent == 0 {
let inter = Polynomial::new(vec![FieldElement::new(
let result = Polynomial::new(vec![FieldElement::new(
polynomial_2_block(vec![0], "gcm").unwrap(),
)]);
let result = inter.div(&modulus);
eprintln!("Returned value is: {:02X?}", result);
return result.1;
return result;
}
//eprintln!("Initial result: {:?}", result);
@ -1175,6 +1174,20 @@ mod tests {
);
}
#[test]
fn test_field_poly_powmod_k0_special() {
let json1 = json!(["NeverGonnaGiveYouUpAAA=="]);
let json2 = json!(["NeverGonnaGiveYouUpAAA=="]);
let element1: Polynomial = Polynomial::from_c_array(&json1);
let modulus: Polynomial = Polynomial::from_c_array(&json2);
let result = element1.pow_mod(0, modulus);
eprintln!("Result is: {:02X?}", result);
assert_eq!(result.to_c_array(), vec!["gAAAAAAAAAAAAAAAAAAAAA=="]);
}
#[test]
fn test_field_poly_powmod_kn_eqdeg() {
let json1 = json!([