[Botan-devel] Need help with generating ECDSA key pair

Jack Lloyd lloyd at randombit.net
Tue May 11 18:13:35 EDT 2010


On Mon, May 10, 2010 at 05:08:32PM +0530, Xen Tao wrote:
> Hi,
> I want to use Botan to generate an ECDSA key pair. I plan to use this key
> pair in the following manner.
> 1. In the client code, use private key to sign a message that is sent to a
> server.
> 2. Server will then use the stored public key to verify that the message was
> indeed signed using the corresponding private key.
> 
> I would appreciate help (with code snippet)  to understand how to generate
> the ECDSA key pair (public/private key).
> 
> I looked at the example (ecdsa.cpp) that came with the library (I am using
> version 1.9.4). In that example I see that public key is same as the private
> key (I have copied the relevant lines from ecdsa.cpp here).
> 
>       EC_Domain_Params params(OID("1.3.132.0.8"));
> 
>       ECDSA_PrivateKey ecdsa(rng, params);
> 
>       ECDSA_PublicKey ecdsa_pub = ecdsa;

The public key is not actually the same as the private key, it's just
a portion of it; ECDSA_PrivateKey and ECDSA_PublicKey are different
types, and the library tells the compiler how to convert one to the
other.

-Jack



More information about the botan-devel mailing list