# Blog: Cryptography

###
The operation of all cryptocurrencies is based on cryptography, but what is cryptography? And what are public-key cryptography, digital signatures, and hash functions? This blog post delves into these issues, among others.

Last updated: 10.03.2023 15:30## Cryptography

The word cryptocurrency consists of two words, one of which is currency, which means money, and the word crypto, which in turn refers to cryptography. However, cryptography is a topic quite foreign to many people who own cryptocurrencies. The word cryptography is based on the Greek word secret or hidden, which give an indication of what kind of issues cryptography deals with.

In practice, cryptography refers to the encryption and decryption of information in the presence of third parties. Cryptography is very important in our current world, as in addition to cryptocurrencies, cryptography is used in password systems and the banking world, among other things.

## Public-key cryptography and digital signatures

In the case of cryptocurrencies, it is appropriate to familiarise ourselves with cryptography encryption methods, in particular public-key cryptography. Public-key cryptography refers to an encryption method that uses key pairs. Each of these key pairs consists of a public key as well as a private key and these keys are mathematically connected. A public key, as the name implies, refers to a key that can be freely shared without compromising the security of information. As the name implies, the private key is private, i.e., it must only be known to the owner of the information. The public-key cryptography makes possible one of the most important features of cryptocurrencies, that is, to make transfers without a third party, such as a bank.

For example, transactions on the Bitcoin network are based on public-key cryptography and digital signatures. For a bitcoin transaction, you need the public key and private key of the wallet that sends the transaction, as well as the public key of the recipient of the transaction. The person sending the transfer must prove with a private key that they are the owner of the wallet sending the transfer. Wallet ownership is verified by using a private key to make a digital signature. In this case, however, we are not talking about just any digital signature, but about a digital signature based on public-key cryptography.

A digital signature is similar in principle to a physical signature. However, a digital signature can be considered significantly more secure and reliable than a physical signature. For example, a digitally signed transaction cannot be edited afterward, as any implemented change would produce a completely different digital signature. According to the basic principle of public-key cryptography, a private key is needed to make a digital signature, but the verification of the signature can be done by anyone with the help of the public key and the signature used to make the transaction without the need for a private key.

Looking more closely at digital signatures, Bitcoin switched to digital Schnorr signatures with the Taproot update in late 2021. Compared to the previously used Elliptic Curve Digital Signature Algorithm (ECDSA) that many cryptocurrencies still use, Schnorr signatures provide Bitcoin with better computational efficiency, storage, and privacy.

## Hashing functions in cryptocurrency mining

In the mining of cryptocurrencies such as Bitcoin, hash functions such as SHA-256 are used to verify the accuracy of the information. In addition to this, SHA-256 is used to generate cryptocurrency wallet addresses. The basic idea of the SHA-256 function is that an input value of a random shape and length can be entered into the function, from which SHA-256 forms an output value of fixed length. This process is called hashing. It is possible to try on this page.

SHA-256 is a powerful function, as it is unidirectional. This means that anyone can use SHA-256 by entering the entry value and getting the output value. From this, it follows that checking the correct output value using the input value is very easy and fast. However, this does not work in the other direction, since it is practically impossible to form the original input value from the output value, since the difference of even one character in the input value makes the output value completely different. For example, the SHA-256 hash of the "The sun is shining" sentence looks like this: "56a336db21a8c589bb4b5c00ddd53d049d4e599c62a9ebff8367f56ea4d88a3a". If you add even one character after a sentence, such as a period, the hash becomes completely different. The hash for the phrase "The sun is shining." is as follows: "6205bf7bf9a44b7b7333d6436366752e562ba5e38df5cc3be77644d3b660e11e".

When mining cryptocurrencies such as Bitcoin, the SHA-256 hash function plays a very key role. In Bitcoin mining, miners, that is, highly efficient computers, compete which miner is the first to guess the right way to present a new Bitcoin block. In practice, miners guess the hash of a new block by changing the value of one variable until some miner finds a hash that is close enough to the correct one, that is, it meets the minimum network requirement at the time. The miner then gets the right to add the new block as part of the Bitcoin blockchain.

## Summary

Cryptography today is a topic that affects the daily lives of almost all people, even if they do not own or use cryptocurrencies. Public-key cryptography and digital signatures play a significant role in enabling cryptocurrency transfers without a third party. On the other hand, hash functions are enabling the mining of cryptocurrencies as well as the generation of cryptocurrency wallet addresses.

Ville Viitaharju Cryptocurrency specialist