Hi all,

I want to implement a sign scheme using Elliptic curves with following
code:

-----------------------------------------------------------------------------------------
class A {
  public:
  A();
  ~A();
  string encryptSignFromHash(string &resultStr, ECIES<ECP>::PrivateKey
&privateKey);

  private :
   ECIES<ECP>::PrivateKey  privateKey;
   ECIES<ECP>::PublicKey   publicKey;
   AutoSeededRandomPool rng;
   void initPublicKey(ECIES<ECP>::PrivateKey &privateKey);
 };


string A::encryptSignFromHash(string &str,
                                               ECIES<ECP>::PrivateKey
&privateKey) {
   privateKey.Initialize(rng, ASN1::secp256r1());    //
<----------------------------------- pb here when two following lines
are in constructor !!
   privateKey.MakePublicKey(publicKey);

   // Signing a message
   ECDSA<ECP>::Signer signer(privateKey);
   string signature;
   StringSink   * stringSink  = new StringSink(signature);
   SignerFilter * signerFilter = new SignerFilter(rng, signer,
stringSink);

   // encrypt message
   StringSource(str, true, signerFilter);

   // ...
 }
-----------------------------------------------------------------------------------------

Doing so, I get a new private/public key each time I sign a document
but that is not what I want !
Of course, I tried to put the two following lines in the constructor
of A():

-----------------------------------------------------------------------------------------
   privateKey.Initialize(rng, ASN1::secp256r1());
   privateKey.MakePublicKey(publicKey);
-----------------------------------------------------------------------------------------


... but it did not work, and I got this error message:
-----------------------------------------------------------------------------------------
" terminate called after throwing an instance of
'CryptoPP::CryptoMaterial::InvalidMaterial'
  what():  CryptoMaterial: this object contains invalid values "
-----------------------------------------------------------------------------------------

What is the reason?
How can I make it so that I create and init a private/public key pair
only once for all before signing several documents?

Thank you very much for your help

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to