[PATCH] Add gcry_mpi_ec_sub.

Ian Goldberg ian at cypherpunks.ca
Tue Jul 22 02:07:21 CEST 2014


On Mon, Jul 21, 2014 at 07:52:27PM +0200, Markus Teich wrote:
> This function subtracts two points on the curve. Only Twisted Edwards curves are
> supported with this change.
> ---
> 
> 
> Heyho,
> 
> I tried to implement it correctly. Beware, this is my first libgcrypt patch.
> Please review carefully for any bugs.
> 
> --Markus
> 
> +/* RESULT = P1 - P2  (Twisted Edwards version).*/
> +static void
> +sub_points_edwards (mpi_point_t result,
> +                    mpi_point_t p1, mpi_point_t p2,
> +                    mpi_ec_t ctx)
> +{
> +  mpi_point_t p2i = _gcry_mpi_point_new (0);
> +  point_set (p2i, p2);
> +  _gcry_mpi_neg (p2i->y, p2i->y);
> +  add_points_edwards (result, p1, p2i, ctx);
> +  _gcry_mpi_point_release (p2i);
> +}

Wait: isn't the negation of a point (x,y) on a twisted Edwards curve
the point (-x,y)?  You're calculating (x,-y) above, it seems to me.

   - Ian



More information about the Gcrypt-devel mailing list