2022-06-08 01:36:46 +02:00
|
|
|
// Copyright (c) 2019-2022 The Dash Core developers
|
2019-03-22 11:52:37 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#ifndef BITCOIN_EVO_MNAUTH_H
|
|
|
|
#define BITCOIN_EVO_MNAUTH_H
|
2019-03-22 11:52:37 +01:00
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <bls/bls.h>
|
|
|
|
#include <serialize.h>
|
2019-03-22 11:52:37 +01:00
|
|
|
|
|
|
|
class CConnman;
|
|
|
|
class CDataStream;
|
|
|
|
class CDeterministicMN;
|
|
|
|
class CDeterministicMNList;
|
2019-04-09 13:28:12 +02:00
|
|
|
class CDeterministicMNListDiff;
|
2019-03-22 11:52:37 +01:00
|
|
|
class CNode;
|
|
|
|
class UniValue;
|
2022-12-30 06:45:31 +01:00
|
|
|
class CBlockIndex;
|
2019-03-22 11:52:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class handles the p2p message MNAUTH. MNAUTH is sent directly after VERACK and authenticates the sender as a
|
|
|
|
* masternode. It is only sent when the sender is actually a masternode.
|
|
|
|
*
|
|
|
|
* MNAUTH signs a challenge that was previously sent via VERSION. The challenge is signed differently depending on
|
|
|
|
* the connection being an inbound or outbound connection, which avoids MITM of this form:
|
|
|
|
* node1 <- Eve -> node2
|
|
|
|
* while still allowing:
|
|
|
|
* node1 -> Eve -> node2
|
|
|
|
*
|
|
|
|
* This is fine as we only use this mechanism for DoS protection. It allows us to keep masternode connections open for
|
|
|
|
* a very long time without evicting the connections when inbound connection limits are hit (non-MNs will then be evicted).
|
|
|
|
*
|
2019-06-22 02:24:32 +02:00
|
|
|
* If we ever want to add transfer of sensitive data, THIS AUTHENTICATION MECHANISM IS NOT ENOUGH!! We'd need to implement
|
2019-03-22 11:52:37 +01:00
|
|
|
* proper encryption for these connections first.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CMNAuth
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
uint256 proRegTxHash;
|
|
|
|
CBLSSignature sig;
|
|
|
|
|
2021-05-27 17:17:29 +02:00
|
|
|
SERIALIZE_METHODS(CMNAuth, obj)
|
2019-03-22 11:52:37 +01:00
|
|
|
{
|
2021-05-27 17:17:29 +02:00
|
|
|
READWRITE(obj.proRegTxHash, obj.sig);
|
2019-03-22 11:52:37 +01:00
|
|
|
}
|
|
|
|
|
2022-12-30 06:45:31 +01:00
|
|
|
static void PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip);
|
2023-01-19 18:49:21 +01:00
|
|
|
static void ProcessMessage(CNode& peer, CConnman& connman, std::string_view msg_type, CDataStream& vRecv);
|
2022-04-07 17:32:40 +02:00
|
|
|
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
2019-03-22 11:52:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#endif // BITCOIN_EVO_MNAUTH_H
|