Edit: this reply is written assuming you might be asking about ‘SPV’ or ‘gentle pockets’ implementations, not a full node implementation
How do I do know that that exact (malicious) node has the latest or legitimate blockchain?
That is two separate questions: are you updated? And is the data legitimate?
Updated: it’s doable for gentle wallets to question information from a number of community friends, although not each implementation will achieve this. This helps guarantee no single node is ‘mendacity by omission’, which implies they’re withholding data from you (Fascinating associated information: ‘fraud proofs’ are apparently very, very tough to craft. It’s an ongoing space of analysis within the discipline). In case you are solely related to malicious nodes, this may increasingly develop into a difficulty, although in follow it isn’t a tough challenge to beat (see: Sybil assaults / eclipse assaults).
Some gentle wallets will hook up with a server run by the builders of that pockets, whereas others will join on to a node(s) within the bitcoin community. Utilizing a service that doesn’t hardcode their very own server into the pockets might be higher, although in the event that they observe a normal HD pockets scheme it needs to be no drawback importing your seed phrase to a unique pockets in case that service goes down.
I believe the most effective recommendation is to run your personal node. Many gentle wallets permit you to level your pockets at your personal node as a guide setup possibility. This provides you sovereignty, and tremendously elevated privateness as effectively.
Validity: gentle wallets work by downloading the chain of block headers, after which requesting information associated to the pockets’s tackle’ from related nodes. By solely downloading the blockheaders, useful resource utilization stays low sufficient for the pockets to work on cellular (lower than 100mb for your complete bitcoin historical past, at present).
The header comprises the transaction merkle root, which can be utilized to regionally confirm {that a} legitimate transaction is included in a sure block, with out having all of that block’s information. A node will serve the transaction in query to the pockets, together with the intermediate hashes within the merkle tree. This enables the node to recalculate the merkle root regionally, giving proof that the transaction is confirmed on the bitcoin community (and thus legitimate in response to the community’s guidelines). If even one bit of knowledge is modified, the merkle root will likely be calculated in a different way, and the pockets will know the transaction served is invalid.