jvdsn / crypto-attacks

Python implementations of cryptographic attacks and utilities.
MIT License
935 stars 121 forks source link

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

Closed ScH01ar closed 1 year ago

ScH01ar commented 1 year ago

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.

jvdsn commented 1 year ago

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...)

ScH01ar commented 1 year ago

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).squareroot() u = (P[1] + tP[0])/(P[1] - tP[0]) % p v = (Q[1] + tQ[0])/(Q[1] - tQ_[0]) % p print (v.log(u))

jvdsn commented 1 year ago

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

ScH01ar commented 1 year ago

attacks/ecc/singular_curve.py : line 43

jvdsn commented 1 year ago

I didn't see too much of a performance difference, but I replaced it anyway for consistency: https://github.com/jvdsn/crypto-attacks/commit/9af6ac20f0abe387a7dcd8c92dc286e997774a75 Thanks.