POLY: don't clamp polyonmial in build_polynom()
Otherwise we might hit problems when using this as an out-polynom in a arithmetic functions. The caller can clamp it himself, if he needs so.
This commit is contained in:
parent
f8cac1553f
commit
0d179a0e7d
12
src/poly.c
12
src/poly.c
@ -81,7 +81,10 @@ void init_polynom_size(pb_poly *new_poly, mp_int *chara, size_t size)
|
|||||||
* Initializes and builds a polynomial with the
|
* Initializes and builds a polynomial with the
|
||||||
* coefficient values of c[] of size len within NTRU
|
* coefficient values of c[] of size len within NTRU
|
||||||
* context ctx and returns a newly allocated polynomial
|
* context ctx and returns a newly allocated polynomial
|
||||||
* pointer.
|
* pointer which is not clamped.
|
||||||
|
*
|
||||||
|
* If you want to fill a polyonmial of length 11 with zeros,
|
||||||
|
* call build_polynom(NULL, 11, ctx).
|
||||||
*
|
*
|
||||||
* @param c array of polynomial coefficients, can be NULL
|
* @param c array of polynomial coefficients, can be NULL
|
||||||
* @param len size of the coefficient array, can be 0
|
* @param len size of the coefficient array, can be 0
|
||||||
@ -119,10 +122,13 @@ pb_poly *build_polynom(int const * const c,
|
|||||||
if (sign == true)
|
if (sign == true)
|
||||||
new_poly->terms[i].sign = 1;
|
new_poly->terms[i].sign = 1;
|
||||||
}
|
}
|
||||||
new_poly->used = len;
|
} else { /* fill with zeros */
|
||||||
pb_clamp(new_poly);
|
for (unsigned int i = 0; i < len; i++)
|
||||||
|
mp_set(&(new_poly->terms[i]), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_poly->used = len;
|
||||||
|
|
||||||
return new_poly;
|
return new_poly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user