Y

Mastering Bitcoinを読む Chapter3-4 txindexオプション、秘密鍵作成

f:id:yzono:20150125020619j:plain

はじめに

前回に引き続き、Mastering BitcoinのChapter3と4を読んで気になったところを書きます。

目次

  • txindexオプション
  • Private Key作成
  • ランダム係数について

txindexオプション

Transaction Database Index and txindex Option

By default, Bitcoin Core builds a database containing only the transactions related to the user’s wallet. If you want to be able to access any transaction with commands like gettransaction, you need to configure Bitcoin Core to build a complete transaction index, which can be achieved with the txindex option. Set txindex=1 in the Bitcoin Core configuration file..

bitcoin.confに設定しているtxindexオプションをtxindex=1にすると、自分のウォレットに関係しないトランザクションについての情報も取得できるようになります。

以下が例です。aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568は自分に関連しないトランザクションです。

bitcoin-cli getrawtransaction aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568 

txindex=1を設定しない場合に比べてインデックスの時間が僅かにかかりますが、同期するトランザクション自体は変更ないため、Blockchainデータの同期時間、容量に大きな変更はないです。(おそらく。後の章を読んで間違っていたら修正します)

ちなみにCounterpartyのインストールガイドではtxindex=1を設定しています。

Private Key作成

Generating a private key from a random number

The size of bitcoin’s private key space, 2^256 is an unfathomably large number. It is approximately 1077 in decimal. The visible universe is estimated to contain 1080 atoms.

秘密鍵は、2256からランダムに取得します(正確には若干エントロピーは異なるそうです)。膨大な数字とはいえスーパーコンピューターを使えばそのうち発見されるのでは?と疑問になったので検索しました。

How long would it take a large computer to crack a private key?

これによると現在のスーパーコンピューターでは、"0.65 billion billion years"大丈夫とのこと.. ムーアの法則を考慮した未来予測とビットコインアルゴリズムが変わらないことを前提した場合でも60年間は大丈夫とのこと... とにかく大丈夫そうです。

ランダム係数について

Generating a private key from a random number

Usually, the OS random number generator is initialized by a human source of randomness, which is why you may be asked to wiggle your mouse around for a few seconds.

多くのOSでは、ランダム係数として固定値ではなく動的な何か、ここではマウスの動きを元にすると書いています。この指摘はCounterparty勉強会でジョナサンも指摘していました。以下の1:36:29あたりに説明がされています。

以前紹介したOracleサービス"Okidoki"でも実装がされていた気がします。今度詳細を調べてみます。

まとめ

安全性は大丈夫?って質問された時に分かりやすく説明できるように、東京ドーム何個分のような比較方法を調べてます。ちなみに宝くじの1等の確率は1千万分の1らしいです。

次は楕円曲線について書きます..

参考

How long would it take a large computer to crack a private key?

SSLについての質問