diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -249,9 +249,15 @@ } } + const CPubKey masterPubKey = peerData->proof->getMaster(); + if (masterKey.GetPubKey() != masterPubKey) { + error = _("The master key does not match the proof public key."); + return nullptr; + } + // Generate the delegation to the session key. DelegationBuilder dgb(*peerData->proof); - if (sessionKey.GetPubKey() != peerData->proof->getMaster()) { + if (sessionKey.GetPubKey() != masterPubKey) { dgb.addLevel(masterKey, sessionKey.GetPubKey()); } peerData->delegation = dgb.build(); diff --git a/test/functional/abc_rpc_avalancheproof.py b/test/functional/abc_rpc_avalancheproof.py --- a/test/functional/abc_rpc_avalancheproof.py +++ b/test/functional/abc_rpc_avalancheproof.py @@ -383,6 +383,18 @@ match=ErrorMatch.PARTIAL_REGEX, ) + # Master private key mismatch + random_privkey = ECKey() + random_privkey.generate() + node.assert_start_raises_init_error( + self.extra_args[0] + [ + "-avaproof={}".format(proof), + "-avamasterkey={}".format( + bytes_to_wif(random_privkey.get_bytes())), + ], + expected_msg="Error: The master key does not match the proof public key.", + ) + if __name__ == '__main__': AvalancheProofTest().main()