開発環境
- 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)、Mathematical Groups、Exercises 5(56)の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3
from ecc import FieldElement, Point
prime = 223
a = FieldElement(0, prime)
b = FieldElement(7, prime)
x = FieldElement(15, prime)
y = FieldElement(86, prime)
p = Point(x, y, a, b)
t = p
order = 1
print(t)
while t != Point(None, None, a, b):
t += p
print(t)
order += 1
print(f'order: {order}')
print(t + p)
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample5.py Point(15,86)_0_7 FieldElement(223) Point(139,86)_0_7 FieldElement(223) Point(69,137)_0_7 FieldElement(223) Point(69,86)_0_7 FieldElement(223) Point(139,137)_0_7 FieldElement(223) Point(15,137)_0_7 FieldElement(223) Point(infinity) order: 7 Point(15,86)_0_7 FieldElement(223) C:\Users\...>
0 コメント:
コメントを投稿