aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/mult
diff options
context:
space:
mode:
authorJ08nY2019-11-25 21:25:29 +0100
committerJ08nY2019-11-25 21:25:29 +0100
commitde491a6191b465edb7bd9a01a5177ac9bf836747 (patch)
tree18459bc2cb101782e2157b0e9313d288d1b6a43b /pyecsca/codegen/mult
parent8a56c7a95e662862cfe78b834ccb091e95d5372f (diff)
downloadpyecsca-codegen-de491a6191b465edb7bd9a01a5177ac9bf836747.tar.gz
pyecsca-codegen-de491a6191b465edb7bd9a01a5177ac9bf836747.tar.zst
pyecsca-codegen-de491a6191b465edb7bd9a01a5177ac9bf836747.zip
Start Python codegen impl.
Diffstat (limited to 'pyecsca/codegen/mult')
-rw-r--r--pyecsca/codegen/mult/double_and_add.c3
-rw-r--r--pyecsca/codegen/mult/mult.c6
-rw-r--r--pyecsca/codegen/mult/mult.h5
3 files changed, 12 insertions, 2 deletions
diff --git a/pyecsca/codegen/mult/double_and_add.c b/pyecsca/codegen/mult/double_and_add.c
index 1fd3c9e..a795654 100644
--- a/pyecsca/codegen/mult/double_and_add.c
+++ b/pyecsca/codegen/mult/double_and_add.c
@@ -1,10 +1,11 @@
#include "mult.h"
+#include "formulas.h"
void scalar_mult(bn_t *scalar, point_t *point, curve_t *curve, point_t *out) {
point_t *q = point_copy(point);
point_t *r = point_copy(curve->neutral);
- int nbits = bn_bit_length(curve->n);
+ int nbits = bn_bit_length(&curve->n);
for (int i = nbits; i >= 0; i--) {
point_dbl(r, curve, r);
if (bn_get_bit(scalar, i) == 1) {
diff --git a/pyecsca/codegen/mult/mult.c b/pyecsca/codegen/mult/mult.c
new file mode 100644
index 0000000..d0f60ae
--- /dev/null
+++ b/pyecsca/codegen/mult/mult.c
@@ -0,0 +1,6 @@
+
+#include "mult.h"
+
+#if MULT == MULT_DOUBLE_AND_ADD
+#include "double_and_add.c"
+#endif \ No newline at end of file
diff --git a/pyecsca/codegen/mult/mult.h b/pyecsca/codegen/mult/mult.h
index dcf6767..d2817b7 100644
--- a/pyecsca/codegen/mult/mult.h
+++ b/pyecsca/codegen/mult/mult.h
@@ -1,7 +1,10 @@
#ifndef MULT_H_
#define MULT_H_
-#include "formulas.h"
+#include "defs.h"
+
+#define MULT_NONE 0
+#define MULT_DOUBLE_AND_ADD 1
void scalar_mult(bn_t *scalar, point_t *point, curve_t *curve, point_t *out);