2019年4月13日土曜日

開発環境

Programming Bitcoin: Learn How to Program Bitcoin from Scratch (Jimmy Song(著)、O'Reilly Media)のChapter 4(Serialization)、Umcompressed SEC Format、Exercises 1(75)の解答を求めてみる。

コード

Python 3

#!/usr/bin/env python3
from ecc import PrivateKey

secrets = [5000, 2018**5, 0xdeadbeef12345]

for secret in secrets:
    private_key = PrivateKey(secret)
    sec = private_key.point.sec().hex()
    for o in [sec, sec[:2], sec[2:2 + 64], sec[2+64:2+64+64]]:
        print(o)
    print()

入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))

C:\Users\...>py sample1.py
04ffe558e388852f0120e46af2d1b370f85854a8eb0841811ece0e3e03d282d57c315dc72890a4f10a1481c031b03b351b0dc79901ca18a00cf009dbdb157a1d10
04
ffe558e388852f0120e46af2d1b370f85854a8eb0841811ece0e3e03d282d57c
315dc72890a4f10a1481c031b03b351b0dc79901ca18a00cf009dbdb157a1d10

04027f3da1918455e03c46f659266a1bb5204e959db7364d2f473bdf8f0a13cc9dff87647fd023c13b4a4994f17691895806e1b40b57f4fd22581a4f46851f3b06
04
027f3da1918455e03c46f659266a1bb5204e959db7364d2f473bdf8f0a13cc9d
ff87647fd023c13b4a4994f17691895806e1b40b57f4fd22581a4f46851f3b06

04d90cd625ee87dd38656dd95cf79f65f60f7273b67d3096e68bd81e4f5342691f842efa762fd59961d0e99803c61edba8b3e3f7dc3a341836f97733aebf987121
04
d90cd625ee87dd38656dd95cf79f65f60f7273b67d3096e68bd81e4f5342691f
842efa762fd59961d0e99803c61edba8b3e3f7dc3a341836f97733aebf987121


C:\Users\...>

0 コメント:

コメントを投稿

関連コンテンツ