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

63 66 0
thuc hanh an toan thong tin khoa cong nghe thong tin da nang

Đ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

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ó.

THỰC HÀNH HỆ THỐNG BLOCKCHAIN Lab Getting Started with Multichain 1.1 Introduction 1.2 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 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 Transaction metadata 3.1 Introduction 3.2 Lab Instruction Lab Atomic exchange transactions 4.1 Introduction 4.2 Lab Instruction 4.2.1 Create the second asset 4.2.2 Check your assets: listassets 4.2.3 Create a locked transaction output containing unit of asset04 4.2.4 Create a locked transaction output containing 50 units of asset01: 4.2.5 Prepare the exchange transaction 4.2.6 Verify the exchange Lab Round-robin mining Lab Multichain Web 6.1 Issuing an Asset 6.2 Sending Coins to the Secondary Node 6.3 Granting Permissions to the Secondary Node 6.4 Sending Coins to the Secondary Node 6.5 Issuing Another Asset 6.6 Preparing an Atomic Exchange Transaction 6.7 Performing the Exchange 6.8 Viewing the Secondary Node Lab 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 1.2 Creating a blockchain on the First Server mchain11 (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 Hình Sơ đồ kết nối hệ thống multichain 1.2.1 Create a new blockchain named chainTuong01 // Tạo chain CHÚ Ý: Thay XYZ tên username@mchain11:~$ multichain-util create chainTuong01 MultiChain 2.0 beta 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 user02 drwxr-xr-x 46 root -rw - user02 -rw-r r user02 -rw-r r user02 drwx user02 drwxr-xr-x user02 -rw-r r user02 username@mchain11:~$ ubuntu root ubuntu ubuntu ubuntu ubuntu ubuntu ubuntu 4096 4096 2106 220 3637 4096 4096 675 Feb Feb Feb Apr Apr Feb Feb Apr 25 18 18 8 25 25 16:56 16:29 19:38 2014 2014 16:56 17:04 2014 .bash_history bash_logout bashrc cache multichain profile //Xem nội dung thư mục multichain vừa tạo username@mchain11:~$ ls -la multichain/ total 16 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:06 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:06 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:06 -rw-r r user02 ubuntu Feb 25 17:06 username@mchain11:~$ chainTuong01 multichain.conf // Tạo thêm chain username@mchain11:~$ multichain-util create chainTuong02 username@mchain11:~$ ls -la multichain/ total 16 drwxr-xr-x user02 ubuntu drwxr-xr-x user02 ubuntu drwxr-xr-x user02 ubuntu drwxr-xr-x user02 ubuntu -rw-r r user02 ubuntu username@mchain11:~$ 4096 4096 4096 4096 Feb Feb Feb Feb Feb 25 25 25 25 25 17:06 17:06 17:06 17:06 17:06 chainTuong01 chainTuong02 multichain.conf 1.2.2 View the blockchain's default settings These can also be modified but we recommend using the defaults for now: // Xem thông số mặc định chain file params.dat username@mchain11:~$ cat ~/.multichain/chainTuong01/params.dat # ==== MultiChain configuration file ==== # 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 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-version = [null] genesis-timestamp = [null] genesis-nbits = [null] genesis-nonce = [null] genesis-pubkey-hash = [null] hash genesis-hash = [null] chain-params-hash = [null] accidental changes username@mchain11:~$ # # # # # # Genesis Genesis Genesis Genesis Genesis Genesis block block block block block block coinbase output public key version timestamp difficulty (nBits) nonce coinbase output public key # Genesis block hash # Hash of blockchain parameters, to prevent username@mchain11:~$ multichaind chainTuong01 -daemon MultiChain 2.0 beta 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 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 1.3 Connecting to a blockchain from the second machine mchain12 (192.168.0.12) 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 cổng 5745 username@mchain12:~$ multichaind chainTuong01@192.168.1.11:5745 -daemon MultiChain 2.0 beta 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: multichain-cli chainTuong01 grant 1ZuwYh6zaHWRn9SMed1zZRMyUWdVwyiXyYoswu connect multichain-cli chainTuong01 grant 1ZuwYh6zaHWRn9SMed1zZRMyUWdVwyiXyYoswu connect,send,receive username@mchain12:~$ You should be told that the blockchain was successfully initialized, but you 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 user02 ubuntu 4096 Feb 25 drwxr-xr-x 43 root root 4096 Feb 18 -rw - user02 ubuntu 333 Feb 18 -rw-r r user02 ubuntu 220 Apr -rw-r r user02 ubuntu 3637 Apr drwx user02 ubuntu 4096 Feb 25 drwxr-xr-x user02 ubuntu 4096 Feb 25 -rw-r r user02 ubuntu 675 Apr 17:08 16:54 19:38 2014 2014 16:56 17:08 2014 .bash_history bash_logout bashrc cache multichain profile username@mchain12:~$ ls -la multichain/ total 12 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:08 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:08 drwxr-xr-x user02 ubuntu 4096 Feb 25 17:08 -rw-r r user02 ubuntu Feb 25 17:08 username@mchain12:~$ chainTuong01 multichain.conf Back on the first server mchain11, add connection permissions for this address: username@mchain11:~$ multichain-cli chainTuong01 grant 1ZuwYh6zaHWRn9SMed1zZRMyUWdVwyiXyYoswu connect {"method":"grant","params": ["1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL","connect"],"id":"119023021549766750","chain_name":"chainTuong01"} 3322dae2f379eed908d6765fc1dc4cccf3fa3d6780e564291def3b254bf9adb7 username@mchain11:~$ Now try reconnecting again from the second server mchain12: username@mchain12:~$ multichaind chainTuong01 -daemon MultiChain 2.0 beta Daemon (latest protocol 20006) Starting up node Retrieving blockchain parameters from the seed node 192.168.1.11:5745 Other nodes can connect to this node using: multichaind chainTuong01@192.168.0.12:5745 Listening for API requests on port 6742 (local only - see rpcallowip setting) Node ready username@mchain12:~$ You should be shown a message that the node was started, and it should display this second node's address 1.4 Some commands in interactive mode 1.4.1 To get general information: getinfo // Xem thông tin chainTuong01 username@mchain11:~$ multichain-cli chainTuong01 getinfo {"method":"getinfo","params":[],"id":"368204381549757454","chain_name":"chainTuong01"} { "version" : "2.0 beta 1", "nodeversion" : 20000201, "protocolversion" : 20006, "keypoololdest" : 1550536798, "keypoolsize" : 2, "paytxfee" : 0, "relayfee" : 0, "errors" : "" }} username@mchain12:~$ Now get the hashes of the last few blocks, with commands like this: username@mchain12:~$ multichain-cli chainTuong01 getblockhash 303 {"method":"getblockhash","params":[171],"id":"119984201618497804","chain_name":"chainTuong01"} 0061f1b2569f61b0abe4ac6e23563b976ac4bf7487a2986c37cfb03c54c3b184 username@mchain12:~$ multichain-cli chainTuong01 getblockhash 302 {"method":"getblockhash","params":[170],"id":"574834651618497906","chain_name":"chainTuong01"} 00497cc8f3447b018b41fd8a77162450a03dd8766f85056646b0aa8615a70cb6 username@mchain12:~$ multichain-cli chainTuong01 getblockhash 301 {"method":"getblockhash","params":[169],"id":"781414431618497997","chain_name":"chainTuong01"} 0026b30356a910572fe00180694eca746b0cc2e8f1e74d54c338ffa4e4df4f08 username@mchain12:~$ For each hash, get more information about the block: getblock [block-hash] When I did it, blocks 170, and 169 were all from the same miner, but block 170 was from the other miner, as shown below It's a race between the miners, so they each have a 50% chance of winning, if both machines have the same processing power username@mchain12:~$ multichain-cli chainTuong01 getblock 0061f1b2569f61b0abe4ac6e23563b976ac4bf7487a2986c37cfb03c54c3b1 84 {"method":"getblock","params": ["00659cf7c05c2d686a7cf4ad1f75cc80aae8dd5b81069d7ab36bbf1652866d65"],"id":" 27245867-1549802036","chain_name":"chainTuong01"} { "hash" : "00659cf7c05c2d686a7cf4ad1f75cc80aae8dd5b81069d7ab36bbf1652866d65", "miner" : "1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL", "confirmations" : 1, "size" : 266, "height" : 171, "version" : 3, "merkleroot" : "9ff8f77ce2c3449d8830a25daaaeefa37235191dbf59b838f124a1bde28748ed", "tx" : [ "9ff8f77ce2c3449d8830a25daaaeefa37235191dbf59b838f124a1bde28748ed" ], "time" : 1549801631, "nonce" : 277, "bits" : "2000ffff", "difficulty" : 5.96046447753906e-8, "chainwork" : "000000000000000000000000000000000000000000000000000000000000ac00", "previousblockhash" : "00ba1d28f49c3e374bdc4fc024ae619d4b326824a63aa87857df6fa4bbe0f962" } username@mchain12:~$ multichain-cli chainTuong01 getblock 00497cc8f3447b018b41fd8a77162450a03dd8766f85056646b0aa8615a70c b6 {"method":"getblock","params": ["00ba1d28f49c3e374bdc4fc024ae619d4b326824a63aa87857df6fa4bbe0f962"],"id":" 78921192-1549802092","chain_name":"chainTuong01"} { "hash" : "00ba1d28f49c3e374bdc4fc024ae619d4b326824a63aa87857df6fa4bbe0f962", "miner" : "1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL", "confirmations" : 2, "size" : 266, "height" : 170, "version" : 3, "merkleroot" : "373fe23a2ff71aa59235648f22339b9f4bb33719f517bf6c075f1b507ced52df", "tx" : [ "373fe23a2ff71aa59235648f22339b9f4bb33719f517bf6c075f1b507ced52df" ], "time" : 1549801626, "nonce" : 77, "bits" : "2000ffff", "difficulty" : 5.96046447753906e-8, "chainwork" : "000000000000000000000000000000000000000000000000000000000000ab00", "previousblockhash" : "004c1ff650a041587bc1e94652848f2e003765936bb62a938009cda94c0edbc2", "nextblockhash" : "00659cf7c05c2d686a7cf4ad1f75cc80aae8dd5b81069d7ab36bbf1652866d65" } username@mchain12:~$ multichain-cli chainTuong01 getblock 0026b30356a910572fe00180694eca746b0cc2e8f1e74d54c338ffa4e4df4f 08 {"method":"getblock","params": ["004c1ff650a041587bc1e94652848f2e003765936bb62a938009cda94c0edbc2"],"id":" 99319582-1549802115","chain_name":"chainTuong01"} { "hash" : "004c1ff650a041587bc1e94652848f2e003765936bb62a938009cda94c0edbc2", "miner" : "1Tp1FxMDm7ktU5KKiPYESfocbMFkhCyvX2kVoL", "confirmations" : 3, "size" : 266, "height" : 169, "version" : 3, "merkleroot" : "2dc3cd7eba054bc47967f23c4f0527b882bcbe6a76ca9856bfe4d63865b55b2c", "tx" : [ "2dc3cd7eba054bc47967f23c4f0527b882bcbe6a76ca9856bfe4d63865b55b2c" ], "time" : 1549801619, "nonce" : 42, "bits" : "2000ffff", "difficulty" : 5.96046447753906e-8, "chainwork" : "000000000000000000000000000000000000000000000000000000000000aa00", "previousblockhash" : "00a7745fc41139be266854911303843ae10e7f38fcaab487b062418efa4e277a", "nextblockhash" : "00ba1d28f49c3e374bdc4fc024ae619d4b326824a63aa87857df6fa4bbe0f962" } username@mchain12:~$ - Lab Multichain Web * Prepare: ubuntu@mchain11:~$ multichaind chain1 -daemon ubuntu@mchain12:~$ multichaind chain1@192.168.1.11:2919 6.1 Issuing an Asset (First node: 192.168.1.11) Open your browser, type: http://192.168.1.11/multichain-web-demo In the Primary Node's GUI (http://192.168.1.11/multichain-web-demo), in the top menu bar, click "Issue Asset" Fill in these fields, leaving the other fields at their default values, and replacing "XYZ" with your own name, as shown below • Asset name: TUONG-Coin01 • Quantity: 1000 • Units: 0.01 Scroll to the bottom of the page and click the "Issue Asset" button A green message says "Asset successfully issued ", as shown below There's also a "Warning" message reminding us that this is all beta software, not a professional financial product 6.2 Sending Coins to the Secondary Node In the Primary Node's GUI (http://192.168.1.11/multichain-web-demo), in the top menu bar, click menu Send On the right side, in the "Send Asset" section, click the "To address" field Only one address is available, as shown below, and it's "local" that is, the Primary Node itself We can't send assets to the Secondary Node, because it doesn't have receive permission 6.3 Granting Permissions to the Secondary Node In the Primary Node's GUI (http://192.168.1.11/multichain-web-demo), in the top menu bar, click Permissions On the right side, in the "Change Permissions" section, the "For address" is empty, as shown below In the Secondary Node's GUI (http://192.168.0.12/multichain-web-demo), at the top right, in the "My Addresses" section, highlight the address, right-click, and click Copy, as shown below In the Primary Node's GUI (http://192.168.1.11/multichain-web-demo), in the right side, in the "Change Permissions" section, paste the address into the "For address" field Check Send and Receive, as shown below Click the "Change Permissions" button A green message says "Permissions successfully changed " 6.4 Sending Coins to the Secondary Node In the Primary Node's GUI (http://192.168.1.11/multichain-web-demo), in the top menu bar, click Send On the right side, in the "Send Asset" section, click the "To address" field and select the second address, the one that is not "local" Enter a Quantity of 50, as shown below Click the "Send Asset" button A green message says "Asset successfully sent " In the Secondary Node's GUI, in the top menu bar, click Send On the left side, the "Available Balances" section now shows 400 "TUONGCoin" 6.5 Issuing Another Asset In the Primary Node's GUI, in the top menu bar, click "Issue Asset" Fill in these fields, leaving the other fields at their default values, and replacing "XYZ" with your own name, as shown below • Asset name: TUONG-Coin02 • Quantity: 50 Scroll to the bottom of the page and click the "Issue Asset" button A green message says "Asset successfully issued " 6.6 Preparing an Atomic Exchange Transaction This is one of the most important features of Multichain: the ability to exchange one asset for another in a single "atomic" transaction, to avoid errors in which payment is sent but goods are not received In the Primary Node's GUI, in the top menu bar, click "Create Offer" On the right side, in the "Create Offer" section, enter these values: • Offer asset: TUONG-Coin02 • Offer qty: • Ask asset: TUONG-Coin01 • Ask qty: 10 Click the "Create Offer" button A green message says "Offer successfully prepared ", as shown below On the left side, in the "Available Balances" section, one TUONG-Coin02 is now "locked" that is, it cannot be spent for any other purpose, to ensure that it remains available for the atomic exchange Under the green message a long line of hexadecimal text appears, as highlighted in the image below Double-click it and copy it to the Clipboard 6.7 Performing the Exchange (Secondary node: 192.168.0.12) Open your browser, type: http://192.168.0.12/multichain-web-demo In the Secondary Node's GUI, in the top menu bar, click Accept On the right side, in the "Decode Offer" field, paste in the hexadecimal text, as shown below Click the "Decode Offer" button The "Complete Offer" section appears, as shown below, showing that we can get a YOURNAME-GoldCoin for ten YOURNAME-Coins Click the "Complete Offer" button The exchange is successful, and you now have a TUONG-Coin02-1, as shown below 6.8 Viewing the Secondary Node In the Secondary Node's GUI, in the top menu bar, click Node On the right side, in the "Permissions" line, find the word that is redacted in the image below - IT FACULTY – DaNang University ... this command to learn about the "sendwithmetadata" command: // Xem thông tin lệnh sendwithmetadata username@mchain11:~$ multichain-cli help sendwithmetadata We can include metadata in a transaction,... Sending Coins to the Secondary Node 6.5 Issuing Another Asset 6.6 Preparing an Atomic Exchange Transaction 6.7 Performing the Exchange 6.8 Viewing the Secondary Node Lab Getting Started with Multichain... exchange transaction 4.2.6 Verify the exchange Lab Round-robin mining Lab Multichain Web 6.1 Issuing an Asset 6.2 Sending Coins to the Secondary Node 6.3 Granting Permissions to the Secondary

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 Xem tại trang 3 của tài liệu.

Mục lục

    Lab 1.                   Getting Started with Multichain

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

    1.2.2       View the blockchain's default settings

    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.7       Get a list of connected peers for each node: getpeerinfo

Tài liệu cùng người dùng

Tài liệu liên quan