Get the Latest from CoinDesk
It is important to know how blockchain Hashing works. In order to do that, however, we need to first understand one of the core principles that go into blockchain creation.
Blockchain technology is one of the most innovative and era-defining discoveries of the past century. In order to understand how various cryptocurrencies like Ethereum and Bitcoin function. So what is hashing? In simple terms, hashing means taking an input string of any length and giving out an output of a fixed length.
In the context of cryptocurrencies like Bitcoin, the transactions are taken as input and run through a hashing algorithm Bitcoin uses SHA which gives an output of a fixed length. We are going put in certain inputs. As you can see, in the case of SHA , no matter how big or small your input is, the output will always have a fixed bits length. This becomes critical when you are dealing with a huge amount of data and transactions.
So basically, instead of remembering the input data which could be huge, you can just remember the hash and keep track. Before we go any further we need to first see the various properties of hashing functions and how they get implemented in the blockchain. A cryptographic hash function is a special class of hash functions that has various properties making it ideal for cryptography. There are certain properties that a cryptographic hash function needs to have in order to be considered secure.
This means that no matter how many times you parse through a particular input through a hash function you will always get the same result.
This is critical because if you get different hashes every single time it will be impossible to keep track of the input. The hash function should be capable of returning the hash of input quickly. What pre-image resistance states are that given H A it is infeasible to determine A, where A is the input and H A is the output hash.
We already know that it is not impossible to determine the original input from its hash value. Suppose you are rolling a dice and the output is the hash of the number that comes up from the dice. How will you be able to determine what the original number was?
Since hash functions are deterministic, the hash of a particular input will always be the same, so you can simply compare the hashes and find out the original input. But this only works when the given amount of data is very less. What happens when you have a huge amount of data? Suppose you are dealing with a bit hash.
The brute-force method basically means that you have to pick up a random input, hash it and then compare the output with the target hash and repeat until you find a match. Even if you make a small change in your input, the changes that will be reflected in the hash will be huge.
Do you see that? Even though you just changed the case of the first alphabet of the input, look at how much that has affected the output hash. This is a critical function because this property of hashing leads to one of the greatest qualities of the blockchain, its immutability more on that later.
What that means is that for the most part, each input will have its own unique hash. If you meet any random stranger out on the streets the chances are very low for both of you to have the same birthday. In other words, it is really low.
However, having said that, if you gather up people in one room, the odds of two people sharing the exact same birthday rises up astronomically. In fact, there is a chance for 2 people sharing the same birthday in this scenario! Why does that happen? It is because of a simple rule in probability which goes as follows. As you can see, it is much easier to break collision resistance than it is to break preimage resistance.
No hash function is collision free, but it usually takes so long to find a collision. Now, this is a fascinating property, and the application and impact that this one property has had on cryptocurrency are huge more on that later when we cover mining and crypto puzzles.
That probably went all over your head! It means that the distribution from which the value is chosen is hugely distributed so much so that us choosing a random value has a negligible probability.
However, if you were to choose a number between 1 and a gazillion, that is a high min-entropy distribution. Concatenation means adding two strings together. In fact, the whole process of mining works upon this more on that later. A data structure is a specialized way of storing data. There are two data structure properties that are critical if you want to understand how a blockchain works.
They are:. Pointers are variables in programming which stores the address of another variable. Usually normal variables in any programming language store data. In this case, it is storing an integer value which is This is a normal variable. Pointers, however, instead of storing values will store addresses of other variables.
Which is why they are called pointers, because they are literally pointing towards the location of other variables. A linked list is one of the most important items in data structures.
This is what a linked list looks like:. It is a sequence of blocks, each containing data that is linked to the next block via a pointer. The pointer variable, in this case, contains the address of the next node in it and hence the connection is made. The last node, as you can see, has a null pointer which means that it has no value. One important thing to note here, the pointer inside each block contains the address of the next block. That is how the pointing is achieved.
Now you might be asking what does that means for the first block in the list? Where does the pointer of the first block stay? It sort of looks like this:. As you may have guessed by now, this is what the structure of the blockchain is based on.
A blockchain is basically a linked list. The blockchain is a linked list that contains data and a hash pointer that points to its previous block, hence creating the chain. What is a hash pointer? A hash pointer is similar to a pointer, but instead of just containing the address of the previous block it also contains the hash of the data inside the previous block. This one small tweak is what makes blockchains so amazingly reliable and trailblazing.
Imagine this for a second, a hacker attacks block 3 and tries to change the data. Because of the properties of hash functions, a slight change in data will change the hash drastically. This means that any slight changes made in block 3, will change the hash which is stored in block 2, now that in turn will change the data and the hash of block 2 which will result in changes in block 1 and so on and so forth.
This will completely change the chain, which is impossible. This is exactly how blockchains attain immutability. But before that, we need to understand what a Merkle Tree is. The above diagram shows what a Merkle tree looks like. In a Merkle tree, each non-leaf node is the hash of the values of their child nodes. Leaf Node: The leaf nodes are the nodes in the lowest tier of the tree. So wrt the diagram above, the leaf nodes will be L1, L2, L3 and L4. Child Nodes: For a node, the nodes below its tier which are feeding into it are its child nodes.
Each block contains thousands and thousands of transactions. It will be very time inefficient to store all the data inside each block as a series. Doing so will make finding any particular transaction extremely cumbersome and time-consuming. If you use a Merkle tree, however, you will greatly cut down the time required to find out whether a particular transaction belongs in that block or not. Instead of going through the cumbersome process of looking at each individual hash and seeing whether it belongs to the data or not, I can simply track it down by following the trail of hashes leading up to the data:.
Miners from around the world are constantly working to make sure that the chain keeps on growing. Earlier it used to be easy for people to mine using just their laptops, but over time, people started forming mining pools to pool in their computer powers and mine more efficiently. This, however, could have been a problem.
There is a cap for each cryptocurrency, eg. There are only 21 million bitcoins out there. If the miners are allowed to carry on, at this rate, they will fish out all the bitcoins in existence. On top of that, there needs to be a specific time limit in between the creation of each blocks. For bitcoin, the time limit in between block creation is 10 mins. If the blocks were allowed to be created faster, it would result in:.
So, in order to restrict block creation, a specific difficulty level is set. Mining is like a game, you solve the puzzle and you get rewards. Setting difficulty makes that puzzle much harder to solve and hence more time-consuming. WRT bitcoins the difficulty target is a character string which is the same as a SHA output which begins with a bunch of zeroes.
Where are TXIDs used?
A Hash or also called hash function is any algorithm that maps data of arbitrary length to data of a fixed length. The values returned by a hash function are called hash values, hash codes, hash sums, checksums or simply hashes. Recent development of internet payment networks and digital money , such as Bitcoin , also uses a form of 'hashing' for checksums, and has brought additional attention to the term. Hash functions are primarily used to generate fixed-length output data that acts as a shortened reference to the original data. This is useful when the original data is too cumbersome to use in its entirety. One practical use is a data structure called a hash table where the data is stored associatively. Searching linearly for a person's name in a list becomes cumbersome as the length of the list increases, but the hashed value can be used to store a reference to the original data and retrieve constant time barring collisions. Another use is in cryptography, the science of encoding and safeguarding data.
Creating a TXID
Every transaction on the blockchain has its unique identifier called transaction hash tx hash, TX ID. You can use transaction hashes to search for your transactions on block explorer and share them with people. For example, if you search for the above hash in popular block explorer Blockchain. Take a look. Note : In any crypto wallet, trading platform. Transaction hashes can be located. Usually, this information can be found in the payment history of that wallet.
On HitBTC, the transaction hashes for your deposits and withdrawals can be found:. On the Reports page, transaction hashes are located in a separate column on the right. You don't even need to copy the hash, just click it. A block explorer page will open, showing you all the details of your transaction. These are internal HitBTC identifiers, not transaction hashes. They should see more be used for searching in block explorers.
Whitelist of withdrawal addresses How to withdraw funds What are withdrawal fees? How to locate transaction hash How to locate transaction hash What is transaction hash? Here is an example of a bitcoin transaction hash: 9a8ef1a4aefbafd02ee41df03fbcdb8e8ce2eaf5e64cb0fd7e You can use transaction hashes to search for your transactions on block explorer and share them with people.
Where do you find a transaction hash?
Creating a TXID
The blockchain only contains validated transactions, which prevents fraudulent transactions and double spending of the currency. Because of the properties of hash functions, a slight change in data will change the hash drastically. But before that, we need to understand what a Merkle Tree is. Taking the sha hash of that hash gives 3b a3 ed fd 7a 7b Then the output sends 50 BTC to a Bitcoin address expressed here in hexadecimal Cryptocurrency mining involves working with this hash. Popular Courses. Your Money. Here are the transactions and the blocks they were included in:. But the real transaction hash according to blockexplorer.