In pycryptopp I have the following horrible code:
http://allmydata.org/trac/pycryptopp/browser/pycryptopp/publickey/
ecdsamodule.cpp?rev=607#L441
------- begin included excerpt of horrible code
const DL_PrivateKey_EC<ECP>* privkey;
privkey = dynamic_cast<const DL_PrivateKey_EC<ECP>*>(&(self->k-
>GetPrivateKey()));
if (!privkey)
return PyErr_Format(ecdsa_error, "dynamic_cast failed for k-
>GetPrivateKey()");
const DL_GroupParameters_EC<ECP>& params = privkey-
>GetGroupParameters();
// Ugh.. Making a temp Verifier just to get the public element
to construct the real verifier along with params.
ECDSA<ECP, Tiger>::Verifier* temp = new ECDSA<ECP,
Tiger>::Verifier(*(self->k));
const DL_PublicKey_EC<ECP>* temppubkey;
temppubkey = dynamic_cast<const DL_PublicKey_EC<ECP>*>(&(temp-
>GetPublicKey()));
if (!temppubkey)
return PyErr_Format(ecdsa_error, "dynamic_cast failed for
temp->GetPublicKey()");
ECP::Element pubel = temppubkey->GetPublicElement();
verifier->k = new ECDSA<ECP, Tiger>::Verifier(params, pubel);
------- end included excerpt of horrible code
The purpose of this horrible code is simply to get the ECDSA public
key which corresponds to the given ECDSA private key while having
point-compression turned on. What's the non-horrible way to do this?
Regards,
Zooko
---
Tahoe, the Least-Authority Filesystem -- http://allmydata.org
store your data: $10/month -- http://allmydata.com/?tracking=zsig
I am available for work -- http://zooko.com/résumé.html