Java program to simulate Proof of Work
Budget: $50 – $70 USD
Our task is to write a simple program for simulating Proof-of-work.
The assumptions on the simulation program are as follows:
1. A blockchain node wants to compute a new block using proof-of-work.
2. Hash function is obtained from an AES or TEA encryption in CBC mode, where the key is obtained from the first 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 final ciphertext.
3. The program simulates 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 for 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
Java hashcash limit 4 data new_ledger.txt
In the above:
1. limit parameter takes the limit of the hashed value of a new block. For example, a blockchain system only accepts a block if the first four digits of the hashed value of a new valid block are 0s.
2. data parameter takes the name of a file. It contains data newly added to the current block. It should be noted that the file (new ledger.txt) 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 artificial. 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 or JSON.
Also, it satisfies the condition specified when the program is executed.
Deliverable
---------------------------------
1. The source code
2. A video file that contains the demonstration of the program.
3. Instruction to run the program.
The assumptions on the simulation program are as follows:
1. A blockchain node wants to compute a new block using proof-of-work.
2. Hash function is obtained from an AES or TEA encryption in CBC mode, where the key is obtained from the first 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 final ciphertext.
3. The program simulates 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 for 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
Java hashcash limit 4 data new_ledger.txt
In the above:
1. limit parameter takes the limit of the hashed value of a new block. For example, a blockchain system only accepts a block if the first four digits of the hashed value of a new valid block are 0s.
2. data parameter takes the name of a file. It contains data newly added to the current block. It should be noted that the file (new ledger.txt) 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 artificial. 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 or JSON.
Also, it satisfies the condition specified when the program is executed.
Deliverable
---------------------------------
1. The source code
2. A video file that contains the demonstration of the program.
3. Instruction to run the program.
Related categories:
Business, Accounting, Human Resources & Legal
Cryptography
Blockchain
Encryption