1. A blockchain node wants to compute a new block using proof-of-work.
2. Hash function is obtained from an AES encryption in CBC mode, where the key is obtained from the ﬁrst 128 bits of the message (which is the contents of the block). You can download the implementation of AES online, but you need to state where the source is from. The output of the hash is 128 bit, which is obtained from the ﬁnal ciphertext.
3. The program simulate the Proof-of-Work is described below.
The program for proof-of-work should perform the following:
1. The program takes at least two parameters as follows:
(a) The condition of the hash value of a new valid block (The number of leading zeros).
(b) The data newly added to the current block.
2. The program outputs a random nonce value for a new block and hashed value of the new block.
3. The program provides a function to validate the output. This function takes a random nonce and the data as inputs and outputs the hashed value to check the validity of the new block.
For example, your program can be executed with the following command
./hashcash limit 4 data [login to view URL]
In the above:
1. limit parameter takes the limit of hashed value of a new block. For example, a blockchain system only accepts a block if the ﬁrst four digits of hashed value of a new valid block are 0s.
2. data parameter takes the name of a ﬁle. It contains data newly added to current block. It should be noted that the ﬁle (new [login to view URL]) must include all necessary information to create a new block. For example, it should include at least transaction records and the hashed value of the last valid block. Note that transaction records can be artiﬁcial. This assignment does not mark the validity of the transaction records.
3. The output of the program must be human readable such as hexadecimal format. Also, it satisﬁes the condition speciﬁed when the program executed.
Programming language in C++