diff --git a/src/poly.c b/src/poly.c index a1894a0..7d5934c 100644 --- a/src/poly.c +++ b/src/poly.c @@ -134,6 +134,20 @@ pb_poly *build_polynom(int const * const c, return new_poly; } +/** + * Sets all the polynomial coefficients to +0. + * + * @param poly the polynomial + * @param len the length of the polynomial + */ +void erase_polynom(pb_poly *poly, size_t len) +{ + for (unsigned int i = 0; i < len ; i++) { + mp_set(&(poly->terms[i]), 0); + mp_abs(&(poly->terms[i]), &(poly->terms[i])); + } +} + /** * This deletes the internal structure of a polynomial, * and frees the pointer. Don't call this on stack variables, diff --git a/src/poly.h b/src/poly.h index c3edab1..3f95e37 100644 --- a/src/poly.h +++ b/src/poly.h @@ -126,6 +126,8 @@ pb_poly *build_polynom(int const * const c, const size_t len, ntru_context *ctx); +void erase_polynom(pb_poly *poly, size_t len); + void delete_polynom(pb_poly *new_poly); void pb_starmultiply(pb_poly *a,