A2_2020
A2_2020
• At the top of your code, you will need to specify the version of the programming language that
you use.
• Students are to place all compilation and instructions on how to run the program inside a
README.TXT file. The markers will refer to this file when marking.
• Submission filenames are to be the same as the ones given in the assignment specifications, do
not use your own filenames.
• DO NOT post this assignment to any forum, or else you will receive 0 marks immediately.
1
1 Task One. Implementation of Trapdoor Knapsack En-
cryption Scheme (2 marks)
In this section, you are to implement a trapdoor knapsack encryption scheme. When the program
is run, it first asks for the size of the super-increasing knapsack, then the user is asked to enter the
value of each ai in the private key. Then, the user is asked to enter a modulus, follows by a multiplier.
You will need to check whether condition of the multipllier is satisfied. Then, the public key will
be generated and shown. Now, a set of message is being asked, and the ciphertext will need to be
displayed. Finally, a ciphertext will need to be asked and the correct decryption of the ciphertext
will need to be displayed. Implement this part as knapsack.cpp or knapsack.java
2
• publickey.txt
• message.txt
The file publickey.txt has four lines, which indicates: e1 , n1 , e2 , n2 from RSA algorithm. The mes-
sage.txt contains a string of characters, which needs to be signed. You need to implement two
programs: sign and verify. The sign program will sign the message (from message.txt) and read
the public keys from publickey.txt. It will ask for one input, which is user 1 or user 2, who is the
signer, and the program will ask for that user’s private key. Then, the sign program will output
signature.txt.
The verify program will take an input of publickey.txt, message.txt and signature.txt and it will
output True or False to show the verification of the ring signature.
The symmetric encryption should use the AES algorithm. You can import the AES algorithm
from the existing library or use any implementation of AES algorithm (with 10 rounds) to do this.
3
1. A blockchain node wants to compute a new block using proof-of-work.
2. SHA1 (160 bits output) is used for hash.
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 new_ledger.txt
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 first four digits of hashed value of a new valid block are 0s.
2. data parameter takes the name of a file. It contains data newly added to 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. Also, it
satisfies the condition specified when the program executed.
Submission
You need to submit one ZIP file and upload it to Moodle. In this ZIP file, you need to create six
subdirectories, in which each subdirectory will have the answer to each task. For each programming
task, write a README file that explains the compiler setting. Ideally, you should make a Makefile
for each of the tasks.
DISCLAIMER: This assignment contains an intellectual property that is owned by the University
of Wollongong. Please do not use it without the permission from the University of Wollongong. If
you have any questions, please contact the author on [email protected].
DISCLAIMER: By submitting your assignment, you DECLARE that the assignment is your
own work and you did not obtain it from any third party or even purchase it from someone else or
ask someone else to do it for you. If you violate this rule, then you may end up failing the subject
entirely.