djb-tweak and comp are necessary to generate the key. I have not found out how to make it work without those flags. In fact, changing comp (compressed) to nocomp causes the program to crash.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 28, 2018, 18:34 Stef Bon <<a href="mailto:stefbon@gmail.com">stefbon@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Op do 28 jun. 2018 om 17:25 schreef Alexander Lyon <<a href="mailto:arlyon@me.com" target="_blank">arlyon@me.com</a>>:<br>
><br>
> gcry_sexp_build( &sexp_genkey_params, NULL,<br>
>                  "(genkey"<br>
>                  "    (ecc"<br>
>                  "        (curve \"Curve25519\")"<br>
>                  "        (flags djb-tweak comp)"<br>
>                  "    )"<br>
>                  ")" );<br>
><br>
<br>
I did not know that the curve "Curve25519" is a valid curve,<br>
I've posted about this earlier.<br>
<br>
> gcry_sexp_extract_param( sexp_Curve25519_pair, NULL, "qd",<br>
>                          &mpi_Curve_pub_compressed, &mpi_Curve_priv, NULL );<br>
><br>
Ah gcry_sexp_extract_param does the trick. Good to know.<br>
The documentation is better with more examples like this.<br>
<br>
> // to decompress, we decode it into a point<br>
> // then extract the X and discard the rest<br>
> gcry_mpi_point_t point_Curve_pub = gcry_mpi_point_new( 0 );<br>
> gcry_ctx_t ctx_curve;<br>
> gcry_mpi_ec_new( &ctx_curve, NULL, "Curve25519" );<br>
> gcry_mpi_ec_decode_point( point_Curve_pub, mpi_Curve_pub_compressed, ctx_curve );<br>
><br>
> // we extract x, y and z but only need x because<br>
> // curve only uses the x coordinate. y and z are discarded.<br>
> gcry_mpi_t mpi_Curve_pub_y = gcry_mpi_new( 0 );<br>
> gcry_mpi_t mpi_Curve_pub_z = gcry_mpi_new( 0 );<br>
><br>
> gcry_mpi_point_snatch_get( mpi_Curve_pub, mpi_Curve_pub_y, mpi_Curve_pub_z, point_Curve_pub );<br>
><br>
> gcry_sexp_release( sexp_genkey_params );<br>
> gcry_sexp_release( sexp_Curve25519_pair );<br>
> gcry_mpi_release( mpi_Curve_pub_y );<br>
> gcry_mpi_release( mpi_Curve_pub_z );<br>
> gcry_mpi_release( mpi_Curve_pub_compressed );<br>
<br>
If it's working, that's good but it looks a bit too much to me. first<br>
you compress it using the djb-twaek flag, and later<br>
you have to decompress it later. Any other benfit using the djb-tweak<br>
I do not see. And if not using compression<br>
you have the public key already available in<br>
"mpi_Curve_pub_compressed" which should be renamed to<br>
mpi_Curve_pub_notcompressed.<br>
And then using gcry_mpi_print and reversing the result shoudl be enough.<br>
<br>
Am I overseeing something?<br>
<br>
Stef<br>
<br>
_______________________________________________<br>
Gcrypt-devel mailing list<br>
<a href="mailto:Gcrypt-devel@gnupg.org" target="_blank">Gcrypt-devel@gnupg.org</a><br>
<a href="http://lists.gnupg.org/mailman/listinfo/gcrypt-devel" rel="noreferrer" target="_blank">http://lists.gnupg.org/mailman/listinfo/gcrypt-devel</a><br>
</blockquote></div>