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
2 changes: 2 additions & 0 deletions src/network_messages/network_message_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ enum NetworkMessageType : unsigned char
RESPOND_ACTIVE_IPO = 65,
REQUEST_ORACLE_DATA = 66,
RESPOND_ORACLE_DATA = 67,
BROADCAST_CUSTOM_MINING_TASK = 68,
BROADCAST_CUSTOM_MINING_SOLUTION = 69,
ORACLE_MACHINE_QUERY = 190, // only on communication channel Core node <-> OM node
ORACLE_MACHINE_REPLY = 191, // only on communication channel Core node <-> OM node
REQUEST_TX_STATUS = 201, // tx addon only
Expand Down
65 changes: 64 additions & 1 deletion src/qubic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,10 +1477,61 @@ static void processRequestedCustomMiningSolutionVerificationRequest(Peer* peer,
}
}

// Hardcoded doge dispatcher public key (identity: XPILPIJYHRBTACMMIRSJLIZWCXDBHWVEOTZBQFBXWEUXDZGGDEKDQPIEQKQK)
static const unsigned char dogeDispatcherPubkey[32] = {
0x25, 0x98, 0x6d, 0x38, 0xa6, 0x3d, 0xd6, 0x45,
0x0c, 0x07, 0x34, 0xd8, 0xaa, 0x47, 0x95, 0x27,
0xd7, 0x2c, 0x0f, 0x9b, 0x3a, 0x86, 0x0a, 0xa8,
0x9e, 0x9f, 0xb1, 0xf3, 0xfd, 0x3d, 0x1f, 0x95
};

// Process a doge custom mining task broadcast (type 68).
// Verifies the signature against the hardcoded doge dispatcher public key and relays if valid.
static void processBroadcastCustomMiningTask(RequestResponseHeader* header)
{
if (!header->isDejavuZero())
return;
const unsigned int messageSize = header->size() - sizeof(RequestResponseHeader);
if (messageSize <= SIGNATURE_SIZE)
return;
const unsigned char* payload = (const unsigned char*)header->getPayload<void>();
m256i digest;
KangarooTwelve(payload, messageSize - SIGNATURE_SIZE, &digest, sizeof(digest));
if (verify(dogeDispatcherPubkey, digest.m256i_u8, payload + (messageSize - SIGNATURE_SIZE)))
{
enqueueResponse(NULL, header);
}
}

// Process a doge custom mining solution broadcast (type 69).
// Verifies the signature against the sender's public key (first 32 bytes of payload)
// and relays if the sender is a computor or has enough balance.
static void processBroadcastCustomMiningSolution(RequestResponseHeader* header)
{
if (!header->isDejavuZero())
return;
const unsigned int messageSize = header->size() - sizeof(RequestResponseHeader);
if (messageSize <= SIGNATURE_SIZE)
return;
const unsigned char* payload = (const unsigned char*)header->getPayload<void>();
const m256i* sourcePublicKey = (const m256i*)payload;

m256i digest;
KangarooTwelve(payload, messageSize - SIGNATURE_SIZE, &digest, sizeof(digest));
if (verify(sourcePublicKey->m256i_u8, digest.m256i_u8, payload + (messageSize - SIGNATURE_SIZE)))
{
if (computorIndex(*sourcePublicKey) >= 0
|| (::spectrumIndex(*sourcePublicKey) >= 0 && energy(::spectrumIndex(*sourcePublicKey)) >= MESSAGE_DISSEMINATION_THRESHOLD))
{
enqueueResponse(NULL, header);
}
}
}

// Process custom mining data requests.
// Currently supports:
// - Requesting a range of tasks (using Unix timestamps as unique indexes; each task has only one unique index).
// - Requesting all solutions corresponding to a specific task index.
// - Requesting all solutions corresponding to a specific task index.
// The total size of the response will not exceed CUSTOM_MINING_RESPOND_MESSAGE_MAX_SIZE.
// For the solution respond, only respond solution that has not been verified yet
static void processCustomMiningDataRequest(Peer* peer, const unsigned long long processorNumber, RequestResponseHeader* header)
Expand Down Expand Up @@ -2286,6 +2337,18 @@ static void requestProcessor(void* ProcedureArgument)
}
break;

case BROADCAST_CUSTOM_MINING_TASK:
{
processBroadcastCustomMiningTask(header);
}
break;

case BROADCAST_CUSTOM_MINING_SOLUTION:
{
processBroadcastCustomMiningSolution(header);
}
break;

case RequestCustomMiningSolutionVerification::type():
{
processRequestedCustomMiningSolutionVerificationRequest(peer, header);
Expand Down
Loading