Skip to contentSkip to conversation

ecc: add l_ecc_point_is_infinity

PATCH Applied James Prestwood 2 participants 2 messages Oct 12, 2023 – Oct 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ecc: add l_ecc_point_is_infinity

When creating a point from raw data the validity and if infinity is checked but there doesn't exist any way to check a point for infinity after doing some arithmetic on it. Some specs requires a resulting point be checked for infinity.

---
 ell/ecc.c   | 5 +++++
 ell/ecc.h   | 1 +
 ell/ell.sym | 1 +
 3 files changed, 7 insertions(+)
ell/ecc.c +5 -0
index 73ddb96..518f405 100644
@@ -1026,3 +1026,8 @@ LIB_EXPORT bool l_ecc_points_are_equal(const struct l_ecc_point *a,
 	return ((memcmp(a->x, b->x, a->curve->ndigits * 8) == 0) &&
 			(memcmp(a->y, b->y, a->curve->ndigits * 8) == 0));
 }
+
+LIB_EXPORT bool l_ecc_point_is_infinity(const struct l_ecc_point *p)
+{
+	return _ecc_point_is_zero(p);
+}
ell/ecc.h +1 -0
index 981bf95..2c2c73a 100644
@@ -114,6 +114,7 @@ bool l_ecc_scalars_are_equal(const struct l_ecc_scalar *a,
 
 bool l_ecc_points_are_equal(const struct l_ecc_point *a,
 				const struct l_ecc_point *b);
+bool l_ecc_point_is_infinity(const struct l_ecc_point *p);
 
 #ifdef __cplusplus
 }
ell/ell.sym +1 -0
index 7b5caa1..84c45b1 100644
@@ -594,6 +594,7 @@ global:
 	l_ecc_point_clone;
 	l_ecc_point_get_curve;
 	l_ecc_points_are_equal;
+	l_ecc_point_is_infinity;
 	l_ecc_scalar_add;
 	l_ecc_scalar_free;
 	l_ecc_scalar_get_data;
Signature · 1 line
2.25.1
#1 lore raw

Hi James,

Quoted 9 lines · James Prestwood

When creating a point from raw data the validity and if infinity is checked but there doesn't exist any way to check a point for infinity after doing some arithmetic on it. Some specs requires a resulting point be checked for infinity.

---
  ell/ecc.c   | 5 +++++
  ell/ecc.h   | 1 +
  ell/ell.sym | 1 +
  3 files changed, 7 insertions(+)

Applied, thanks.

Regards,
-Denis