how to construct a public ECDSA key with point compression turned on?

236 views
Skip to first unread message

Zooko Wilcox-O'Hearn

unread,
May 26, 2009, 6:12:53 PM5/26/09
to Crypto++ Users
Folks:

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

Wei Dai

unread,
May 26, 2009, 8:26:12 PM5/26/09
to Crypto++ Users, Zooko Wilcox-O'Hearn
You can just do this:

verifier->k = new ECDSA<ECP, Tiger>::Verifier(*(self->k));
verifier->k->AccessKey().AccessGroupParameters().SetPointCompression(true);

--------------------------------------------------
From: "Zooko Wilcox-O'Hearn" <zo...@zooko.com>
Sent: Tuesday, May 26, 2009 3:12 PM
To: "Crypto++ Users" <cryptop...@googlegroups.com>
Subject: how to construct a public ECDSA key with point compression turned
on?
Reply all
Reply to author
Forward
0 new messages