開発環境
- 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 2(Elliptic Curves)、Point Addition for When P1 = P2、Exercises 6(38)の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3 def slope(p1, a): x1, y1 = p1 return (3 * x1 ** 2 + a) / (2 * y1) def add(p1, a, b): x1, y1 = p1 s = slope(p1, a) x3 = s ** 2 - x1 - x1 y3 = s * (x1 - x3) - y1 return (x3, y3) p1 = (-1, -1) p3 = add(p1, 5, 7) x3, y3 = p3 for o in [p3, y3 ** 2 == x3 ** 3 + 5 * x3 + 7]: print(o)
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample6.py (18.0, 77.0) C:\Users\...>
0 コメント:
コメントを投稿