Question: *********JAVA we are given a message, M, and the current time, T, and we must generate some set of bytes R such that SHA256(M +

*********JAVA

we are given a message, M, and the current time, T, and we must generate some set of bytes R such that SHA256(M + R + T) have a certain number of starting bits, P, set. for example, if P=1, you could set R to nothing and just hash SHA256(M+T) together and you have a 50% chance of getting the first bit set. if the resulting first bit is set, you will change R to something else and try again. the idea is to keep changing R until you get the right number of unset bits at the beginning of the hash result.

for this assignment you will need to implement the single method doWork() in the ProofOfWork.java class.( see code below ) it returns the R that you found that produces the correct hash result.

uploaded a ProofOfWorkTest.java for running test cases.

In JAVA

public class ProofOfWork {

/**

* find an array of bytes such that the SHA256 hash of the message,

* bytes, and time bytes will produce a result where the first

* numberOfUnsetBits will be unset (0).

*

* @param message the message bytes.

* @param time the time bytes.

* @param numberOfUnsetBits the number of initial bits of the hash

result

* that must be unset (equal to 0).

* @return the array of bytes that will produce numberOfUnsetBits

initial

* zero bits from SHA256(message + bytes + time).

*/

static byte []doWork(byte message[], byte time[], int

numberOfUnsetBits) {

return null;

}

}

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!