ITunes Error 1015 after downgrading iPhone to 3.1.3

My iPhone OS was upgraded to OS 4 but because I accidentally restore it, I have to downgrade it again to 3.1.3. But now I get stuck with “iTunes Error 1015”. Any ideas on how to fix it please let me know. Thanks.
