科技
您的位置:海南资讯在线 » » 科技 » 正文

代做COMP1011程序、Programming留学生程序

核心提示: COMP1011 Programming Fundamentals 2018/19 Semester 2Departme...


COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

Programming Fundamentals

Assignment 3

A Simple Blockchain

[Deadline: 23:00:00 30th April, 2019]

Background

Blockchain, a cryptographic tool, is extensively used in Fintech applications nowadays for

protecting chronological order of transactions.

The blocks are “linked” together by enforcing a specific relationship between blocks. That is,

代做COMP1011作业、Programming留学生作业代写、C/C++课程设计作业代做、c/c++编程作业调试a block must contain a “fingerprint”, which is a hash value, of the data of the previous block.

A hash function can condense arbitrary message (the block information) to a fixed size (e.g.,

160 bits) and produces a fingerprint of the message.

Hash of Block 1 Hash of Block 2 Hash of Block 3

COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

The Hong Kong Polytechnic University

- 2 -

After a block is added to the end of the chain, it can neither be removed or modified. If there

are malicious changes to the transaction data, it can be detected by checking the hash value

stored in the next block.

In short, blockchain is essentially a linked list data structure, which links the transaction data

stored in blocks. And the integrity of the blocks can be verified by using hash values.

What you have to do

Implement a Blockchain using linked list as the data structure. The following template files

have been given to you (available in Blackboard). Import the files in a new C++ project and

use them as the starting point of your code:

Blockchain.h

It is a class of linked list corresponds to the structure of block, it includes all the data

necessary to enter in a block, for example, sender, receiver, amount_of_transaction

etc. You DO NOT have to modify this file.

Blockchain.cpp

This file contains the implementation of Blockchain (linked list). This includes five functions:

1. Linked_List(). //(Constructor)

2. ~Linked_List(). //(Destructor)

3. add(). //Function to add blocks

4. print(). //Function to print the blockchain

5. Verify(). //Function to check the validity of blockchain

Consolas You DO NOT have to modify this file.

SHA1.h

This file contains the declarations of sha1. You DO NOT have to modify this file.

SHA1.cpp

This file contains the core logic of generating a 160-bit value hash value based on Secure

Hash Algorithm version 1 (SHA-1). You DO NOT have to modify this file.

Assignment_3.cpp

COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

The Hong Kong Polytechnic University

- 3 -

This file contains the main() program. Use it as a testing driver of your code. Here are some

steps you can follow in main().

1. Make some transactions by add() functions.

2. Use the verify() function to check the validity of your chain.

3. Now manipulate the data of any the blocks.

4. Now again check the validity of you chain.

You DO NOT have to modify this file.

Read carefully the details of each file first before coding. The existing coding may shed you

some light on how to code the missing parts.

The following is a visual representation of the blockchain, to be implemented by your

program:

Block

BlockData

transaction

NULL

hash of previous

transaction

Block

BlockData

transaction

Blockchain

Block

BlockData

transaction

hash of previous

transaction

hash of previous

transaction

In the real world, the hash value has to be digitally signed by the creator of the block so

changes on the hash value is not possible by the attacker. In this assignment, we just assume

the hash value cannot be changed after the block is created.

COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

The Hong Kong Polytechnic University

- 4 -

Below shows the output of Assignment_3.cpp if the implementation is successful:

Example for the use of SHA1.cpp

 It produces a string of 160 bits no matter how long or small the input is. 

COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

The Hong Kong Polytechnic University

- 5 -

Assessment

This assignment is divided into multiple levels of difficulty. Try to accomplish the

assignment from the easiest level first and proceed to the next level. It helps you break down

the problem into smaller pieces and build up the program progressively. You will be awarded

a maximum mark for each level. Only if you complete all requirement of this assignment,

you will get full marks.

Level 1 (30 marks)

 Implement the constructor Linked_List() and destructor ~Linked_List()

functions in Blockchain.cpp.

Level 2 (20 marks)

 Implement the print() in Blockchain.cpp.

Level 3 (50 marks)

 Implement the add() and verify() functions in Blockchain.cpp.

At the beginning of Assignment_3.cpp, type your information using the following C++

comment template:

//============================================================================

// Author : <your full name>

// Student No. : <your student number>

// Description : COMP1011 Assignment 3

//============================================================================

Warning: Any compilation error will be awarded ZERO mark, regardless of what you

have coded. Therefore, if you are unable to complete the whole program, try to accomplish

some of the implementations. In this case, you may edit Assignment_3.cpp as well as other

files so that the project can be compiled and the program can be run successfully.

Submission

COMP1011 Programming Fundamentals 2018/19 Semester 2

Department of Computing

The Hong Kong Polytechnic University

- 6 -

Follow the steps below:

1. Create a folder and name it as <student no>_<your name>.

E.g., 12345678d_CHANTaiMan

2. Put the following .h and .cpp files into the folder:

1. Blockchain.h

2. Blockchain.cpp

3. Assignment_3.cpp

4. SHA1.h

5. SHA1.cpp

3. Compress the folder (.zip, .7z, .rar, or .jar) and submit the compressed file to

Blackboard.

The deadline of this assignment is 23:00:00 30th April, 2019. No late submission is allowed.

This assignment is an individual work. All work must be done on your own. Plagiarism

is serious offence. The Moss (https://theory.stanford.edu/~aiken/moss/) system will be

adopted for plagiarism checking. Submissions with high similarity, in terms of code

patterns and structures, in addition to direct-copy-and-paste, will be treated as

plagiarism. Copying code from web resources is prohibited as well. Any plagiarism

cases (both copier and copiee) will be given ZERO mark in this assignment.


如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp


编辑:code




Tags:COMP 1011 程序 Programming 留学生 程序