ec subtract

Markus Teich teichm at in.tum.de
Thu Jul 17 15:01:39 CEST 2014


NIIBE Yutaka wrote:
>     Xi = [ri](Zi+1 - Zi-1)
>     one point subtraction and one scalar multiplication of point
> 
> into:
> 
>     Xi = [ri]Zi+1 + [-ri]Zi-1
>     two scalar multiplications of point and one point addition

Heyho,

this seems pretty straight forward, here is what I came up with:

	void
	gotr_ecbd_gen_X_value(gcry_mpi_point_t* ret, const gcry_mpi_point_t succ,
	                      const gcry_mpi_point_t pred, const gcry_mpi_t priv)
	{
		gcry_mpi_t tmp = gcry_mpi_new(0);
		gcry_mpi_point_t tmpoint = gcry_mpi_point_new(0);
	
		gotr_assert(succ && pred && priv);
	
		*ret = gcry_mpi_point_new(0);
		gcry_mpi_ec_mul(*ret, priv, succ, ctx);
		gcry_mpi_sub(tmp, tmp, priv);
		gcry_mpi_ec_mul(tmpoint, tmp, pred, ctx);
		gcry_mpi_ec_add(*ret, *ret, tmpoint, ctx);
		gcry_mpi_point_release(tmpoint);
		gcry_mpi_release(tmp);
	}

with ctx beeing a file-static gcry_ctx_t:

	gcry_mpi_ec_new(&ctx, NULL, "Ed25519");

Any further suggestions?

--Markus



More information about the Gcrypt-devel mailing list