+static int eccompr(ec_curve *c, const ec *p)
+{
+ /* --- Take the LSB of %$y/x$%, or zero if %$x = 0$% ---
+ *
+ * The negative of a point has %$y' = y + x$%. Therefore either %$y/x$% or
+ * $%(y + x)/x = y/x + 1$% is odd, and this disambiguates, unless %$x =
+ * 0$%; but in that case we must have %$y^2 = b$% which has exactly one
+ * solution (because squaring is linear in a binary field).
+ */
+
+ int ybit;
+ field *f = c->f;
+ mp *y, *t;
+ if (MP_ZEROP(p->x)) ybit = 0;
+ else {
+ t = F_IN(f, MP_NEW, p->x);
+ y = F_IN(f, MP_NEW, p->y);
+ t = F_INV(f, t, t);
+ t = F_MUL(f, t, y, t);
+ t = F_OUT(f, t, t);
+ ybit = MP_ODDP(t);
+ MP_DROP(y); MP_DROP(t);
+ }
+ return (ybit);
+}
+