Programming Assigment 3

profilePradhu
497_Assignment03-SumII2022.pdf

CSCI 497 Assignment 03

30 points Instruction:

• Show your work (at least 50% penalty otherwise)

• Submit a single Word (.doc or .docx) document containing all your answers to the designated folder (“Assignment #3”) under Assignments (at least 10% penalty otherwise). Neither PDF documents nor documents in other formats would be accepted.

• Make sure if you submitted the intended one. It is recommended that you download what has been uploaded and double-check if the correct document has been submitted.

• You can submit as many times as you want, but the last submission will only be graded. If the last submission is made after the deadline, there should be a late submission penalty.

• No plagiarism: Do not copy and paste any from textbooks and other resources to answer questions (Zero will be given otherwise).

• No extension/resubmission request will be accepted.

Note: The instructor and TA will welcome your questions to clarify homework problems but do not ask if what you answered is correct. We may not reply from Friday evening to Monday morning.

Problem 1 Proof-of-Work Algorithm and Hash Puzzle

As we have discussed in our lectures, Bitcoin achieves proof‐of‐work using hash puzzles. In order to create a block, the node that proposes hat block is required to find a number, or nonce , such that when you concatenate the nonce, the previous hash, and the list of transactions that comprise that block and take the hash of this whole string, then that hash output should be a number that falls into a target space that is quite small in relation to the much larger output space of that hash function. In this assignment, we will concentrate on a simple implementation of proof-of-work algorithm and its improvement by addressing following questions.

a. Hash a string containing your CWID and full name using SHA-256 and show its hash value containing only hexadecimal digits using the hexdigest() method included in the module “hashlib”. Provide the source code, hash value, and the captured screenshot in your submitted document.

Hashlib module: https://docs.python.org/3/library/hashlib.html

b. Add a nonce (number) to the end of the string created in 1(a) and calculate the hash of the input (string+nonce) by iterating the nonce (number) from 0 to 30. Provide the source code and captured screenshot of program outputs in your submitted document.

c. Based on the implementation of a simplified proof-of-work algorithm is included in the file” pow.py”, set the string created in 1(a) in your new block and provide the statement and captured screenshot in your submitted document.

d. Based on the changes made in 1(c), test the program. Provide the source code and program output in your submitted document

e. Set the maximum difficulty (in bits) to 15 bits and maximum nonce to 2^{16}. Test the program. Provide the source code and program output in your submitted document.