2017年11月2日木曜日

bbc1の持つ主要機能「超」概要を眺めてみる

はじめに

  • bbc1には3つの主要な機能が用意されている。
    • core : bbc1のコア機能
    • app :  bbc1を使用したアプリケーションのためのSDK
    • common : coreとappのためのライブラリ
  • それぞれが持つ機能を大まかに理解していく

commonについて

bbclib.py

  • クラス一覧
    • Keytype
    • Keypair
    • BBcSignature
    • BBcTransaction
    • BBcEvent
    • BBcReference
    • BBcAsset
    • BBcCrossRef
    • ServiceMessageType
    • NodeInfo
    • StorageType
      • どの場面にも出て来そうな汎用的な機能を備えている

coreについて

bbc_core.py

  • クラス一覧
    • BBcCoreService
      • このクラスに多くの機能を持たせている

bbc_ledger.py

  • クラス一覧
    • ResourceType
    • BBcLedger
      • データベースマネージャー、それっぽいことができる?
      • 現状はSQL形式のみらしい

bbc_network.py

  • クラス一覧
    • BBcNetwork
      • インフラレイヤーのためのソケットやスレッド管理
    • DomainBase
      • ドメインの基底クラス
        • ドメインやノード管理に関するあれこれ

bbc_storage.py

  • クラス一覧
    • BBcStorage
      • ストレージマネージャー

appについて

bbc_app.py

  • クラス一覧
    • BBcAppClient
    • Callback
      • ノードにコマンドを発行するメソッドを含む
        • それらのうち幾つかはアプリケーションの設定時に呼び出される必要がある

次回

コードに含まれるメソッドのうちいくつかの動作確認をしてみる

2017年10月26日木曜日

ビットコインゴールドについて

# ビットコインゴールドの狙い

- 1CPU 1票の世界でそれが少数の企業によって支配されている現状を変えようと目論む
  - SHA256ベースのマイニングを時代遅れに
  - GPUベースとすることでマイニングを一般的なものに
  - Equihash用にASICを設計することも可能だがかなり効果で速度向上は限定的とのこと


# ハードフォークとその対応

- 10/25頃にフォークが発生する
- 強力なリプレイプロテクションを予定
  - BitcoinCashと同様に署名ハッシュ形式を変更
- segwit 2xとは違う


# ビットコインとの違い

Supply,21 Million
PoW algorithm,Equihash(GPU使用、Ethereumに近い?)
Mining Hardware,GPU
Block Interval,10 Minutes
Block size (actual),1M (2-4M)
Difficulty adjustment,Every block
Segwit,done
Replay protection,done(btcは未対応?)
Unique address format,done

# 取引所の対応

- 対応予定を表明している取引所
  - coincheck(付与),zaif(付与しない),bitbank(決めかねてる),bitflyer(付与)
- まとめ一覧はこちら -> https://bitpress.jp/news/information/entry-6648.html

# 参考リンク

- bitcoingold
  - https://btcgpu.org/
- Equihash
  - https://eprint.iacr.org/2015/946.pdf
- Bitcoin Gold: What you need to know
  - https://bitcointechtalk.com/bitcoin-gold-what-you-need-to-know-8b3e645be409
- How Segwit2x Replay Protection Works
  - https://bitcointechtalk.com/how-segwit2x-replay-protection-works-1a5e41767103

2017年9月25日月曜日

5分でわかる「ヒステリシス署名と履歴交差」

狙い


  • 将来的にBBc-1の存在証明の機能を実現する技術要素の理解・共有


概念の理解

電子署名

デジタル署名(デジタルしょめい)とは、書面上の手書き署名のセキュリティ特性を模倣するために用いられる公開鍵暗号技術の一種である。デジタル署名  

暗号ブレイク

  • 電子署名の偽造のこと


偽造の要因

  • 大きく4つに分類される
  1. 署名生成者に問題がある
  2. 署名検証者に問題がある
  3. オーソリティに問題がある
  4. 電子署名方式に問題がある

過去の提案(比較して言える共通課題)



  • 前述した要因への対応案がいくつかなされているが以下の共通した課題がある。
  1. オーソリティによる改ざん
  2. 通信経路上での改ざん

ヒステリシス署名


  • つまり、署名間で連鎖する構造をもつ
  • なぜ安全なのか?ブロックハッシュの連鎖との違いは?
    • 計算の容易さ
      • ブロックハッシュは誰もが計算できるが署名は鍵の所有が前提となる
    • 鍵の偽造ができれば容易になってしまう

