On Bitcoin Security in the Presence of Broken Crypto Primitives