jvdsn / crypto-attacks

Python implementations of cryptographic attacks and utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A faster function to solve the DLP question in ecc's singular_curve.py

ScH01ar opened this issue · comments

In some tests, using "return v.log(u)" instead of "return int(discrete_log(v, u))" is more efficient.
What are the differences between the two functions?
Thanks.

Which tests are you referring to specifically? Those functions are heavily overloaded, and do different things depending on the type of the input parameters (finite field element, integer, real number...)

such as this script

p=193387944202565886198256260591909756041
P. = GF(p)[]
f = x^3 + 2*x^2 + x
P = (4, 10)
Q = (65639504587209705872811542111125696405, 125330437930804525313353306745824609665)
print(f)
f_ = f.subs(x=x-1)
print(f_)
print (f_.factor())
P_ = (P[0] +1, P[1])
Q_ = (Q[0] +1, Q[1])

t = GF(p)(193387944202565886198256260591909756040).square_root()
u = (P_[1] + tP_[0])/(P_[1] - tP_[0]) % p
v = (Q_[1] + tQ_[0])/(Q_[1] - tQ_[0]) % p
print (v.log(u))

@ScH01ar could you link where this is used in the repository, I can't find it.

attacks/ecc/singular_curve.py : line 43

I didn't see too much of a performance difference, but I replaced it anyway for consistency: 9af6ac2 Thanks.