POLY: fix substraction

Interestingly, the results and tests work with both variants.
However, this one is correct and matches the algorithm given in
NTRU Cryptosystems Tech Report #014.
This commit is contained in:
hasufell 2014-09-13 18:26:31 +02:00
parent 73a90cc3e9
commit 398edc729d
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 2 additions and 2 deletions

View File

@ -509,12 +509,12 @@ poly_inverse_poly_p(fmpz_poly_t Fp,
/* f = f - u * g mod p */
fmpz_poly_scalar_mul_fmpz(g_tmp, g_tmp, u);
fmpz_poly_sub(f, g_tmp, f);
fmpz_poly_sub(f, f, g_tmp);
fmpz_poly_mod_unsigned(f, params->p);
/* b = b - u * c mod p */
fmpz_poly_scalar_mul_fmpz(c_tmp, c_tmp, u);
fmpz_poly_sub(b, c_tmp, b);
fmpz_poly_sub(b, b, c_tmp);
fmpz_poly_mod_unsigned(b, params->p);
fmpz_clear(u);