One of the current blockchains’ main features is security. User transaction information and privacy must be safeguarded by the blockchain, along with data consistency and immutability. Those are achieved by means of cryptography, which is a way of securing data against unauthorized access. Messages in the blockchain are encrypted and, in order to secure block information and their links, cryptographic hashing is used. Therefore, the focus of cryptography is ensuring the security of participants and transactions, safeguarding against double-spending. Cryptography methods consist of a set of protocols that secure information from any third party in a communication process.
Before going deeper into the kinds of cryptography, one needs to understand some basic concepts. Encryption is the conversion of normal text to a random sequence of bits. Key is some data that is required to get information from the cryptographic algorithm. And decryption, as the name implies, is the inverse process of encryption, getting the normal text back from a random sequence of bits. There are two types of cryptography: Symmetric-key and Asymmetric-Key encryption. Blockchain technology uses Asymmetric-Key encryption, which is a cryptographic method that uses different keys for the encryption and decryption processes. In the blockchain, these keys are public and private keys. The public key is shared openly and used to share information between unknown parties. The private key is kept secret and helps to decrypt messages and verify digital signatures. Private and public keys are bound by a mathematical relation, in which the private key cannot be derived from the public key, but the public key can be obtained from the private key.
With that, one must understand the roles of blockchain wallets and digital signatures. A blockchain wallet is a software or hardware that is used to keep the user’s personal and transaction information. They do not contain actual currency; they contain the user’s private keys and a transaction balance. The actual currency is stored in the blockchain’s blocks, which is the current state of the network and all of the accounts’ balances. The digital signatures are proofs that the user gives to the recipient and to the network nodes that prove the user’s legitimacy to carry out a transaction. Whenever a transaction is initiated, the user must create a unique digital signature combining the transaction data with the user’s private key with a cryptographic algorithm. With that, the authenticity of the node and the integrity of the data are guaranteed. Therefore, one can only send transactions on the blockchain with access to its private key, and the blockchain wallet acts as a communication tool between users and network.
Finally, it is also important to understand cryptographic hashing, the method that enables immutability in the blockchain. Hashing does not involve the use of keys and consists of an algorithm that receives a string of any length as input and produces a fixed length output. Hash functions are deterministic, so a specific input will always produce the same output; they also have a unique output, meaning that two different inputs cannot produce the same output. It is also impossible to derive the original input from the output of the hash function; and any small change in the input results in a completely different output. Those characteristics with the association of Merkle Trees, which are data structures that encode the whole blockchain data, allow for the verification of the blockchain data integrity and authenticity with a single hash, not needing the complete knowledge of the blockchain.