Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Consensus] Remove Old message format in CMasternodeBroadcast #1001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
}

std::string errorMessage = "";
if (!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetNewStrMessage(), errorMessage)
&& !obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetOldStrMessage(), errorMessage))
if (!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetStrMessage(), errorMessage))
{
// don't ban for old masternodes, their sigs could be broken because of the bug
nDos = protocolVersion < MIN_PEER_MNANNOUNCE ? 0 : 100;
Expand Down Expand Up @@ -661,11 +660,7 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
std::string errorMessage;
sigTime = GetAdjustedTime();

std::string strMessage;
if(chainActive.Height() < Params().Zerocoin_Block_V2_Start())
strMessage = GetOldStrMessage();
else
strMessage = GetNewStrMessage();
std::string strMessage = GetStrMessage();

if (!obfuScationSigner.SignMessage(strMessage, errorMessage, sig, keyCollateralAddress))
return error("CMasternodeBroadcast::Sign() - Error: %s", errorMessage);
Expand All @@ -681,31 +676,20 @@ bool CMasternodeBroadcast::VerifySignature()
{
std::string errorMessage;

if(!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetNewStrMessage(), errorMessage)
&& !obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetOldStrMessage(), errorMessage))
if(!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, GetStrMessage(), errorMessage))
return error("CMasternodeBroadcast::VerifySignature() - Error: %s", errorMessage);

return true;
}

std::string CMasternodeBroadcast::GetOldStrMessage()
std::string CMasternodeBroadcast::GetStrMessage()
{
std::string strMessage;

std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end());
strMessage = addr.ToString() + std::to_string(sigTime) + vchPubKey + vchPubKey2 + std::to_string(protocolVersion);

return strMessage;
}

std:: string CMasternodeBroadcast::GetNewStrMessage()
{
std::string strMessage;

strMessage = addr.ToString() + std::to_string(sigTime) + pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() + std::to_string(protocolVersion);

return strMessage;
return (addr.ToString() +
std::to_string(sigTime) +
pubKeyCollateralAddress.GetID().ToString() +
pubKeyMasternode.GetID().ToString() +
std::to_string(protocolVersion)
);
}

CMasternodePing::CMasternodePing()
Expand Down
3 changes: 1 addition & 2 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ class CMasternodeBroadcast : public CMasternode
bool Sign(CKey& keyCollateralAddress);
bool VerifySignature();
void Relay();
std::string GetOldStrMessage();
std::string GetNewStrMessage();
std::string GetStrMessage();

ADD_SERIALIZE_METHODS;

Expand Down