If you restore it you lose your jailbreak and unlock. It must remain jailbroken to remain unlocked. The two go hand in hand when the device is unlocked.
Try the links below, they will guide you thru to the correct programs needed for your particular firmware/bootloader combination if it is possible:
http://www.iclarified.com/entry/index.php?enid=8603
http://www.jailbreakmatrix.com/
I am in no way affiliated with these sites and receive nothing in return if you go to them. It is just some sites I have run across and am passing them along. No strings attached
Before you do anything it is recommended that you backup your SHSH Blobs for future requirements:
How to use TinyUmbrella to save your iOS4 SHSH Blobs:
http://www.iclarified.com/entry/index.php?enid=10249
How to Backup SHSH Blobs for iPhone using firmware Umbrella (Windows):
http://www.iclarified.com/entry/index.php?enid=9194
How to Backup SHSH Blobs for iPhone using firmware Umbrella (Mac):
http://www.iclarified.com/entry/index.php?enid=9189
How to find your iPhone ECID (Windows):
http://www.iclarified.com/entry/index.php?enid=9192
How to find your iPhone ECID (Mac):
http://www.iclarified.com/entry/index.php?enid=9190