Blockchain Primitives: Cryptography and Consensus