aboutsummaryrefslogtreecommitdiffstats
path: root/src/zmodmul.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-03 10:33:29 +0100
committerMattias Andrée <maandree@kth.se>2016-03-03 10:35:22 +0100
commitc0bc7b6e2d090554c9d940bc3614e089a688503a (patch)
treea1b85a760ec1e18bdd0ceac15b802bdf6409e625 /src/zmodmul.c
parentznot man page: notes on representation and tendness toward zero (diff)
downloadlibzahl-c0bc7b6e2d090554c9d940bc3614e089a688503a.tar.gz
libzahl-c0bc7b6e2d090554c9d940bc3614e089a688503a.tar.bz2
libzahl-c0bc7b6e2d090554c9d940bc3614e089a688503a.tar.xz
Add zabs, zadd, zdiv, zmod, zmodmul, zmodpow, zneg, zpow, zsub, and the newly introduced zmodsqr
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zmodmul.c')
-rw-r--r--src/zmodmul.c17
1 files changed, 17 insertions, 0 deletions
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);
+ }
+}