Add simple public-key encryption program `catcrypt'.
[u/mdw/catacomb] / group-stdops.c
index faa34f2..ec30b4d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: group-stdops.c,v 1.2 2004/04/08 01:36:15 mdw Exp $
+ * $Id: group-stdops.c,v 1.3 2004/04/17 09:58:37 mdw Exp $
  *
  * Standard group operations
  *
@@ -42,7 +42,7 @@
  * Returns:    Zero on success, nonzero for failure.
  *
  * Use:                Checks that @x@ is a valid group element.  This may take a
- *             while, since it checks that %$x^h \ne 1$% and %$x^r = 1$%.
+ *             while, since it checks that %$x \ne 1$% and %$x^r = 1$%.
  */
 
 int group_check(group *g, ge *x)
@@ -50,8 +50,8 @@ int group_check(group *g, ge *x)
   ge *d = G_CREATE(g);
   int rc;
 
-  G_EXP(g, d, x, g->h); rc = !G_IDENTP(g, d);
-  if (rc) { G_EXP(g, d, x, g->r); rc = G_IDENTP(g, d); }
+  G_EXP(g, d, x, g->r);
+  rc = (G_IDENTP(g, d) && !G_IDENTP(g, x));
   G_DESTROY(g, d);
   if (!rc) return (-1);
   return (0);
@@ -137,7 +137,7 @@ int group_stdtoec(group *g, ec *d, ge *x) { return (-1); }
  *
  * Arguments:  @group *g@ = abstract group
  *             @ge *d@ = destination pointer
- *             @ec *p@ = elliptic curve point
+ *             @const ec *p@ = elliptic curve point
  *
  * Returns:    Zero for success, @-1@ on failure.
  *
@@ -145,7 +145,7 @@ int group_stdtoec(group *g, ec *d, ge *x) { return (-1); }
  *             coordinate.
  */
 
-int group_stdfromec(group *g, ge *d, ec *p)
+int group_stdfromec(group *g, ge *d, const ec *p)
   { if (EC_ATINF(p)) return (-1); return (G_FROMINT(g, d, p->x)); }
 
 /* --- @group_stdcheck@ --- *