diff --git a/src/utils/field.rs b/src/utils/field.rs index 2c80b51..3c7c683 100644 --- a/src/utils/field.rs +++ b/src/utils/field.rs @@ -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!([