開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Python 3.7 (プログラミング言語)
Programming Bitcoin: Learn How to Program Bitcoin from Scratch (Jimmy Song(著)、O'Reilly Media)のChapter 3(Elliptic Curve Cryptography)、Public Key Cryptography、Programming Signature Verification、Exercises 7(69)の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3 from ecc import S256Point, G, N from helper import hash256 e = 12345 z = int.from_bytes(hash256(b'Programming Bitcoin!'), 'big') k = 1234567890 r = (k * G).x.num k_inv = pow(k, N - 2, N) s = (z + r * e) * k_inv % N point = e * G for o in [point] + [hex(t) for t in [z, r, s]]: print(o)
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample7.py S256Point(f01d6b9018ab421dd410404cb869072065522bf85734008f105cf385a023a80f, 0eba29d0f0c5408ed681984dc525982abefccd9f7ff01dd26da4999cf3f6a295) 0x969f6056aa26f7d2795fd013fe88868d09c9f6aed96965016e1936ae47060d48 0x2b698a0f0a4041b77e63488ad48c23e8e8838dd1fb7520408b121697b782ef22 0x1dbc63bfef4416705e602a7b564161167076d8b20990a0f26f316cff2cb0bc1a C:\Users\...>
0 コメント:
コメントを投稿