aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/templates/formula_add.c
diff options
context:
space:
mode:
authorJ08nY2019-12-23 02:05:35 +0100
committerJ08nY2019-12-23 02:05:35 +0100
commitb43c5dba0ec18fe5a5204537855ea2b73fc674c6 (patch)
tree879c946cb9036f6db721fc44c37635c295ee2003 /pyecsca/codegen/templates/formula_add.c
parent878d95c4e4dadf882a205316a07bc0642f773256 (diff)
downloadpyecsca-codegen-b43c5dba0ec18fe5a5204537855ea2b73fc674c6.tar.gz
pyecsca-codegen-b43c5dba0ec18fe5a5204537855ea2b73fc674c6.tar.zst
pyecsca-codegen-b43c5dba0ec18fe5a5204537855ea2b73fc674c6.zip
Implement multipliers.
Diffstat (limited to 'pyecsca/codegen/templates/formula_add.c')
-rw-r--r--pyecsca/codegen/templates/formula_add.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/pyecsca/codegen/templates/formula_add.c b/pyecsca/codegen/templates/formula_add.c
index 971dd0a..05fd541 100644
--- a/pyecsca/codegen/templates/formula_add.c
+++ b/pyecsca/codegen/templates/formula_add.c
@@ -1,3 +1,13 @@
void point_add(const point_t *one, const point_t *other, const curve_t *curve, point_t *out_one) {
+ {%- if short_circuit %}
+ if (point_equals(one, curve->neutral)) {
+ point_set(other, out_one);
+ return;
+ }
+ if (point_equals(other, curve->neutral)) {
+ point_set(one, out_one);
+ return;
+ }
+ {%- endif %}
{%- include "ops.c" %}
} \ No newline at end of file