Answered step by step
Verified Expert Solution
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 In this question, we will see how they work in practice. This question requires programming in a language that has an implementation of SHA hash function. You should use Pythons hashlib for this purpose. Let
t
Suppose solving the hash puzzle for the current block requires you to find a nonce r an integer greater or equal to such that
H strs str strr t
Here H is the SHA hash function. The function str is the string function, ie given any integer s the function strs casts it into a string. For example s becomes strs The symbol denotes string concatenation. Suppose s is your student ID Your strategy is to try successive values of r starting from until the SHA of the string above falls below the target value, ie until you solve the puzzle.
a Implement a program that tries successive values of r ie r computes H strs str strr
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started