Cryptography CS 411& CS 507 Term Project Phase II

$30.00

Download Details:

  • Name: TERM-PROJECT-II-fj4r3p.zip
  • Type: zip
  • Size: 346.17 KB

Category:

Description

Rate this product

Phase II: Developing software for transaction and implementing
proof of work
In this phase of the project, you are required to generate a block of random transactions and Proofof-Work for the block. The details are given in the following subsections. For further information
about bitcoin and blockchain, please refer to bitcoin.pptx provided in the assignment package.
2
3.1 Transaction
A transaction contains information of a payment (transaction) from the payer to the payee and is
in the following format:
*** Bitcoin transaction ***
Serial number:
Payer public key (beta):
Payee public key (beta):
Amount:
Signature (s):
Signature (h):
Explanations of these fields are as follows
Serial Number: is a uniformly randomly generated 128-bit integer
Payer public key (beta): is the public key of the person making the payment
Payee public key (beta): is the public key of the person receiving the payment
Amount: is the amount in Satoshi being transferred in range [1, 1000000]
Signature (s): Signature (s part) of the transaction by Payer
Signature (h): Signature (h part) of the transaction by Payer
Note that the payer and payee are identified by their public keys in the transaction, which is
signed by the private key of the payer. Therefore, the transaction can be verified by the public
key of the payer. For the signature you are required to use the set of public parameters in file
“pubparams.txt” provided in the assignment package. A sample block of random transactions is
given in file “transactions sample.txt” also provided in the assignment package.
In this part of the project, you are required to generate random transactions and write those
transactions into a file named “transactions.txt”. For this, you will develop a function named
“gen random tx(q, p, g)”. You have to test your transactions in “transactions.txt’ using
CheckBlock() function in Test code “PhaseII Test.py’ before submission.’
As a deliverable, you are required to submit a file with the name “Tx.py” that should include
the function
“gen random tx(q, p, g)”
that will take the public parameters and output a random transaction in the format defined above.
3.2 Implementing Proof-of-Work (PoW)
In cryptocurrency systems, blockchain network members (a.k.a. miners) approve transactions by
running the proof-of-work (PoW) algorithm. The PoW algorithm is a consensus protocol that determines who will write the next block of the transactions to the blockchain. All miners participate
in the protocol as they receive a commision if they win.
A miner reads a block of transactions, adds a random number called nonce at the end and tries
to compute a hash value of the special form. In particular, the hash value must start with x 0 bits;
i.e., if you print the hash value with “hexdigest()”, the first PoWLen = x/4 hexadecimal digits
must be 0 (pick x a multiple of 4). The hash value with this property is known as Proof-of-Work
or shortly PoW. To find PoW, the miner tries different nonce values chosen at random.
The miner, who comes up with such hash value first, wins the right to add the block to the
chain and thus recevies the commision. A sample block is given in file “block.txt” with x = 20
3
provided in the assignment package.
You are required to write a function (with the name “PoW”) that reads the transactions in the
file “transactions.txt” and computes a PoW for the block. PoWLen must be at least 5. Once your
programs finds the PoW for the block, it appends the nonce at the end of the block and writes it
into a file with the name “block.txt”. A sample block is provided in the file “block sample.txt” in
the assignment package.
You are strongly recemmended to test your codes with the test functions in “PhaseII Test.py”
before submission as we will use it to test your codes. If your codes will not pass the tests in
“PhaseII Test.py”, you will get no credit in this phase of the project.
Finally, as generating PoW takes quite some time, you are recommended to test your codes
with smaller PoWLen first such as PoWLen = 3 to make sure your code is working. Then you try
larger PoWLen.
3.3 Bonus I – Competition
The group that will submit a block with the longest PoW will recieve an extra 10% in this Phase.
Submit your block in the file “block.txt”. To qualify for the competition, PowLen must be at least
7. In case of tie, the earliest submission wins. Make sure that “block.txt’ is testable by the “Test
II” in “PhaseII Test.py”.
4 Appendix I: Timeline & Deliverables & Weight & Policies etc.
Project Phases Deliverables Due Date Weight
Project announcement 07/12/2018
First Phase Source code (DS.py) 14/12/2018 25%
Second Phase Source codes 21/12/2018 40%
( Tx.py and PoW.py)
Bonus – I block.txt 21/12/2018 10%
Third Phase TBA 28/12/2018 TBA
Bonus – II TBA 28/12/2018 TBA
4.1 Policies
• You may work in groups of two.
• You may be asked to demonstrate a project phase to a TA or the instructor.
• In every phase, we will provide you with a validation software in python language that can
be used to check your implementation for correctness. We will also use it to check your
implementation. If your implementation in a project phase fails to pass the validation, you
will get no credit for that phase.