前回は、
bbc1リポジトリには、
なお、
以降では、
環境整備
bbc1リポジトリに入っているプログラムはPython3で実装されています。まずはPython3および関連ライブラリをビルドするための環境を作る必要があります。ここでは、
ターミナルを起動してから、
# sudo apt-get install -y git tzdata openssh-server python3 python3-dev libffi-dev net-tools autoconf automake libtool libssl-dev make
# brew install libtool automake python3
以下、
# python3 -mvenv venv # source venv/bin/activate # pip install bbc1
最初の2行は、
うまくインストールできれば、
# file_proof.py -h
とすれば、
usage: file_proof.py [-h] {store,get,remove,list,update,verify,keypair,wait,send,setup} ... positional arguments: {store,get,remove,list,update,verify,keypair,wait,send,setup} commands store Store a file get Get a file remove Remove a file list Get a file list update Update a file verify Verify a file keypair Create a key pair wait Wait for receiving a file send Send a file setup Setup domain and asset group optional arguments: -h, --help show this help message and exit
これで準備完了です。いよいよ動作させてみましょう。
file_proof.pyを使ってみる
BBc-1 Coreのインストールや起動
file_
新しくターミナルを立ち上げたときなどは、
# source venv/bin/activate
とするのを忘れないようにしてください。このコマンドで、
このツールは、
# bbc_core.py --no_nodekey
“–no_
coreノードが起動すると、
次に別のターミナルを開いて
# file_proof.py keypair
上記のコマンドを実行すると、
さらに、
# file_proof.py setup
これで、
ファイルの登録
では、
# cat > testfile.txt BBC HEAVEN.
念の為、
# ls ./ ../ testfile.txt
このように、
# file_proof.py store testfile.txt -o userA
これで、
Relation[]: 1 [0] asset_group_id: b'45b2a200ccdcdcc3fb80cc9d423e1069f3ca726157f6492b4a70a48e4a1713ab' Asset: asset_id: b'd2e509a4002b664b9c651c3bbf95f583bbfe2065eeeb63a5f20e903de20a2ba5' user_id: b'9367417d63903350aeb7e092bca792263d4fd82d4912252e014e073a8931b4c1' nonce: b'78d4e9d8c78175bc5bae25393d7afb66e39610ce73908f00a1203efe0a0614ae' file_size: 12 file_digest: b'6aa951c7eb5886694b56ec7f74075f9d410cf9c9fb68d66ca889da5097066e3c' body_size: 14 body: b'Owner is userA’
なお、
登録したファイルの検証
では、
# file_proof.py verify testfile.txt
上記のコマンドで、
testfile.txt is valid done verify testfile.txt
となっていれば問題なしです。
試しにtestfile.
testfile.txt is invalid done verify testfile.txt
と、
ファイル所有権の移転
file_
- ~Bさん
(新規ウィンドウで) ~ -
# source venv/
bin/ activate # mkdir otherDir/ # cd otherDir # file_ proof. py keypair 次に、
ファイルの移転を待ち受けます # file_
proof. py wait -o userB すると、
次のように表示され、 待受状態になります。 Your name is [ userB ] and user_
id is [ 16進数の文字列 ] Waiting for file transfer..... - ~Aさん
(さきほどstoreしたターミナルで) ~ -
testfile.
txtで指定したファイルの所有権をBさんに移転します。 # file_
proof. py send testfile. txt -o userA すると、
次のように表示され、 入力待ち状態になります。 Your name is [ userA ] and user_
id is [ 16進数の文字列 ] Please enter the receiver user name for file testfile. txt. >> 最後に、
送り先のユーザ名の入力を求められるので、 userBと入力してenterキーを押します。 - ~Bさんでのファイル受け入れ~
-
Bさんのターミナルに次のように表示されます。
-------------------------- File digest written in the transaction data: “16進数の文字列” File digest calculated from the received file: “16進数の文字列” -------------------------- ====> Do you want to accept the file? (Y/
N) >> “16進数の文字列” の部分はファイルによって異なりますが、 大事なのは2つがまったく同じ文字列であることです。一致していないものは何らかの不正が考えられます。このファイルの所有権を受け入れるならYを、 受け入れないならNを入力して、 enterキーを押します。 ここでは、 Yを押しておきましょう。 Waiting for the message from the sender... --> file name is testfile.
txt and the transaction_ id is “16進数の文字列” と出れば、
移転完了です。なお、 ファイル自体が手に入るわけではなく、 所有権のみが移転しました。ファイルが必要な場合は、 下記のようにしてファイルを取得してください。 # file_
proof. py get testfile. txt
以上がfile_
まとめ
今回は、