Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Recall hash puzzles from Lecture 1 0 . In this question, we will see how they work in practice. This question requires programming in a

Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This question requires programming in a language that has an implementation of SHA-256 hash function. You should use Pythons hashlib for this purpose. Let
t =2^248
Suppose solving the hash puzzle for the current block requires you to find a nonce r, an integer greater or equal to 1, such that
H (str(s)|| str(2024)|| str(r))< t
Here H is the SHA-256 hash function. The function str is the string function, i.e., given any integer s, the function str(s) casts it into a string. For example s =2024 becomes str(s)=2024. The symbol || denotes string concatenation. Suppose s is your student ID. Your strategy is to try successive values of r starting from 1, until the SHA256 of the string above falls below the target value, i.e., until you solve the puzzle.
(a) Implement a program that tries successive values of r, i.e., r =1,2,3,..., computes H (str(s)|| str(2024)|| str(r)),
compares it with t and halts whenever it is less than t, with the output r. You need to provide the program and the output r. If the value of s is different every time a new block is to be formed, what is the expected value of r before your code will find the target and why?

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

What is classification shifting?

Answered: 1 week ago