Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | bool Processor::forNode(NodeId nodeid, | ||||
LOCK(cs_peerManager); | LOCK(cs_peerManager); | ||||
return peerManager->forNode(nodeid, std::move(func)); | return peerManager->forNode(nodeid, std::move(func)); | ||||
} | } | ||||
CPubKey Processor::getSessionPubKey() const { | CPubKey Processor::getSessionPubKey() const { | ||||
return sessionKey.GetPubKey(); | return sessionKey.GetPubKey(); | ||||
} | } | ||||
uint256 Processor::buildLocalSighash(CNode *pfrom) const { | |||||
CHashWriter hasher(SER_GETHASH, 0); | |||||
hasher << peerData->delegation.getId(); | |||||
hasher << pfrom->GetLocalNonce(); | |||||
hasher << pfrom->nRemoteHostNonce; | |||||
hasher << pfrom->GetLocalExtraEntropy(); | |||||
hasher << pfrom->nRemoteExtraEntropy; | |||||
return hasher.GetHash(); | |||||
} | |||||
uint256 Processor::buildRemoteSighash(CNode *pfrom) const { | |||||
CHashWriter hasher(SER_GETHASH, 0); | |||||
hasher << pfrom->m_avalanche_state->delegation.getId(); | |||||
hasher << pfrom->nRemoteHostNonce; | |||||
hasher << pfrom->GetLocalNonce(); | |||||
hasher << pfrom->nRemoteExtraEntropy; | |||||
hasher << pfrom->GetLocalExtraEntropy(); | |||||
return hasher.GetHash(); | |||||
} | |||||
bool Processor::sendHello(CNode *pfrom) const { | bool Processor::sendHello(CNode *pfrom) const { | ||||
if (!peerData) { | if (!peerData) { | ||||
// We do not have a delegation to advertise. | // We do not have a delegation to advertise. | ||||
return false; | return false; | ||||
} | } | ||||
// Now let's sign! | // Now let's sign! | ||||
SchnorrSig sig; | SchnorrSig sig; | ||||
{ | { | ||||
CHashWriter hasher(SER_GETHASH, 0); | const uint256 hash = buildLocalSighash(pfrom); | ||||
hasher << peerData->delegation.getId(); | |||||
hasher << pfrom->GetLocalNonce(); | |||||
hasher << pfrom->nRemoteHostNonce; | |||||
hasher << pfrom->GetLocalExtraEntropy(); | |||||
hasher << pfrom->nRemoteExtraEntropy; | |||||
const uint256 hash = hasher.GetHash(); | |||||
if (!sessionKey.SignSchnorr(hash, sig)) { | if (!sessionKey.SignSchnorr(hash, sig)) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()) | connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()) | ||||
.Make(NetMsgType::AVAHELLO, | .Make(NetMsgType::AVAHELLO, | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |