Warning: include(/home/smartonl/royalcustomessays.com/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /home/smartonl/royalcustomessays.com/wp-settings.php on line 95

Warning: include(): Failed opening '/home/smartonl/royalcustomessays.com/wp-content/advanced-cache.php' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/smartonl/royalcustomessays.com/wp-settings.php on line 95
C++ Programming Language – RoyalCustomEssays

C++ Programming Language

fraud prevention
November 26, 2018
Music : Great Ideas in Western Music
November 26, 2018

Proof of Work
A- Project Description:
In bitcoin mining, the most important step is to find solutions for Proof of Work (POW).
In this project, you will need to simulate the mining process by implementing Proof of
Work (POW). More specifically,
– Given a POW difficulty d, your program should be able to compute a target t
based on this POW difficulty d, where the first d bits in this target are all 0s and
the rest of the bits in this target are 1s. In addition, you program should be able to
write this target to a file.!
– Given an input m and a target t, your program should be able to compute a
POW solution s, s.t.,
Hash(m||s)≤t !
where || is a concatenation operator. For example, if m = bear and s = cats, then m||s =
bearcats. !In addition, your program should be able to write this solution s to a
file.!
– Given an input m, a POW solution s, and a target t, your program should be
able to verify whether !this POW solution is a valid solution for input m.
Specifically, you program should output

!In this project, you should use SHA256 as your hash function.
B- Basic Requirements:
1- You need to write a program using the Microsoft Visual C++ 2010 express. You
can choose any IDE you like,
the code should be able to compile and run in
Windows
.!
2- Crypto Libraries: You can leverage third-party libraries, such as openssl (C/C++),
BouncyCastle (Java), etc., to implement SHA256. You do not need to build the
functions of SHA256 by yourself.

3- Program Directory: Please name your project folder as pow M12978348!
4- The recommended directories of your program should be organized as follows:
./pow_m12978348/src
./pow_m12978348/build
./pow_m12978348/data
./pow_m12978348/report.pdf
Normally, folder src should include all the source files and your own header files, e.g.,
.cpp and .h files. All the object files and executable files, e.g., .o files, should be under
folder build. Folder data has all the given files and data, and also includes all the files and
results generated by the program. In report.pdf file, you should describe which OS you
use, show which language and version you use, and illustrate how to compile, run and use
your code. In addition, you also need to include screenshots for the outputs of each
function in your report (please see details in the next section).
5- The program should be able to correctly run all the functions described in this
project.
!
6- Write comments and briefly explain each function in your code, such as inputs,
outputs, etc. You may need some of the functions in other projects. In addition,
please clearly explain how to compile and run your code, two or three lines as a
comment in your code
!
7- Take as many screenshots as required in here and include them with your work.!
8- Please submit a zip file of your code along with all required screenshots.!
C- Project Details:
In this project, you should use SHA256 as your hash function. Assume a message m
is stored in file “../data/input.txt”, and assume this message is m12978348
1. Target Generation Function:
(a) Given a POW difficulty d from the command line, compute a target t based on this
POW difficulty d, where the first d bits in this target are all 0s and the rest of the bits in
this target are 1s. Since we use SHA256 in this project, it indicates that given d, the first d
bits are 0s and the rest of 256-d bits in this target are 1s, e.g.,

You also need to print this target in the terminal, and write this target to file
“../data/target.txt”. There is no requirement in terms of the format of this target as long as
it is consistent with your read function.
(b) Take a screenshot for the output of your target generation function in step (a) by using
d = 10 and include it in your report.
2. Solution Generation Function:
(a) Read a target t from file “../data/target.txt, and read an input m from file
“../data/input.txt, find a solution s, s.t.,!
print this solution, and write this solution to file “../data/solution.txt”. Note that
even though the input message here is m12978348, your code should be generic,
i.e., it should be able to find solutions for other inputs as well.
(b) Take a screenshot for the output of your solution generation function in step (a)
by using the target generated in step 1.(a) and include it in your report.
3. Verification Function:
(a) Read an input m from file “../data/input.txt, read a solution from file
“../data/solution.txt”, read a target t from file “../data/target.txt, output and print 1 if
this solution is valid, i.e., Hash(m||s) ≤ t; otherwise, output and print 0.
(b) Take a screenshot for the output of your verification function in step (a) by using
the target generated in step 1.(a) and the solution generated in step 2.(a), and
include it in your report.
4. Performance of POW: !
(a) Given an input m (i.e., m12978348) from file “../data/input.txt”, generate 6
different solutions for 6 different difficulties. More specifically, generate a
solution si for each difficulty i, where 21 ≤ i ≤ 26. All the 6 solutions should be
different. Record and compare the running time of finding each of those
solutions, and include the solutions you found, the running time and
comparison in your report. In your report, please describe details of your
implementation, such as OS, language, crypto libraries, etc. You can use tables
or figures to present the comparison.
(b) If you could not find a solution for target 25 or 26 after running your code for
more than 6 hours, please take a screenshot and mention it in your report. In
theory, you should be able to find a solution within 6 hours by using your
computer, but there is no guarantee.

D- Examples
This section provides some examples, which can help you understand the functions
of your project. If your code can provide the same functionalities, you can customize
the number of arguments and the order of arguments, as long as you describe it
clearly in your report.
Example 1: The following command generates a target based on a difficulty
pow target d ../data/target.txt
where pow is the name of your executable file, target is the argument for target
generation function, d is difficulty, and the result of this target will be written to file
../data/target.txt. Note that, depending on where your executable file is, the paths of
your input and output files might be different.
Example 2: The following command generates a solution based on an input and a target
pow sol ../data/input.txt ../data/target.txt ../data/solution.txt
where this function reads an input from file ../data/input.txt, reads a target from file
../data/target.txt, computes a solution and writes this solution to file ../data/solution.txt.
Example 3: The following command verifies whether a solution is valid.!
Pow verify ../data/input.txt ../data/target.txt ../data/solution.txt
where this function reads an input from file ../data/input.txt, reads a target from file
../data/target.txt, reads a solution to file ../data/solution.txt, and outputs either 1 (valid) or
0 (invalid) in terminal.

Place Order