Download the correct 3.1.2 IPSW file (the internet can find the link for you), then hold down Option (I think) when you click Restore in iTunes, then you can pick the IPSW you want to use, so use the one you downloaded.
In fact, it might still be on your computer. I don't remember the name of the folder where iTunes stores the IPSWs, though.