Question
Lab 2: 30 pts Group Lab: MERKLE MADNESS Skills covered in this lab that were reviewed in class: SHA256 Hashing Merkle trees Multithreading TIP: Remember,
Lab 2: 30 pts Group Lab: MERKLE MADNESS Skills covered in this lab that were reviewed in class: SHA256 Hashing Merkle trees Multithreading TIP: Remember, don't be overwhelmed by all the details. Simply focus on one line at a time as the instructions walk you through the creation of the app. IMPORTANT GROUP GUIDANCE: There are many classes in this lab one approach is to divide up the classes initially and then share with each other your code in the Files section of your group page, and then help each other figure out what parts are correct and who needs help with their code. Be patient with each other and remember that if you happen to be a group member who is understanding things better than the others than this is an opportunity for you to help the others reach that level of understanding as well this will only help you in the long run because it makes you think about how to explain things to someone else. This is a normal process that happens on every developer team out in the industry. Each member of the group will be including in the group submission a doc with a paragraph about which part of the code was the most challenging part and why. IMPORTANT: Read bottom of this doc to understand where to turn things in for a group lab! 1. SUMMARY *** REMINDER: You can watch the video accompanying this lab as a reminder of how the game works from a users standpoint. The user first enters in the merkle root of four words the user will try to give to the merkle thread... this merkle root can be manually figured out by the user from the "NOTE" description on the top of page 2. Then a multithreaded portion of the app allows user submission of Strings on the main thread, and each of those Strings is grabbed by a Merkle or Rogue background thread depending on the users timing. If the Merkle thread gets enough words (4), then it will create a merkle tree and produce a merkle root string and if it matches the initial merkle root entered by the user, the user wins ... if it doesnt match the user loses. Meanwhile, every word the rogue thread gets is a strike. 3 strikes and the user loses. The two background threads will sleep a random number of seconds which challenges the user to time their entry just right so that the Merkle thread gets the word and not the Rogue thread. A third Monitor thread in the background will check on progress and end the app once lost or won. So it's just a simple game to allow you to get some coding experience with multithreading and Merkle roots.
2. DETAILS a. Youre creating a console app. b. Remember that its easier to prompt the user for input using the JOptionPane, which youll create a method for near the end in the Util class. This is because if you use System.in from the console text, your typing gets mixed in with the threads waking up and typing stuff to the console window. c. Classes i. MerkleManager_Test 1. AT TOP IN COMMENTS: ALL MEMBER NAMES IN GROUP 2. Will have main method and will instantiate instance of MerkleManager and call manage function... that's it. ii. MerkleManager 1. Instance variables: a. Public & static & volatile String for Users entered word. b. Public & static String for user entered expected merkle root. c. Public & static String for merkle root set to null. d. Public & static int for strikes set to 0. 2. Method: A public "manage" method and this will be called by the MerkleManager_Test class's main method. a. No inputs or outputs. b. Use Util class (that youll create later on below) to prompt user for the expected merkle root (The merkle root of the four words the user will enter later as specified down below in the UI Menu Loop). i. Put user entered text into the instance variable to hold for end of game comparison. ii. NOTE: Use https://www.xorbin.com/tools/sha256-hash-calculator to figure out merkle root of the four words you expect to use just like we do in the code: 1. EXAMPLE: H6: Merkle root / \ H4 H5 / \ / \ H0 H1 H2 H3 | | | | word1 word2 word3 word4 a. if your words were word1, word2, word3, word4, then you would enter word1 into the above web page and get the hash (H0), b. Then do the same with the others. c. Then combine each pair of hashes, so the hash of word1 (H0) together with the hash of word2 (H1), and get the hash of that long string (H4). Youll do that twice, once for the first two (H0 & H1) and once for the second two (H2 & H3). So you now have H4 & H5. d. Finally, then combine those resulting two hashes (H4 & H5) into one string in the web page entry to produce another hash this is your merkle root hash.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started