From c0bc7b6e2d090554c9d940bc3614e089a688503a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 3 Mar 2016 10:33:29 +0100 Subject: Add zabs, zadd, zdiv, zmod, zmodmul, zmodpow, zneg, zpow, zsub, and the newly introduced zmodsqr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/zmodmul.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/zmodmul.c (limited to 'src/zmodmul.c') diff --git a/src/zmodmul.c b/src/zmodmul.c new file mode 100644 index 0000000..5b10c6e --- /dev/null +++ b/src/zmodmul.c @@ -0,0 +1,17 @@ +/* See LICENSE file for copyright and license details. */ +#include "internals" + + +void +zmodmul(z_t a, z_t b, z_t c) +{ + /* TODO Montgomery modular multiplication */ + if (a == d) { + zset(libzahl_tmp_modmul, d); + zmul(a, b, c); + zmod(a, a, libzahl_tmp_modmul); + } else { + zmul(a, b, c); + zmod(a, a, d); + } +} -- cgit v1.2.3-70-g09d2