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
25 changes: 14 additions & 11 deletions src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,31 @@ bool CCoinJoinEntry::AddScriptSig(const CTxIn& txin)
return false;
}

uint256 CCoinJoinQueue::GetSignatureHash() const
uint256 CCoinJoinQueue::GetSignatureHash(bool legacy) const
{
return SerializeHash(*this);
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
return SerializeHash(*this, SER_GETHASH, version);
}

bool CCoinJoinQueue::Sign()
{
if (!fMasternodeMode) return false;


uint256 hash = GetSignatureHash();
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
uint256 hash = GetSignatureHash(legacy_bls_scheme);
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
if (!sig.IsValid()) {
return false;
}
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
vchSig = sig.ToByteVector(legacy_bls_scheme);

return true;
}

bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinQueue::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand All @@ -89,29 +90,31 @@ bool CCoinJoinQueue::IsTimeOutOfBounds(int64_t current_time) const
nTime - current_time > COINJOIN_QUEUE_TIMEOUT;
}

uint256 CCoinJoinBroadcastTx::GetSignatureHash() const
uint256 CCoinJoinBroadcastTx::GetSignatureHash(bool legacy) const
{
return SerializeHash(*this);
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
return SerializeHash(*this, SER_GETHASH, version);
}

bool CCoinJoinBroadcastTx::Sign()
{
if (!fMasternodeMode) return false;

uint256 hash = GetSignatureHash();
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
uint256 hash = GetSignatureHash(legacy_bls_scheme);
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
if (!sig.IsValid()) {
return false;
}
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
vchSig = sig.ToByteVector(legacy_bls_scheme);

return true;
}

bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class CCoinJoinQueue
{
READWRITE(obj.nDenom);

if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
READWRITE(obj.masternodeOutpoint);
} else {
READWRITE(obj.m_protxHash);
Expand All @@ -230,7 +230,7 @@ class CCoinJoinQueue
}
}

[[nodiscard]] uint256 GetSignatureHash() const;
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;
/** Sign this mixing transaction
* return true if all conditions are met:
* 1) we have an active Masternode,
Expand Down Expand Up @@ -292,7 +292,7 @@ class CCoinJoinBroadcastTx
{
READWRITE(obj.tx);

if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
READWRITE(obj.masternodeOutpoint);
} else {
READWRITE(obj.m_protxHash);
Expand All @@ -317,7 +317,7 @@ class CCoinJoinBroadcastTx
return *this != CCoinJoinBroadcastTx();
}

[[nodiscard]] uint256 GetSignatureHash() const;
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;

bool Sign();
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
Expand Down