I wasn't sure how they could figure this out at the time until someone later pointed out that many corporations do a credit history check on you as part of the background check. This gives them access to past compensation.
The information asymmetry here is, as with much of hiring, pretty bonkers when they had both the current and past comp history during negotiations when you have just yours. You might also have the comp history of your friends too (if you share) but that's still tiny compared to the corporations.
0 - this was in NYC where it's now no longer allowed.