I don't think it's actually illegal. Apple has simply stated that they will not provide support for any iPhone that has been jailbroken. It's your hardware...they won't 'brick' it if you jailbreak it...they just wont fix it if it has problems later on. Not sure about them being able to detect after some of the methods of 'restoring.'