Phát hành chứng chỉ lên blockchain (module cert-issuer)

Một phần của tài liệu Ứng dụng công nghệ blockchain trong việc quản lý chứng chỉ đào tạo (Trang 36 - 41)

3.5.3.1. Mô t

Đây là quá trình phát hành chứng chỉ lên blockchain bằng cách tìm ra giá trị băm của lô chứng chỉ phát hành và đẩy lên trường OP_RETURN của một giao dịch Bitcoin.

37

Hình 9: Tạo Merkle root của lô chứng chỉ

(Tham khảo https://github.com/blockchain-certificates/cert-issuer)

Hoàn toàn có thể thực hiện phát hành chứng chỉ dưới dạng mỗi chứng chỉ là một giao dịch Bitcoin, nhưng sẽ hiệu quả hơn nhiều khi thực hiện phát hành chứng chỉ theo lô. Đơn vị phát hành xây dựng một cây Merkle của băm chứng chỉ và phát hành giá trị gốc của cây Merkle (256 bit) lên trường OP_RETURN trong giao dịch Bitcoin.

3.5.3.2. Cài đặt

 Cài đặt Docker Version 2.0.0.2 (30215)  Dùng git để clone repository

git clone https://github.com/blockchain- certificates/cert-issuer.git

cd cert-issuer

 Tại thư mục cert-issuer, thực hiện build một bản container trên docker:

docker build -t bc/cert-issuer:1.1 .  Sau khi build xong, thực hiện kiểm tra containerid:

docker ps –l

Hình 10: Kiểm tra ContainerID

 Tương tác với cointainer vừa build

38  Thực hiện sửa file cấu hình conf.ini trong đường dẫn /etc/cert-

issuer/conf.ini issuing_address = miggSiHgD6gJa6ED9SCrppQqMwtncUbmQL chain=bitcoin_testnet usb_name=/etc/cert-issuer/ key_file=pk_issuer.txt unsigned_certificates_dir=/etc/cert-issuer/data/unsigned_certificates blockchain_certificates_dir=/etc/cert-issuer/data/blockchain_certificates work_dir=/etc/cert-issuer/work no_safe_mode

Thay giá trị của tham số:

o issuing_address: bằng địa chỉ Bitcoin của nhà phát hành o chain: loại blockchain sẽ triển khai ở đây là bitcoin testnet o usb_name: tên của đường dẫn, thiết bị chứa private key của

nhà phát hành

o key_file: là tên file chưa private key của nhà phát hành o unsigned_certificates_dir: đường dẫn chứa những chứng chỉ

chưa được phát hành

o blockchain_certificates_dir: đường dẫn chứa những chứng chỉ đã được phát hành lên blockchain

o work_dir: thư mục lưu chứng chỉ trong quá trình xử lý  Tạo file pk_issuer.txt tại đường dẫn /etc/cert-issuer/ với nội dung

cURHoLU8oWEAA5ZtaFJxRBrhztGvsQzVvMSuf7WSQ4FQcDP5 Pr9S

 Copy chứng chỉ đầu ra của mục 4.3.2.4 vào thư mục /etc/cert- issuer/data/unsigned_certificates : docker cp ca3903a0-b49e-4ac6-88e7- a2c1495e56e1.json 8f60e18ed038:/etc/cert- issuer/data/unsigned_certificates docker cp 01463a59-c7dc-4b53-ae71- 4af8a223c6b9.json 8f60e18ed038:/etc/cert- issuer/data/unsigned_certificates docker cp 800a369f-efa2-4735-9a9d- 89787077fdf9.json 8f60e18ed038:/etc/cert- issuer/data/unsigned_certificates

39 docker cp 1822803c-6d76-464d-b20d-

57834fdc4645.json 8f60e18ed038:/etc/cert- issuer/data/unsigned_certificates

3.5.3.3. Phát hành chng ch

 Thực hiện lệnh bên dưới:

cert-issuer -c /etc/cert-issuer/conf.ini  Log của quá trình xử lý (adsbygoogle = window.adsbygoogle || []).push({});

WARNING - Your app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure

INFO - This run will try to issue on the bitcoin_testnet chain

INFO - Set cost constants to

recommended_tx_fee=0.000600,min_per_output=0. 000028,satoshi_per_byte=250

INFO - Processing 4 certificates

INFO - Processing 4 certificates under work path=/etc/cert-issuer/work

INFO - Total cost will be 133500 satoshis INFO - Starting finalizable signer

WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure

INFO - Stopping finalizable signer

WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure

INFO - here is the op_return_code data:

ef3da16394c64206b0550715f7245676ea79e65579e96 86708bc5f40f1ce2441 INFO - Unsigned hextx=01000000018e271fa8474aa27cc0ff13cf13013 9c66693d3a61b87e889df2609f2970d26eb0000000000 ffffffff02a7efce00000000001976a91422bf4e32a70 aa5015cb3e6eac2454528628c2be588ac000000000000 0000226a20ef3da16394c64206b0550715f7245676ea7 9e65579e9686708bc5f40f1ce244100000000

INFO - Preparing tx for signing INFO - Starting finalizable signer

40 check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure

INFO - Stopping finalizable signer

WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure

INFO - The actual transaction size is 235 bytes INFO - Signed hextx=01000000018e271fa8474aa27cc0ff13cf13013 9c66693d3a61b87e889df2609f2970d26eb000000006b 483045022100e72a35f471e5e20de8d7e0a28f8c30646 54a1065262c2cbc03ee7bb050f7f975022046519b6b6c 0b63dfd396b2285910d9b7ed83637654794714056e1e8 149a4ba2c0121026e711471626a411ce1f617c487d92a a3ac9a6105a0279d219414f23cdd401ef8ffffffff02a 7efce00000000001976a91422bf4e32a70aa5015cb3e6 eac2454528628c2be588ac0000000000000000226a20e f3da16394c64206b0550715f7245676ea79e65579e968 6708bc5f40f1ce244100000000 INFO - Signed hextx=01000000018e271fa8474aa27cc0ff13cf13013 9c66693d3a61b87e889df2609f2970d26eb000000006b 483045022100e72a35f471e5e20de8d7e0a28f8c30646 54a1065262c2cbc03ee7bb050f7f975022046519b6b6c 0b63dfd396b2285910d9b7ed83637654794714056e1e8 149a4ba2c0121026e711471626a411ce1f617c487d92a a3ac9a6105a0279d219414f23cdd401ef8ffffffff02a 7efce00000000001976a91422bf4e32a70aa5015cb3e6 eac2454528628c2be588ac0000000000000000226a20e f3da16394c64206b0550715f7245676ea79e65579e968 6708bc5f40f1ce244100000000

INFO - verifying op_return value for transaction

INFO - verified OP_RETURN

WARNING - Caught exception trying provider <bound method

BlockrIOBroadcaster.broadcast_tx of

<cert_issuer.blockchain_handlers.bitcoin.conn ectors.BlockrIOBroadcaster object at

0x7f43d1882e48>>. Trying another.

Exception=Expecting value: line 1 column 1 (char 0)

41 INFO - Broadcasting succeeded with

method_provider=<bound method BlockExplorerBroadcaster.broadcast_tx of <cert_issuer.blockchain_handlers.bitcoin.conn ectors.BlockExplorerBroadcaster object at 0x7f43d1882cf8>>, txid=039b659f49bb383455bad0f12b7f2ffd951cc3c7 23136c60bda2792c67657bdd

INFO - Broadcast transaction with txid

039b659f49bb383455bad0f12b7f2ffd951cc3c723136 c60bda2792c67657bdd

INFO - Your Blockchain Certificates are in /etc/cert-issuer/data/blockchain_certificates

3.5.3.4. Output (adsbygoogle = window.adsbygoogle || []).push({});

Kết quả của quá trình này là 4 file chứng chỉ đã được ký và phát hành thành công lên blockchain testnet:

Hình 11: Đầu ra các chứng chỉđược phát hành

Một phần của tài liệu Ứng dụng công nghệ blockchain trong việc quản lý chứng chỉ đào tạo (Trang 36 - 41)