Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | if (argsman.IsArgSet("-avaproof")) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
if (!VerifyProof(*peerData->proof, error)) { | if (!VerifyProof(*peerData->proof, error)) { | ||||
// error is set by VerifyProof | // error is set by VerifyProof | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
const CPubKey masterPubKey = peerData->proof->getMaster(); | std::unique_ptr<DelegationBuilder> dgb; | ||||
if (masterKey.GetPubKey() != masterPubKey) { | const CPubKey &masterPubKey = masterKey.GetPubKey(); | ||||
error = _("The master key does not match the proof public key."); | |||||
if (argsman.IsArgSet("-avadelegation")) { | |||||
Delegation dg; | |||||
if (!Delegation::FromHex(dg, argsman.GetArg("-avadelegation", ""), | |||||
error)) { | |||||
// error is set by FromHex() | |||||
return nullptr; | |||||
} | |||||
if (dg.getProofId() != peerData->proof->getId()) { | |||||
error = _("The delegation does not match the proof."); | |||||
return nullptr; | return nullptr; | ||||
} | } | ||||
if (masterPubKey != dg.getDelegatedPubkey()) { | |||||
error = _( | |||||
"The master key does not match the delegation public key."); | |||||
return nullptr; | |||||
} | |||||
dgb = std::make_unique<DelegationBuilder>(dg); | |||||
} else { | |||||
if (masterPubKey != peerData->proof->getMaster()) { | |||||
error = | |||||
_("The master key does not match the proof public key."); | |||||
return nullptr; | |||||
} | |||||
dgb = std::make_unique<DelegationBuilder>(*peerData->proof); | |||||
} | |||||
// Generate the delegation to the session key. | // Generate the delegation to the session key. | ||||
DelegationBuilder dgb(*peerData->proof); | |||||
const CPubKey sessionPubKey = sessionKey.GetPubKey(); | const CPubKey sessionPubKey = sessionKey.GetPubKey(); | ||||
if (sessionPubKey != masterPubKey) { | if (sessionPubKey != masterPubKey) { | ||||
dgb.addLevel(masterKey, sessionPubKey); | dgb->addLevel(masterKey, sessionPubKey); | ||||
} | } | ||||
peerData->delegation = dgb.build(); | peerData->delegation = dgb->build(); | ||||
if (!VerifyDelegation(peerData->delegation, sessionPubKey, error)) { | if (!VerifyDelegation(peerData->delegation, sessionPubKey, error)) { | ||||
// error is set by VerifyDelegation | // error is set by VerifyDelegation | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
} | } | ||||
// We can't use std::make_unique with a private constructor | // We can't use std::make_unique with a private constructor | ||||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |