Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,924 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAHELLO) { | ||||
BCLog::AVALANCHE, | BCLog::AVALANCHE, | ||||
"Ignoring avahello from peer %d: already in our node set\n", | "Ignoring avahello from peer %d: already in our node set\n", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
return; | return; | ||||
} | } | ||||
pfrom.m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | pfrom.m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | ||||
CHashVerifier<CDataStream> verifier(&vRecv); | |||||
avalanche::Delegation delegation; | avalanche::Delegation delegation; | ||||
verifier >> delegation; | vRecv >> delegation; | ||||
avalanche::DelegationState state; | avalanche::DelegationState state; | ||||
CPubKey &pubkey = pfrom.m_avalanche_state->pubkey; | CPubKey &pubkey = pfrom.m_avalanche_state->pubkey; | ||||
if (!delegation.verify(state, pubkey)) { | if (!delegation.verify(state, pubkey)) { | ||||
Misbehaving(pfrom, 100, "invalid-delegation"); | Misbehaving(pfrom, 100, "invalid-delegation"); | ||||
return; | return; | ||||
} | } | ||||
CHashWriter sighasher(SER_GETHASH, 0); | CHashWriter sighasher(SER_GETHASH, 0); | ||||
sighasher << delegation.getId(); | sighasher << delegation.getId(); | ||||
sighasher << pfrom.nRemoteHostNonce; | sighasher << pfrom.nRemoteHostNonce; | ||||
sighasher << pfrom.GetLocalNonce(); | sighasher << pfrom.GetLocalNonce(); | ||||
sighasher << pfrom.nRemoteExtraEntropy; | sighasher << pfrom.nRemoteExtraEntropy; | ||||
sighasher << pfrom.GetLocalExtraEntropy(); | sighasher << pfrom.GetLocalExtraEntropy(); | ||||
SchnorrSig sig; | SchnorrSig sig; | ||||
verifier >> sig; | vRecv >> sig; | ||||
if (!pubkey.VerifySchnorr(sighasher.GetHash(), sig)) { | if (!pubkey.VerifySchnorr(sighasher.GetHash(), sig)) { | ||||
Misbehaving(pfrom, 100, "invalid-avahello-signature"); | Misbehaving(pfrom, 100, "invalid-avahello-signature"); | ||||
return; | return; | ||||
} | } | ||||
// If we don't know this proof already, add it to the tracker so it can | // If we don't know this proof already, add it to the tracker so it can | ||||
// be requested. | // be requested. | ||||
const avalanche::ProofId proofid(delegation.getProofId()); | const avalanche::ProofId proofid(delegation.getProofId()); | ||||
▲ Show 20 Lines • Show All 2,157 Lines • Show Last 20 Lines |