Skip to content
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
7 changes: 7 additions & 0 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class CBLSWrapper
static NullHash nullHash;
cachedHash = nullHash.hash;
}
CBLSWrapper(const std::vector<unsigned char>& vecBytes) : CBLSWrapper<ImplType, _SerSize, C>()
{
SetBuf(vecBytes);
}

CBLSWrapper(const CBLSWrapper& ref) = default;
CBLSWrapper& operator=(const CBLSWrapper& ref) = default;
Expand Down Expand Up @@ -238,6 +242,7 @@ class CBLSId : public CBLSWrapper<CBLSIdImplicit, BLS_CURVE_ID_SIZE, CBLSId>
using CBLSWrapper::operator=;
using CBLSWrapper::operator==;
using CBLSWrapper::operator!=;
using CBLSWrapper::CBLSWrapper;

CBLSId() {}

Expand All @@ -254,6 +259,7 @@ class CBLSSecretKey : public CBLSWrapper<bls::PrivateKey, BLS_CURVE_SECKEY_SIZE,
using CBLSWrapper::operator=;
using CBLSWrapper::operator==;
using CBLSWrapper::operator!=;
using CBLSWrapper::CBLSWrapper;

CBLSSecretKey() {}

Expand All @@ -278,6 +284,7 @@ class CBLSPublicKey : public CBLSWrapper<bls::PublicKey, BLS_CURVE_PUBKEY_SIZE,
using CBLSWrapper::operator=;
using CBLSWrapper::operator==;
using CBLSWrapper::operator!=;
using CBLSWrapper::CBLSWrapper;

CBLSPublicKey() {}

Expand Down
4 changes: 1 addition & 3 deletions src/governance/governance-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ bool CGovernanceObject::Sign(const CBLSSecretKey& key)

bool CGovernanceObject::CheckSignature(const CBLSPublicKey& pubKey) const
{
CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.VerifyInsecure(pubKey, GetSignatureHash())) {
if (!CBLSSignature(vchSig).VerifyInsecure(pubKey, GetSignatureHash())) {
LogPrintf("CGovernanceObject::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down
5 changes: 1 addition & 4 deletions src/governance/governance-vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ bool CGovernanceVote::Sign(const CBLSSecretKey& key)

bool CGovernanceVote::CheckSignature(const CBLSPublicKey& pubKey) const
{
uint256 hash = GetSignatureHash();
CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.VerifyInsecure(pubKey, hash)) {
if (!CBLSSignature(vchSig).VerifyInsecure(pubKey, GetSignatureHash())) {
LogPrintf("CGovernanceVote::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,8 +2113,7 @@ bool AppInitMain()
std::string strMasterNodeBLSPrivKey = gArgs.GetArg("-masternodeblsprivkey", "");
if (!strMasterNodeBLSPrivKey.empty()) {
auto binKey = ParseHex(strMasterNodeBLSPrivKey);
CBLSSecretKey keyOperator;
keyOperator.SetBuf(binKey);
CBLSSecretKey keyOperator(binKey);
if (!keyOperator.IsValid()) {
return InitError(_("Invalid masternodeblsprivkey. Please see documentation."));
}
Expand Down
12 changes: 2 additions & 10 deletions src/privatesend/privatesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ bool CPrivateSendQueue::Sign()

bool CPrivateSendQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
uint256 hash = GetSignatureHash();

CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.VerifyInsecure(blsPubKey, hash)) {
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
LogPrint(BCLog::PRIVATESEND, "CPrivateSendQueue::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down Expand Up @@ -109,11 +105,7 @@ bool CPrivateSendBroadcastTx::Sign()

bool CPrivateSendBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
uint256 hash = GetSignatureHash();

CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.VerifyInsecure(blsPubKey, hash)) {
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
LogPrint(BCLog::PRIVATESEND, "CPrivateSendBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down
9 changes: 3 additions & 6 deletions src/test/evo_simplifiedmns_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ BOOST_AUTO_TEST_CASE(simplifiedmns_merkleroots)
std::string ip = strprintf("%d.%d.%d.%d", 0, 0, 0, i);
Lookup(ip.c_str(), smle.service, i, false);

uint8_t skBuf[CBLSSecretKey::SerSize];
memset(skBuf, 0, sizeof(skBuf));
skBuf[0] = (uint8_t)i;
CBLSSecretKey sk;
sk.SetBuf(skBuf, sizeof(skBuf));
std::vector<unsigned char> vecBytes{static_cast<unsigned char>(i)};
vecBytes.resize(CBLSSecretKey::SerSize);

smle.pubKeyOperator.Set(sk.GetPublicKey());
smle.pubKeyOperator.Set(CBLSSecretKey(vecBytes).GetPublicKey());
smle.keyIDVoting.SetHex(strprintf("%040x", i));
smle.isValid = true;

Expand Down