This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
/
print_curves.c
76 lines (64 loc) · 1.69 KB
/
print_curves.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <[email protected]>
* Arnaud EBALARD <[email protected]>
* Jean-Pierre FLORI <[email protected]>
*
* Contributors:
* Nicolas VIVET <[email protected]>
* Karim KHALFALLAH <[email protected]>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include "print_curves.h"
/*
* Locally convert given projective point to affine representation and
* print x and y coordinates.
*/
void ec_point_print(const char *msg, prj_pt_src_t pt)
{
aff_pt y_aff;
int ret, iszero;
y_aff.magic = WORD(0);
MUST_HAVE(msg != NULL, ret, err);
ret = prj_pt_iszero(pt, &iszero); EG(ret, err);
if (iszero) {
ext_printf("%s: infinity\n", msg);
goto err;
}
ret = prj_pt_to_aff(&y_aff, pt); EG(ret, err);
ext_printf("%s", msg);
nn_print("x", &(y_aff.x.fp_val));
ext_printf("%s", msg);
nn_print("y", &(y_aff.y.fp_val));
err:
aff_pt_uninit(&y_aff);
return;
}
void ec_montgomery_point_print(const char *msg, aff_pt_montgomery_src_t pt)
{
int ret;
MUST_HAVE(msg != NULL, ret, err);
ret = aff_pt_montgomery_check_initialized(pt); EG(ret, err);
ext_printf("%s", msg);
nn_print("u", &(pt->u.fp_val));
ext_printf("%s", msg);
nn_print("v", &(pt->v.fp_val));
err:
return;
}
void ec_edwards_point_print(const char *msg, aff_pt_edwards_src_t pt)
{
int ret;
MUST_HAVE(msg != NULL, ret, err);
ret = aff_pt_edwards_check_initialized(pt); EG(ret, err);
ext_printf("%s", msg);
nn_print("x", &(pt->x.fp_val));
ext_printf("%s", msg);
nn_print("y", &(pt->y.fp_val));
err:
return;
}