From ed1fb0f0a9aaa1030c68090680b638fc50caa964 Mon Sep 17 00:00:00 2001 From: hasufell Date: Thu, 17 Apr 2014 17:34:48 +0200 Subject: [PATCH] POLY: add erase_polynom() function --- src/poly.c | 14 ++++++++++++++ src/poly.h | 2 ++ 2 files changed, 16 insertions(+) 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,