Question: Please solve it in python code and the student ID is 4 5 5 2 3 6 9 7 . In this question, we will

Please solve it in python code and the student ID is 45523697. 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) k str(2024) k 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 k 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) k str(2024) k 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.
b) 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!