...
 
Commits (2)
......@@ -187,29 +187,26 @@ void ReprocessBlocks(int nBlocks)
bool CSporkManager::CheckSignature(CSporkMessage& spork, bool fCheckSigner)
{
//note: need to investigate why this is failing
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
std::string strMessage = std::to_string(spork.nSporkID) + std::to_string(spork.nValue) + std::to_string(spork.nTimeSigned);
CPubKey pubkeynew(ParseHex(Params().SporkKey()));
std::string errorMessage = "";
if (fCheckSigner && !obfuScationSigner.VerifyMessage(pubkeynew, spork.vchSig,strMessage, errorMessage))
bool fValidWithNewKey = obfuScationSigner.VerifyMessage(pubkeynew, spork.vchSig,strMessage, errorMessage);
if (fCheckSigner && !fValidWithNewKey)
return false;
if (GetAdjustedTime() < Params().RejectOldSporkKey()) {
// See if window is open that allows for old spork key to sign messages
if (!fValidWithNewKey && GetAdjustedTime() < Params().RejectOldSporkKey()) {
CPubKey pubkeyold(ParseHex(Params().SporkKeyOld()));
if (obfuScationSigner.VerifyMessage(pubkeynew, spork.vchSig, strMessage, errorMessage) ||
obfuScationSigner.VerifyMessage(pubkeyold, spork.vchSig, strMessage, errorMessage)) {
return true;
}
}
else if (obfuScationSigner.VerifyMessage(pubkeynew, spork.vchSig, strMessage, errorMessage)) {
return true;
return obfuScationSigner.VerifyMessage(pubkeyold, spork.vchSig, strMessage, errorMessage);
}
return false;
return fValidWithNewKey;
}
bool CSporkManager::Sign(CSporkMessage& spork)
{
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
std::string strMessage = std::to_string(spork.nSporkID) + std::to_string(spork.nValue) + std::to_string(spork.nTimeSigned);
CKey key2;
CPubKey pubkey2;
......@@ -219,16 +216,25 @@ bool CSporkManager::Sign(CSporkMessage& spork)
LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage);
return false;
}
else{
LogPrintf("CMasternodePayments::Sign - obfuScationSigner.SetKey: '%s'\n", strMasterPrivKey);
}
if (!obfuScationSigner.SignMessage(strMessage, errorMessage, spork.vchSig, key2)) {
LogPrintf("CMasternodePayments::Sign - Sign message failed");
return false;
}
else{
LogPrintf("CMasternodePayments::Sign - obfuScationSigner.SignMessage: '%s'\n", strMessage);
}
if (!obfuScationSigner.VerifyMessage(pubkey2, spork.vchSig, strMessage, errorMessage)) {
LogPrintf("CMasternodePayments::Sign - Verify message failed");
return false;
}
else{
LogPrintf("CMasternodePayments::VerifyMessage - obfuScationSigner.SignMessage: '%s'\n", strMessage);
}
return true;
}
......