Home » Blog » Cryptography and its role in blockchain security
Cryptography and its role in blockchain security
3202 ,41 lirpA

Cryptography and its role in blockchain security

Blockchain operators are always looking for better security options, which, among other things, often involve cryptography. Cryptographic hashing functions (which receive a data input of a random size and give back a hash of a certain size, always of the same length) are the key focus. These hashes work as unique identifiers for blockchain blocks, playing a significant role in blockchain security. They are created depending on the previous blocks’ hash. Generation of a block’s hash is based on the data contained in the block itself and the previous block’s hash. The result is a chain of linked blocks.

Hash functions also play a role in consensus algorithm processes — for example, the PoW algorithm uses a specific hash function. Hashing is commonly used to comply with the four key requirements:verification and confirmation of balances of the users’ wallets, wallet addresses’ encryption, transaction encryption and mining of blocks by means of creating mathematical puzzles, which should be solved to generate the block.

A correct block hash needs to contain the following data:

  • Merkle root (hash of all transactions added to the block, which a certain Merkle tree contains)
  • ‘Nonce’ (a free combination of symbols, helping to create the hash, which suits the current purpose and matches the current complexity). The complexity of the Nonce guessing is sometimes regulated by PoW blockchains to reach a specific block generation frequency.
  • Previous block hash (which was verified before)
  • Supplementary metadata (which may include various additional information, such as the current software version, time stamps, the degree of complexity of mining, current block number, etc.)

Another major role of cryptography lies in the field of wallet security. It helps to ensure the security of stored assets. The public and private keys are generated with the help of asymmetric cryptography.

Cryptography is used to generate unique digital signatures which serve as a personal identification in the network (via mathematical functions, which refer to certain wallets).

Use of cryptography on a blockchain

As mentioned above, cryptography is used to secure blockchains quite often and there are a number of use cases. It’s worth taking a closer look at them:

  • Authentication and transaction verification. In this case so-called asymmetric cryptography is used, providing the user with a secure key pair (as a user needs both keys to validate transactions, when a private key is used to encrypt and the public one to decipher). With the help of a cryptographic function a unique digital signature is generated by using two sources (transaction data hash and the private key), which is later added to the transaction data. This digital signature is used for verification. The digital signature verification protocol combines the transaction hash and the hash received after the digital signature deciphering, and validates the transaction only if they match. The combination of hashing and asymmetric encryption guarantees that the key owner has a right to access the assets, stored on blockchain, while making the access secure and protecting the assets from the misuse or malicious attempts of stealing.
  • Block creation (and resistance to Sybil attack). None block creation process can do without proper hash generating. The competition among the miners to be the first to create the proper hash takes place on PoW blockchains. The same method is used to prevent the so-called Sybil attack (when a certain person takes the block creating process under control by means of making fake identities). The hashing process involves a relevant (huge) amount of calculations, which helps to prevent ‘denial-of-service’ attacks, but on the other hand requires a relevant amount of ‘work’ by the participants (miners). PoS blockchains also generate hash, but unlike the PoW ones, the competition is not based on work, but on the stake amount. It prevents a Sybil attack by requiring users to put up stakes to take part in the block creation process.
  • Data storage. The longer a blockchain works, the longer its registries are and the more data storage and synchronization cost. To make data storage and encryption more secure, so-called Merkle trees are used, where each transaction is hashed, then compared to another hashed transaction and then hashed again. The hashes are constantly ‘re-hashed’ until a ‘hash of hashes’ appears (it is called a Merkle root). In Bitcoin Merkle trees are used with transactions based on Unspent transaction output (or UTXO) model, while Ethereum uses them for transactions with the account model with generalized support of smart contracts. These trees are very convenient and useful, they occupy comparatively little disk space and help to carry out efficient data integrity checks and insertion of the data into the blockchain. Merkle roots are included into block headers and help to check if a certain transaction was included into the block, quickly and securely.
  • Zero-knowledge proof (ZKP). This method allows one user to convince another that the former has certain knowledge about certain pieces of information without disclosure of any specifics (for example, nodes can validate transactions without having information about the sender, the addresses or the transaction amount).
  • Trusted execution environment (TEE). It means using trusted equipment for confidential calculations, where their consistency may be proved with cryptographic certificates (for example, validator nodes on a blockchain use trusted execution environments to ensure smart contract confidentiality during operation)
  • Threshold signature scheme (TSS). It is a technique of shared generation of keys, which is used for calculation authentication in a decentralized network by means of a cryptographic signature (for that a threshold number of participants is necessary). For example, a transaction must be verified by only a half of nodes to be validated. 

We use cookies on our website to improve user experience and analyze website traffic. By clicking “Accept“, you agree to our website's cookie use as described in our Privacy Policy.