Security and Privacy in Blockchains