I use this article for my task https://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/
Scalar multiplication is
where n
is a natural number
I use this code for finding Q
import numpy as np
def f(x,a,b):
return x**3+a*x + b
def bits(n):
while n:
yield n & 1
n >>= 1
def double_and_add(n, x):
result = 0
addend = x
for bit in bits(n):
if bit == 1:
result += addend
addend *= 2
return result
P = 3
Q = double_and_add(P,151) #453 <--- issue here
xp = P
yp = np.sqrt(f(xp)) #4
xq = Q
yq = np.sqrt(f(xq))
Why my Q variable not matched with variable on site https://cdn.rawgit.com/andreacorbellini/ecc/920b29a/interactive/reals-mul.html