What's wrong with this iPhone 4?

My friend sold me an iPhone a few days ago.
It was in good condition. The first two days it worked great. Battery held up, no signs of jailbreaking, normal apps bought on iTunes. I logged him off his account on iTunes and I logged into mine. I downloaded a few apps and played for while. I charged it the next day and I played again. Now today, I took it to school. I was showing my buddies a funny video I had that I installed via iTunes on my computer. I proceeded to do my classwork and as soon as I left the class, I clicked the home button to go onto the lock screen. Blank.Nothing. Just a black screen. I thought it somehow discharged (I left it charging so I don't see how this was possible). My friend had iPod usb cable, so he lets me use it to charge it. All I see is the Apple logo, as if it were rebooting. Kept doing this for a long time. I unplugged it and took it home after. I tried to reset it now, hard reset and putting it in DFU mode (it worked for a bit since it changed the screen to the "Connect to iTunes" image.

Now what do I do? Any tips? Different methods of resetting I might have missed?

Added (1). Edit: I'm trying as I type this. It's starting to respond to the DFU mode but now it says that there was an error in downloading the file onto the iPhone, please try again. This has happened 3 times so far.

Restore in itunes.