履歴交差


  • 複数エンティティ間の署名履歴をすり合わせる
    • チェイニング署名
    • つまり署名のチェーンを利用する
      • 一人ではなく利用者間でチェーンを生成する
  • 署名処理や履歴交差プロトコル については割愛
”本稿で提案しているヒステリシス署名にとって脅威となるようなハッシュ関数のブレイクは、本稿で問題としている暗号ブレイクより困難であると考えられる”

参考文献

斉藤 賢爾 分散レッジャー技術と来たるべき社会変容 WIDE Technical-Report in 2017洲崎誠一, 松本勉. 電子署名アリバイ実現機構 — ヒステリシス署名と履歴交差. 情報処理学会論文誌, Vol. 43,No. 8, pp. 2381–2393, 2002.

2017年8月18日金曜日

pandasでビットコインのトランザクション処理状況を見る

概要

https://blockchain.info/ からntxとmempoolsizeに関するcsvファイルをダウンロードして二軸プロットするスクリプト。ついでにpngとしてプロット画像を保存する。

結果

処理能力が改善したとは言い切れない、なんとも怪しさを感じさせる状況。


コード

import matplotlib.pyplot as plt
import pandas as pd

# CSVの読み込み
df_memp = pd.read_csv('mempool-size.csv',index_col=0, parse_dates=[0], names=['memp_size'])
df_memp = df_memp.astype(float)
df_ntx = pd.read_csv('n-transactions.csv',index_col=0, parse_dates=[0], names=['ntx'])
df_ntx = df_ntx.astype(float)
df = pd.concat([df_memp,df_ntx])

# 二軸プロットのため二つの軸を作成
fig, ax1 = plt.subplots()
ax1.plot(df.index,df['memp_size'],color='b')
ax2 = ax1.twinx()
ax2.plot(df.index,df['ntx'],color='r')

# プロットとその他処理
plt.rcParams['font.size'] = 8
plt.legend()
plt.savefig("image.png")
plt.show()

参考サイト


2017年6月19日月曜日

GO言語で始めるEthereumプログラミング(Gethを使ったアカウント管理編)

環境


OS : osx

目的

Gethの"Basic Use Case Documentation"にある3つをそれぞれ試す。
Ethereum開発に必要なClientであるGethの使い方を学ぶ。


始めに

  • アカウントを暗号化する際のパスワードを忘れるとそのアカウントにはアクセスできなくなるので注意
  • gethはaccountというサブコマンドによってアカウント管理できる
  • 鍵は<DATADIR>/keystore以下に保存される
    • 定期的なバックアップをオススメする
    • 鍵のバックアップに関する詳細:Backup & restore
  • ヘルプコマンド
    • geth account help <subcommand>


アカウント管理でできること

  • 新たなアカウントの作成
  • 既存アカウントのリスト化
  • 新たなアカウントに対する秘密鍵のインポート
  • 最新の鍵形式への移行とパスワード変更

アカウントの作成

新たなアカウントを作る

前回の投稿で作成したgo-ethereum内で作業を行う。
$ geth account new
WARN [06-18|10:42:55] No etherbase set and no accounts found as default 
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {2e9f6ce30074338fac346090d4bc6a1fd5506f38}

リスト化した情報を参照してみる。


$ geth account list
Account #0: {2e9f6ce30074338fac346090d4bc6a1fd5506f38} keystore:///Users/xxx/Library/Ethereum/keystore/UTC--2017-06-18T13-53-47.688998272Z--2e9f6ce30074338fac346090d4bc6a1fd5506f38

アカウント情報を暗号化形式で保存する。この時に指定するパスフレーズはアカウントをアンロックする時に必要なので決して忘れてはならない。
$ > personal.newAccount test

上記の作業前後でディレクトリ内には以下のような変化が。
(前)
$ ls
AUTHORS  build  core  les  rlp
COPYING  circle.yml crypto  light  rpc
COPYING.LESSER cmd  eth  log  swarm
Dockerfile common  ethclient metrics  tests
Makefile compression ethdb  miner  trie
README.md consensus ethstats mobile  vendor
VERSION  console  event  node  whisper
accounts containers interfaces.go p2p
appveyor.yml contracts internal params

(後)


