requesting another ECC function...

Christian Grothoff grothoff at in.tum.de
Thu Mar 21 13:39:55 CET 2013


Hi Werner,

Hacking more on our code, I discovered that there is another API call 
that is missing.  Right now, I can convert an S-expression to a 'ctx'
for 'low level' operations, but I cannot go back from a 'ctx' (where
I can manipulate 'Q' freely) to an S-expression.  So what I need is
something like a function "gcry_sexp_from_ec_context", to be used as
follows:

  /* initialize 'ctx' with 'q' */
   gcry_mpi_ec_set_point ("q", q, ctx);
   gcry_mpi_point_release (q);

   /* convert 'ctx' to 'sexp' (this hurts) */
   if (0 != (rc = gcry_sexp_from_ec_context (&pk_sexpr, ctx)))
   {
     LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_from_context", rc);
     gcry_ctx_release (ctx);
     gcry_sexp_release (data);
     gcry_sexp_release (sig_sexpr);
     return GNUNET_SYSERR;
   }
   gcry_ctx_release (ctx);

   /* finally, verify the signature */
   rc = gcry_pk_verify (sig_sexpr, data, pk_sexpr);
   gcry_sexp_release (sig_sexpr);
   gcry_sexp_release (data);
   gcry_sexp_release (pk_sexpr);
   if (rc)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          _("ECDSA signature verification failed at %s:%d: %s\n"), __FILE__,
          __LINE__, gcry_strerror (rc));
     return GNUNET_SYSERR;
   }


Also, I noticed that there is point_get_affine, but no point_set_affine.
As creating an MPI with value "1" is inconvenient, it might be nice
(also for symmetry) to have a gcry_point_set_affine (x,y) API as well.

Finally, I'm not sure 'gcry_ctx_t' is a great name for the ECC context,
as it suggests a broader use; calling it 'gcry_ec_ctx_c' might be nicer;
after all, all the functions that manipulate it are "_ec_" functions.


Happy hacking!

Christian



More information about the Gcrypt-devel mailing list