diff options
| author | J08nY | 2020-02-20 15:06:18 +0100 |
|---|---|---|
| committer | J08nY | 2020-02-20 15:06:18 +0100 |
| commit | 92cb16e8103da998aa1bf226d24ef6771a92c5d5 (patch) | |
| tree | 760e5f4921e8813b29748e7353a32168d99140cc /pyecsca/codegen/templates/point.c | |
| parent | 5da1d167c203395103d220c450e29fece08f4198 (diff) | |
| download | pyecsca-codegen-92cb16e8103da998aa1bf226d24ef6771a92c5d5.tar.gz pyecsca-codegen-92cb16e8103da998aa1bf226d24ef6771a92c5d5.tar.zst pyecsca-codegen-92cb16e8103da998aa1bf226d24ef6771a92c5d5.zip | |
Allocate and initialize formula variables only once.
Diffstat (limited to 'pyecsca/codegen/templates/point.c')
| -rw-r--r-- | pyecsca/codegen/templates/point.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pyecsca/codegen/templates/point.c b/pyecsca/codegen/templates/point.c index 445bdc4..aebb7c7 100644 --- a/pyecsca/codegen/templates/point.c +++ b/pyecsca/codegen/templates/point.c @@ -1,12 +1,13 @@ #include "point.h" #include <stdlib.h> +{% import "ops.c" as ops %} point_t *point_new(void) { point_t *result = malloc(sizeof(point_t)); {%- for variable in variables %} bn_init(&result->{{ variable }}); {%- endfor %} - + result->infinity = false; return result; } @@ -74,7 +75,7 @@ bool point_equals_affine(const point_t *one, const point_t *other, const curve_t } void point_to_affine(const point_t *point, const curve_t *curve, bn_t *out_x, bn_t *out_y) { - {%- include "ops.c" %} + {{ ops.render_all(allocations, initializations, operations, returns, frees) }} {%- if "x" in allocations %} if (out_x) { bn_copy(&x, out_x); |
