POLY: style/readability

This commit is contained in:
hasufell 2014-05-28 20:57:55 +02:00
parent 67a4557487
commit 4def114c5c
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 10 additions and 15 deletions

View File

@ -278,7 +278,7 @@ poly_inverse_poly_q(fmpz_poly_t a,
fmpz_poly_t Fq,
ntru_context *ctx)
{
bool retval = true;
bool retval = false;
int k = 0,
j = 0;
fmpz *b_last;
@ -325,10 +325,8 @@ poly_inverse_poly_q(fmpz_poly_t a,
k++;
if (fmpz_poly_degree(f) == -1) {
retval = false;
goto cleanup;
}
if (fmpz_poly_degree(f) == -1)
goto _cleanup;
}
if (fmpz_poly_degree(f) == 0)
@ -349,10 +347,8 @@ poly_inverse_poly_q(fmpz_poly_t a,
k = k % ctx->N;
b_last = fmpz_poly_get_coeff_ptr(b, ctx->N);
if (b_last && fmpz_cmp_si(b_last, 0)) {
retval = false;
goto cleanup;
}
if (b_last && fmpz_cmp_si(b_last, 0))
goto _cleanup;
/* Fq(x) = x^(N-k) * b(x) */
for (int i = ctx->N - 1; i >= 0; i--) {
@ -372,19 +368,18 @@ poly_inverse_poly_q(fmpz_poly_t a,
/* check if the f * Fq = 1 (mod p) condition holds true */
fmpz_poly_set(a_tmp, a);
poly_starmultiply(a_tmp, Fq, a_tmp, ctx, ctx->q);
if (!fmpz_poly_is_one(a_tmp))
retval = false;
if (fmpz_poly_is_one(a_tmp))
retval = true;
else
fmpz_poly_zero(Fq);
cleanup:
_cleanup:
fmpz_poly_clear(a_tmp);
fmpz_poly_clear(b);
fmpz_poly_clear(c);
fmpz_poly_clear(f);
fmpz_poly_clear(g);
if (!retval)
fmpz_poly_zero(Fq);
return retval;
}