$ ls
AUTHORS   console   metrics
COPYING   containers  miner
COPYING.LESSER  contracts  mobile
Dockerfile  core   node
Makefile  crypto   p2p
README.md  eth   params
VERSION   ethclient  personal.newAccount
accounts  ethdb   rlp
appveyor.yml  ethstats  rpc
build   event   swarm
circle.yml  interfaces.go  tests
cmd   internal  trie
common   les   vendor
compression  light   whisper
consensus  log
アカウントに関するファイルが生成されている。

秘密鍵のインポートによってアカウントを作る

暗号化されてない秘密鍵を使用する場合。これは不要なのでスキップする。

既存のアカウントをアップデートする

アカウントを暗号化形式で最新バージョンに保存する。
この時アカウントのロックを解除するためにパスフレーズを求められる。
$ geth account update 2e9f6ce30074338fac346090d4bc6a1fd5506f38
Unlocking account 2e9f6ce30074338fac346090d4bc6a1fd5506f38 | Attempt 1/3
Passphrase: 
INFO [06-19|22:07:53] Unlocked account                         address=0x2e9f6ce30074338fac346090d4bc6a1fd5506f38
Please give a new password. Do not forget this password.
Passphrase: 
Repeat passphrase: 

プリセールウォレットをインポートする

スキップ。

アカウントのリスト化と残高のチェック

現在のアカウントのリスト化

$ geth account list
Account #0: {2e9f6ce30074338fac346090d4bc6a1fd5506f38} keystore:///Users/kichino/Library/Ethereum/keystore/UTC--2017-06-18T13-53-47.688998272Z--2e9f6ce30074338fac346090d4bc6a1fd5506f38

2017年6月18日日曜日

GO言語で始めるEthereumプログラミング(ビルド編)

環境


OS : osx


インストール

以下入力コマンド。出力内容は最後のみ表示。

$ brew tap ethereum/ethereum

$ brew install ethereum

$ cd Desktop
$ mkdir ethe
$ cd ethe
$ git clone https://github.com/ethereum/go-ethereum

$ brew install go

$ cd go-ethereum

$ make geth
build/env.sh go run build/ci.go install ./cmd/geth
>>> /usr/local/Cellar/go/1.8.1/libexec/bin/go install -ldflags -X main.gitCommit=431cf2a1e453346bcc627ac1fb9df3950a6c3499 -s -v ./cmd/geth
github.com/ethereum/go-ethereum/common/hexutil
github.com/ethereum/go-ethereum/common/math
github.com/ethereum/go-ethereum/rlp
github.com/ethereum/go-ethereum/crypto/sha3
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/ethereum/go-ethereum/common
github.com/ethereum/go-ethereum/vendor/github.com/go-stack/stack
github.com/ethereum/go-ethereum/log
github.com/ethereum/go-ethereum/params
github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics
github.com/ethereum/go-ethereum/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque
github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime
github.com/ethereum/go-ethereum/common/mclock
github.com/ethereum/go-ethereum/event
github.com/ethereum/go-ethereum/crypto/randentropy
github.com/ethereum/go-ethereum/vendor/github.com/pborman/uuid
github.com/ethereum/go-ethereum/vendor/github.com/rjeczalik/notify
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/pbkdf2
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/scrypt
github.com/ethereum/go-ethereum/cmd/internal/browser
github.com/ethereum/go-ethereum/vendor/github.com/edsrzf/mmap-go
github.com/ethereum/go-ethereum/common/bitutil
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/cache
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage
github.com/ethereum/go-ethereum/trie
github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/exp
github.com/ethereum/go-ethereum/metrics
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/iterator
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/journal
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/opt
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/memdb
github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru/simplelru
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/table
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/context
github.com/ethereum/go-ethereum/vendor/github.com/rs/xhandler
github.com/ethereum/go-ethereum/vendor/github.com/rs/cors
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/websocket
github.com/ethereum/go-ethereum/vendor/gopkg.in/fatih/set.v0
github.com/ethereum/go-ethereum/rpc
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/ripemd160
github.com/ethereum/go-ethereum/ethdb
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/httpu
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/scpd
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/soap
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/ssdp
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/atom
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal/identifier
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/transform
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/charmap
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/japanese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/korean
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/simplifiedchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/traditionalchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/utf8internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/runes
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/tag
github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/unicode
github.com/ethereum/go-ethereum/p2p/netutil
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1/base64vlq
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/token
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/dbg
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/file
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/ast
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/registry
github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/parser
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/htmlindex
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/charset
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway1
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway2
github.com/ethereum/go-ethereum/p2p/nat
github.com/ethereum/go-ethereum/log/term
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-colorable
github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1
github.com/ethereum/go-ethereum/les/flowcontrol
github.com/ethereum/go-ethereum/internal/jsre/deps
github.com/ethereum/go-ethereum/internal/debug
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-isatty
github.com/ethereum/go-ethereum/vendor/github.com/fatih/color
github.com/ethereum/go-ethereum/internal/web3ext
github.com/ethereum/go-ethereum/vendor/github.com/peterh/liner
github.com/ethereum/go-ethereum/vendor/golang.org/x/tools/go/ast/astutil
github.com/ethereum/go-ethereum/vendor/golang.org/x/tools/imports
github.com/ethereum/go-ethereum/vendor/github.com/maruel/panicparse/stack
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-runewidth
github.com/ethereum/go-ethereum/vendor/github.com/mitchellh/go-wordwrap
github.com/ethereum/go-ethereum/vendor/github.com/nsf/termbox-go
github.com/ethereum/go-ethereum/vendor/github.com/naoina/go-stringutil
github.com/ethereum/go-ethereum/vendor/github.com/gizak/termui
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml/ast
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/crypto/ecies
github.com/ethereum/go-ethereum/core/types
github.com/ethereum/go-ethereum/p2p/discover
github.com/ethereum/go-ethereum/p2p/discv5
github.com/ethereum/go-ethereum/accounts/abi
github.com/ethereum/go-ethereum
github.com/ethereum/go-ethereum/core/state
github.com/ethereum/go-ethereum/accounts
github.com/ethereum/go-ethereum/core/vm
github.com/ethereum/go-ethereum/accounts/keystore
github.com/ethereum/go-ethereum/consensus
github.com/ethereum/go-ethereum/consensus/misc
github.com/ethereum/go-ethereum/consensus/clique
github.com/ethereum/go-ethereum/consensus/ethash
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/p2p
github.com/ethereum/go-ethereum/core
github.com/ethereum/go-ethereum/accounts/usbwallet
github.com/ethereum/go-ethereum/accounts/abi/bind
github.com/ethereum/go-ethereum/ethclient
github.com/ethereum/go-ethereum/node
github.com/ethereum/go-ethereum/whisper/whisperv5
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/eth/gasprice
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/contracts/release
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "build/bin/geth" to launch geth.

