Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4. Mining (18 points] The hash target is used in mining. It is a number that a block hash must be below for the block

image text in transcribed

Q4. Mining (18 points] The hash target is used in mining. It is a number that a block hash must be below for the block to be valid in order for it to be added on to the blockchain. Assume that the hash target is 256=243. In other words, each block hash has to start with 8 zeros (as the most significant bits). To hash a block, the fields are concatenated in the same order. For example, the "Current Block Hash" for the block with ID=1 is the hash of the value "1002262Ahmad". a. [6 points) Fill replace "???" by appropriate values to make the blockchain a valid one. Head Hash: Head Pointer: ??? 4 Prex ID Prex Hash Nonce Data Current Block Hash 2 ??? ??? Hessa ??? 001ecdf2e0b2b7b7c51701385d99d58eaeccbabea16061a0ef2cfb91f0308336 ID Prex ID Prex Hash Nonce Data Current Block Hash ??? $$Name$$ ??? 0 A null Prex ID Prex Hash Nonce Data Current Block Hash 0 2261 Ahmad 001ecdf2e0b2b7b7c51701385d99d58eaeccbabea16061 a0ef2cfb91fb308336 b. [6 points] Find the average time for mining a block for each of the following hash targets. Measure the time in terms of both the number of hash computations as well as in seconds on your machine. Report your results as an average for mining 10 different blocks. Fill the table below. 1. Hash target = 28 2. Hash target = 212 3. Hash target = 216 Hash Target Average number of hash computations to mine a block (average over 10 blocks) Average time in seconds to mine a block (average over 10 blocks) 28 = 256 212= 4,096 216= 65,536 c. [6 points) Show the source code of a full program to mine one block. The block follows the format of the blocks shown in part (a) of this question. In the program, you initialize the values of the fields ID Prev ID Prev Hash Data It computes and prints the Nonce and the Current Block Hash values. You can use a programming language of your choice. Q4. Mining (18 points] The hash target is used in mining. It is a number that a block hash must be below for the block to be valid in order for it to be added on to the blockchain. Assume that the hash target is 256=243. In other words, each block hash has to start with 8 zeros (as the most significant bits). To hash a block, the fields are concatenated in the same order. For example, the "Current Block Hash" for the block with ID=1 is the hash of the value "1002262Ahmad". a. [6 points) Fill replace "???" by appropriate values to make the blockchain a valid one. Head Hash: Head Pointer: ??? 4 Prex ID Prex Hash Nonce Data Current Block Hash 2 ??? ??? Hessa ??? 001ecdf2e0b2b7b7c51701385d99d58eaeccbabea16061a0ef2cfb91f0308336 ID Prex ID Prex Hash Nonce Data Current Block Hash ??? $$Name$$ ??? 0 A null Prex ID Prex Hash Nonce Data Current Block Hash 0 2261 Ahmad 001ecdf2e0b2b7b7c51701385d99d58eaeccbabea16061 a0ef2cfb91fb308336 b. [6 points] Find the average time for mining a block for each of the following hash targets. Measure the time in terms of both the number of hash computations as well as in seconds on your machine. Report your results as an average for mining 10 different blocks. Fill the table below. 1. Hash target = 28 2. Hash target = 212 3. Hash target = 216 Hash Target Average number of hash computations to mine a block (average over 10 blocks) Average time in seconds to mine a block (average over 10 blocks) 28 = 256 212= 4,096 216= 65,536 c. [6 points) Show the source code of a full program to mine one block. The block follows the format of the blocks shown in part (a) of this question. In the program, you initialize the values of the fields ID Prev ID Prev Hash Data It computes and prints the Nonce and the Current Block Hash values. You can use a programming language of your choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago