SecureBinaryData CryptoECDSA::ComputePublicKey(SecureBinaryData const & cppPrivKey) { BTC_PRIVKEY pk = ParsePrivateKey(cppPrivKey); BTC_PUBKEY pub; pk.MakePublicKey(pub); return SerializePublicKey(pub); }
SecureBinaryData CryptoECDSA::SignData(SecureBinaryData const & binToSign, SecureBinaryData const & binPrivKey) { if(CRYPTO_DEBUG) { cout << "SignData:" << endl; cout << " BinSgn: " << binToSign.getSize() << " " << binToSign.toHexStr() << endl; cout << " BinPrv: " << binPrivKey.getSize() << " " << binPrivKey.toHexStr() << endl; } BTC_PRIVKEY cppPrivKey = ParsePrivateKey(binPrivKey); return SignData(binToSign, cppPrivKey); }
bool CryptoECDSA::CheckPubPrivKeyMatch(SecureBinaryData const & privKey32, SecureBinaryData const & pubKey65) { if(CRYPTO_DEBUG) { cout << "CheckPubPrivKeyMatch:" << endl; cout << " BinPrv: " << privKey32.toHexStr() << endl; cout << " BinPub: " << pubKey65.toHexStr() << endl; } BTC_PRIVKEY privKey = ParsePrivateKey(privKey32); BTC_PUBKEY pubKey = ParsePublicKey(pubKey65); return CheckPubPrivKeyMatch(privKey, pubKey); }
BTC_PRIVKEY CryptoECDSA::CreateNewPrivateKey(SecureBinaryData entropy) { return ParsePrivateKey(SecureBinaryData().GenerateRandom(32, entropy)); }