-
Describe hash functions with your own words
The process of converting an input of variable size in an output of a fixed size -
How are hash functions used in cryptocurrencies like bitcoin?
Hashing is used in generating the public key from the private key (as input). Then the public key is hashed once again to get the bitcoin address.
Hashing is also used in mining blocks of bitcoin transactions and linking them all together in the blockchain. All bitcoin transactions are organized in blocks. In order for a new block to be added to the blockchain the miners generate hashes of the block data, concatenate it with a random string (called nonce), hash it again and compare the result with another string called difficulty target (which has a certain number of leading zeros) . When the concatenated hash is smaller (the number of leading zeros) than the difficulty target, the new block is added to the blockchain. -
What does it mean when we say that hash functions need to be collision resistant?
To be infeasible to find two inputs that generate the same hash
- Encrypted representations of text wherefrom the input (the text) cannot be derived (itâs not feasible). You can see hash functions as a way to generate a digital âfingerprintâ to a specific set of data.
- Hash functions serve multiple purposes in cryptocurrencies like bitcoin. They capture an encrypted representation of a blockâs transactions, a reference to the previous block and point to the next block, and thus creating the immutable ledger. If you change anything, everything needs to change, which is not feasible.
- Collision resistant means the possibility of two hashing efforts lead towards the same hash. This possibility is very small sqrt(2^256)
-
A has function takes a given text input and generates a fixed-length output in the form of 64 hex characters, or 32 somewhat unreadable bytes. There are 95 readable (keyboard) characters in the ASCII table, so 95 keyboard characters out of each byte (or 256 possibilities), plus a few more that are symbols. Itâs just easier for humans to keep it in a hexadecimal form.
-
Hash functions are used with bitcoin to take the contents of the block, the date time, a nonce, the block version number, and the contents of the previous block to come up with a header value. This header value is then placed on the blockchain in a Merkel type hash database for easy future retrieval.
-
Hash functions should be collision resistant because if two or more strings of text âhashesâ into an output value, it makes it easier to corrupt the system. You could possibly replace a block of contents with your own contents. Very difficult to do, but if you found a collision that would suit your needs, you could grant yourself 1,000,000 (or all the) bitcoins, and break bitcoin altogether. You could also manipulate the system and grant yourself a reasonable amount of bitcoins, and no one would be any wiser.
Not exactly. It is used to cryptographically link the blocks together thus insuring validity, but it does not assure anonymity
For generating public key from the private key we use elliptic curve cryptography, not hashing. We do hash the public key to get the address
Only the hash of the previous block is really needed
Merkle tree is a tree of hashes, and is not used to store blocks but transactions within a block blocks are stored on the hard drive in binary form.
-
Hashing functions take an input of any length and generates an output of fixed length. Making ideal for cryptographic ally storing information in a secure way.
-
They are used to encrypt transactions by running them through a hashing algorithm in order to secure the data, small changes in the input changes the hash in the
chain therefore the data is kept secure by adding more data that has been hashed on the previous block increasing the difficulty to alter the information. -
Each input will have itâs own unique hash output it is hard to find two inputs that hash to the same output;
- Describe hash functions with your own words
A hash function takes an input and outputs a unique numerical âfingerprintâ for the input. Any change to the input changes the unique output.
- How are hash functions used in cryptocurrencies like bitcoin? (Try to research this on your own, we will cover this later in the course but challenge yourself and see if you can find information on this already now).
Bitcoin uses a chain of transactions called blocks representing an exchange of value like money. The chain is secured from being changed or counterfeit by running each transaction through the Secure Hashing Algorithm 256 to produce a unique fingerprint for each block and for each transaction within the block. When the data of the current block is hashed the output is recorded in the hash field of the current block as well as previous hash field of the next block. This ties each block in the chain to each of the previous blocks created. A change to any previous block or any previous transaction will change and invalidate every block that follows. Seeing the discrepancy the Bitcoin Network will reject these changes as they are now out of consensus with all the other peers on the network.
- What does it mean when we say that hash functions need to be collision resistant? (We didnât use the term âcollision resistantâ in the lecture, but you will easily find this on Google, we add this question intentionally to make you research information on your own, thatâs how you learn best)
In cryptographic hash functions all hashes need to be unique to be secure but there is a chance the hash of H(A) equals the hash of H(B). To reduce the likelihood of this possibility collision resistance is the concept that the hash algorithm uses such large lumbers, like SHA 256, that the likelihood of two different inputs producing the same output becomes so Infinitesimal that if H(A) were to equal H(B) you can just assume that A really does equal B and that it is not two different inputs sharing the same exact output.
-
Describe hash functions with your own words.
A hash function is a specialized mathematical function in which a unique input generates (according to a code) a unique output. This output very specifically represents only that input. Any changes in the input, changes the output completely. Furthermore it is unidirectional and can not be reversed. i.e. one can not generate the input if the hashed output is known. -
How are hash functions used in cryptocurrencies like bitcoin?
In cryptocurrencies, the transactions are the input files, these are hashed according to the SHA-256 algorithm to generate a highly specific output. It is this output number sequence that is added to the growing ledger. -
What does it mean when we say that hash functions need to be collision resistant?
Ideally, to be 100% perfect, each input needs to generate a unique output. However because of random chance, no system can be 100% perfect all the time. So very, rarely, 2 different inputs result in the same output - this is known as a collision and is not ideal! The hash function needs to be as free of collisions as possible to be useful so ideally hash functions need to be collision resistantwhere all inputs generate unique outputs.
- Convert any string of data into a fixed length string (eg. 256 bit in case of SHA256), in a way that is almost impossible to have the same hash from different input and extremely hard to guess the input from the corresponding hash
- Transaction data in hashed and then the miners try to find another number (nonce) that appended to the previous hash and hashed again give a number beginning with a certain number of zeros, based on the current hashing difficulty
- 2 different input should not give the same hash (very rare)
1.) Each unique input gives a unique output.
2.) Hash functions are part of the block hashing algorithm which is used to write new transactions into the blockchain through the mining process. the inputs for the function are all of the most recent, not-yet-confirmed transactions along with some additional inputs relating to the timestamp and a reference to the previous block and difficulty.
3.) A hash function is collision resistant if it is hard to find two inputs that hash the same output.
Homework on Hash Functions - Questions
-
Describe hash functions with your own words
Hash functions is a security enabled encoding for a 2 part operation or equation to basically hide or secure an input output operation,this has to be a one way to enable the security necessary during a process of transmission especially when the message or output is intended for a particular reciepient.A formula generated the hash which thus help to secure the data from tamperinf. -
How are hash functions used in cryptocurrencies like bitcoin? (Try to research this on your own, we will cover this later in the course but challenge yourself and see if you can find information on this already now).
Bitcoin uses the Secure Hash Algorithm SHA256 function which converts data to an hexadecimal output to secure the networks.The hash fucntions needs to have certain properties like:
a.)Deterministic:A specific input needs to always produce the same output to aid record keeping of the input
b.)Quick computation:For efficient system
c.)Pre-image Resistance: It should be infeasible to determine the input from the output hash function
d)Small Change in the Input changes the Hash
e)Collision Resistance
f)Puzzle friendly: Always infeasible to determine an output from concatenation or addition of two strings together -
What does it mean when we say that hash functions need to be collision resistant? (We didnât use the term âcollision resistantâ in the lecture, but you will easily find this on Google, we add this question intentionally to make you research information on your own, thatâs how you learn best).
Collission Resistance means given two different input X and Y and there respective Hash H(X) and H(Y) it should be infeasible for the two result to be the same in bitcoin cryptographic as we will be dealing with a huge data as you can see the value of bitcoin is volatile and changes rapidly and if you are sending $50 to a recipient by the time you complete the transaction you may end up sending 0.0055 Bitcoin to the recipient and vendor maybe doing the same and may end up getting either less or a fraction more bitcoin incase of the volatility factor,network fee computation or vendor charges, it will therefore be difficult for the two hashes to be the same and thus very infeasible for the data to collide on the network.
[/quote]
- Hash functions are non invertible 1-to-1 functions. They are deterministic and for every input x there will be an unique output y, thus 1-to-1. However to find x from y is a problem harder than to find a rainbow in the dark, if you do not know of Dio.
- SHA256 transforms any set of characters into a fixed length string in a deterministic way, not yet understood in detail. The algorithm is created by NSA. Doesnât prime numbers play a significant role in this?
- If two inputs generates the same output, odds are the inputs are equal. If H(m)=H(n) it is likely that m=n.
No problem, Erwin. I am glad I could help you understand better.
What do you mean by this? A recipient that receives the hash will never know what the original input/data was.
What do you mean by prime numbers? You explained what hash functions do, but can you find out how do we use them in bitcoin? They are quite important. If you canât find it, donât worry. It will all make sense later on in the course.
Thanks for your message.
I meant hash function is use to pass a secure message to a recipient in a secured manner.(especially when the message is intended for a particular recipient means others wouldnât or shouldnât have access to such message but just the intended recipient).
I hope it is clear.
Hi Bolanle.
You canât use a hash function like that. Hash functions are one way, you canât go back from a hash. If you want to send a message securely over a public network, you would need to use public and private key cryptography.
When you hash a file with SHA256, you get a fixed output of 256 bits. There is no way near enough information here to be able to go back. A hash is just a fingerprint of a file. The original data does not exist in a hash. Encrypting a message with a public key retains the content information and size. All we need to do now is to decrypt it with a corresponding private key.
I hope you understand now.
Therefore hash function is just the process of converting an input to a more secure fingerprint i.e the output right.
Yes. We still have to keep the original input. Here is a quick example.
This is our input: âMauro sent 1 bitcoin to Bolanieâ
(Sha256) Hash= 11817b76e7d8d19ca4a9bbf5b9ff469b0ac1dc722b81df0c575699d9affc1594
Letâs try to change the past.
This is our modified input: âMauro sent 0.1 bitcoin to Bolanieâ
(Sha256 )New Hash = a550df450f77d8f67747864a406c3d4d95106d2bea4107e950ad128921d6f2eb
We can easily identify that I changed the past, since the hash no longer matches.
I used this online SHA256 generator: https://emn178.github.io/online-tools/sha256.html