As far as I understand it the difficulty will be adjusted according to how long it took to generate a certain amount of blocks. The time the generation of these blocks took will be determined by the timestamps of the blocks.
Yes.
My question now is: Why don't miners simply use wrong timestamps in order to exaggerate how long it took to generate the certain amount of blocks? So instead of putting the actual time into a block they simply take some date that is still in the future, e.g. one year from now. Then generating our certain amount of blocks did not take 2 weeks but more than one year.
As a consequence the difficulty would have to go down, wouldn't it?
It is impossible for the blocks to deviate from the time by more than 2 hours. Nodes will reject any blocks that:
- Have a lower timestamp than the median of the previous 11 blocks
- Deviate from the network adjusted time (Average time given by the nodes connected) by 2 hours.
Any nodes that see your blocks will not see it as valid if they fit any of the two criteria above.