merkle Trees (JAVA)

Goal: The purpose of this assignment is to write a Java program that implements a MerkleTree to be
used in a blockchain. Then you will write a brief report describing your results, in the comments of your
program; see the end of this document.

1. This assignment is self-contained. We do not expect you to know how Blockchain works. However, by
the end of this assignment, if you read the code well enough, you will learn Blockchain in detail.
2. You will be surprised how this Blockchain technology, considered revolutionary, is built on such simple
ideas that a beginner student can code. And later in life you can mention that you were writing
blockchains in your second year of undergraduate.
3. A transaction is a transfer of coins from a set of addresses (i.e., senders) to another set of addresses
(i.e., receivers).
4. Each sender or receiver is an address, which is stored in a String variable (see In
real life, people can create and use many addresses. We cannot know the owner of an address by just
looking at the string.
5. A Bitcoin transaction can have many senders and receivers. This is why transactions in Figure 1 have
dierent shape sizes. For this assignment, we simplify the transaction model to only one sender and
one receiver (see
6. A transaction has sender, receiver and amount attributes. In Bitcoin, transactions are created by ordi-
nary users and sent to a Peer to Peer network. Miners listen to the network, discover new transactions
and create blocks out of them. In this assignment, we will not have a real Peer to Peer network.
The simulates this, and returns a random number of articial transactions
whenever someone calls the collectNewTransactions() function.
7. A miner is a user (anyone can choose to be a miner) who wants to create a block. The process of
getting transactions, putting them into a block and solving the Proof-of-Work puzzle is called mining
a block.
8. Proof-of-Work (see mineTheBlock() in involves creating a string from the block-
Hash of the previous block, topHash of the MerkleTree, and a long integer (called nonce). Once the
SHA256 hash is applied to this string, a 256 bit integer is computed. If the integer is less than a
predened diculty, the nonce is said to satisfy the diculty. The block is said to be mined.
9. Any helper function that you need (e.g., to hash SHA256) is already given in the les.
What you should implement: Implement the following algorithms and methods (you can

Disclaimer: It is illegal to use the research material ordered on this website for other than research purposes. You must quote the sources appropriately. The company bears no responsibility for the use of research work, not intended for education use, the work is sold as-is with the highest quality and service available and written by freelancers.