2017年6月11日日曜日

IOTA whitepaperの概要

ペーパーを第3章まで読んでざっくりと内容をまとめてみる。
ここには個人的な意見も含むことを注意してほしい。
http://iotatoken.com/IOTA_Whitepaper.pdf

目的

IOT向けマイクロペイメントの実現

現状の課題(述べられていること)

ビットコインでは手数料が高く少額の支払いに向いていない

現状の課題(個人的)

取引承認にかかる時間、スケーラビリティ

何をするのか

  • Blockchainless
  • DAGでTxチェーンを作成
    • これをtangleと呼んでいるらしい

どう動くのか

  • Txの発行・承認・伝搬の役割が参加者で別れておりTxがTxを承認する
    • 理想的な状態では承認が重複せずスケールアウトする?
  • Txを発行するには、ユーザーは他のTxを承認する必要がある
  • 新しいTxはランダムに選ばれる前の2つのTxを承認する必要がある
  • 全てのTxは台帳に入りうる
    • Orphanのような存在も救われるようにしている
  • 各ノードはTxを伝搬させる役割を持つ 
    • そのインセンティブはネットワークに参加できること
    • あまりにも怠惰であるとドロップされる
  • 自らのTxを参照する空Txションを作成することでtipからの承認を受ける確率をあげることが望まれる
    • 不要なTxの増加を誘発させないか?
  • Spam対策
    • 大きなweightがあるものほどノードが承認しやすいならば、spamは承認されづらくなる 
      • しかしそれでは新たなtipsが承認されなくなってしまうのでは?
      • spamに承認されてるTxはなるべく承認されないようになっているのでは?

言葉の定義

tips:未承認のTx
site:tangleグラフ上に表されるTx
node:ネットワーを構成しているもの、Txを発行するエンティティ
height:genesisまで最長指向経路の長さ
depth:いくつかの先端までの最長の逆向き経路の長さ
score:全てのTxのweightの合計
cumulative weight:全ての取引のweightの合計
weights:Txスコアの元になる
cutset:ある時点におけるtipsの集合