aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/templates/point.c
diff options
context:
space:
mode:
authorJ08nY2020-03-02 15:11:25 +0100
committerJ08nY2020-03-02 15:11:25 +0100
commit81e5f24363cf8f50099b7fbed0fd3bcfaac9d5ea (patch)
tree2e4abe38a7e3b2a53bb8bb2d31b6fe1cfbfb2e13 /pyecsca/codegen/templates/point.c
parent02d091ad7e7bb2d80e4ce6649437aad41b479346 (diff)
downloadpyecsca-codegen-81e5f24363cf8f50099b7fbed0fd3bcfaac9d5ea.tar.gz
pyecsca-codegen-81e5f24363cf8f50099b7fbed0fd3bcfaac9d5ea.tar.zst
pyecsca-codegen-81e5f24363cf8f50099b7fbed0fd3bcfaac9d5ea.zip
Make Barrett reduction work.
Diffstat (limited to 'pyecsca/codegen/templates/point.c')
-rw-r--r--pyecsca/codegen/templates/point.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pyecsca/codegen/templates/point.c b/pyecsca/codegen/templates/point.c
index 1ea116f..8b7b07e 100644
--- a/pyecsca/codegen/templates/point.c
+++ b/pyecsca/codegen/templates/point.c
@@ -123,9 +123,10 @@ void point_from_affine(bn_t *x, bn_t *y, const curve_t *curve, point_t *out) {
{%- endif %}
{%- if variable == "Z" %}
bn_from_int(1, &out->Z);
+ bn_red_encode(&out->Z, &curve->p, &curve->p_red);
{%- endif %}
{%- if variable == "T" %}
- bn_mod_mul(x, y, &curve->p, &out->T);
+ bn_red_mul(x, y, &curve->p, &out->T);
{%- endif %}
{%- endfor %}
{{ end_action("coord_map") }}