fix: Fix incorrect dic output. Remainder could be zero.
This commit is contained in:
parent
3687733b7f
commit
8064dcb9e8
1 changed files with 8 additions and 12 deletions
|
|
@ -140,7 +140,7 @@ impl Polynomial {
|
||||||
//eprintln!("result in powmod after reduction: {:02X?}", result);
|
//eprintln!("result in powmod after reduction: {:02X?}", result);
|
||||||
|
|
||||||
if result.is_empty() {
|
if result.is_empty() {
|
||||||
result = Polynomial::new(vec![FieldElement::new(vec![0; 16])]);
|
result = Polynomial::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -192,7 +192,7 @@ impl Polynomial {
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.is_empty() {
|
if result.is_empty() {
|
||||||
result = Polynomial::new(vec![FieldElement::new(vec![0; 16])]);
|
result = Polynomial::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -241,7 +241,7 @@ impl Polynomial {
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.is_empty() {
|
if result.is_empty() {
|
||||||
result = Polynomial::new(vec![FieldElement::new(vec![0; 16])]);
|
result = Polynomial::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -278,20 +278,16 @@ impl Polynomial {
|
||||||
remainder.polynomial[pos] = a + &(divisor_coeff * c);
|
remainder.polynomial[pos] = a + &(divisor_coeff * c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove trailing zeros
|
while !remainder.polynomial.is_empty() && remainder.polynomial.last().unwrap().is_zero()
|
||||||
while !remainder.polynomial.is_empty()
|
|
||||||
&& remainder
|
|
||||||
.polynomial
|
|
||||||
.last()
|
|
||||||
.unwrap()
|
|
||||||
.as_ref()
|
|
||||||
.iter()
|
|
||||||
.all(|&x| x == 0)
|
|
||||||
{
|
{
|
||||||
remainder.polynomial.pop();
|
remainder.polynomial.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if remainder.is_empty() {
|
||||||
|
remainder = Polynomial::zero();
|
||||||
|
}
|
||||||
|
|
||||||
(Polynomial::new(quotient_coeffs), remainder)
|
(Polynomial::new(quotient_coeffs), remainder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue