9

I am doing coursera online course on Bitcoin and Cryptocurrency Technologies. It defines the concept of hash pointer in the first lecture as pointer to where some information is store and cryptographic hash of that information. I am confused on what is the difference between hash and hash pointer. I understand hashing of the information but how can a pointer store both the hash of the information and the address of where the information is? Please correct me if i am wrong.

Can someone explain the difference, how each is calculated and then give an example.

1

4 Answers 4

13

I believe that the use of the term "pointer" in the this sentence is not referring to the low-level data type, such as int *pointer_to_int; would be in C. I think it's more referring to a "pointer" as a key into a data structure or database table. In this sense, the hash is a pointer/key used to retrieve the information you are looking for.

For example, in Bitcoin, transaction hashes are used in this way. The hash of a transaction can both be used to look up the transaction and to verify that the transaction retrieved has not been tampered with since it was stored.

3
  • Please explain how the hash/key is used to retrieve the information you are looking for. My understanding is that hash can be used to compare the integrity of data like if a given hash matches the computed hash of the data then the data is known to be untampered. Please throw more light on how hash can act as a key? How would you retrieve the value it points to given only the hash? THanks May 20, 2016 at 18:45
  • 2
    @user2065276 you have to have a database built that uses that key already. In bitcoin, the full nodes on the network keep a database of blocks and of transaction (outputs), so they can use the hash pointers in later blocks in transactions to lookup the previous blocks/transactions.
    – morsecoder
    May 20, 2016 at 18:47
  • 3
    This of a table in the database, where each record has an ID field. Instead of using an integer value like 563, you use a hash value like 4b58bf2fdc528a32db8c82406958af828a313e162de13fe14a089f2e6a56140f. Now they ID you use to look up that record in the database can also verify that the record has not changed.
    – Jestin
    May 20, 2016 at 19:46
2

A hash is the output of a hash function, which is a one-way functions, where knowing the output doesn't help figure out what the input was. They can sometimes serve as short, unique, identifiers for the data that was passed into the function, in order to reference that data. Hash pointers are just hashes that are used to reference another piece of known information.

In bitcoin's case, one place where hash pointers are used is in the the 80 byte block header. The block header is hashed to produce a block ID. You can see this ID on any block explorer. See this for example. In the upper right side of that page there is also a link for the "Previous Block", which is a hash, and it is a hash that points to the block that has that ID.

Bitcoin also uses hashes to reference funds supplied in previous transactions. So, if you want to make a transaction giving some bitcoins to someone, you have to reference (with a hash pointer) the transaction where you were given some funds.

1

https://www.coursera.org/learn/cryptocurrency/lecture/EYEAo/hash-pointers-and-data-structures The above link has more info about Hash pointers in cryptocurrency data structures

1
  • Thanks for the answer, and welcome to Bitcoin SE! Just so you know, link-only answers are frowned upon here. Even if the topic is better explained elsewhere, it's best to give a summary of the links you post. Usually just enough to answer the initial question, and then you can link to a more detailed explanation. "Click here" answers like this are often downvoted or deleted as "low quality" or "spam". Adding just a sentence or two could make this a much better answer.
    – Jestin
    Sep 7, 2017 at 14:47
1

A hash pointer is a pointer that also has a hash of what it points to. You use the pointer to get to the next block, and the hash to check if it has been changed is some way. If you are familiar with C, then think of it as s Structure, that contains two objects, a pointer, and a hash.

Also the block chain is a linked list, but instead of using normal pointers, it uses hash pointer which give you the ability to check if anything has been changed. (a regular pointer does not, since it's only a memory address.)

http://learningspot.altervista.org/hash-pointers-and-data-structures/

https://www.youtube.com/watch?v=fOMVZXLjKYo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.