2019年4月5日金曜日

開発環境

Programming Bitcoin: Learn How to Program Bitcoin from Scratch (Jimmy Song(著)、O'Reilly Media)のChapter 3(Elliptic Curve Cryptography)、Elliptic Curves over Finite Fields、Exercises 1(44)の解答を求めてみる。

コード

Python 3

#!/usr/bin/env python3
prime = 223
points = [(192, 105),
          (17, 56),
          (200, 119),
          (1, 193),
          (42, 99)]

for x, y in points:
    print(f'({x}, {y})')
    left = y ** 2 % prime
    right = (x ** 3 + 7) % prime
    print(left == right)

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

C:\Users\...>py sample1.py
(192, 105)
True
(17, 56)
True
(200, 119)
False
(1, 193)
True
(42, 99)
False

C:\Users\...>

0 コメント:

コメントを投稿