jvdsn / crypto-attacks

Python implementations of cryptographic attacks and utilities.
MIT License
887 stars 114 forks source link

TypeError in Example code rsa/boneh_durfee.py #9

Closed shemon11 closed 1 year ago

shemon11 commented 1 year ago

Hi, thank you for your work! Can you help me to run Example script from your Readme instructions?(https://github.com/jvdsn/crypto-attacks/blob/master/README.md)

I have error:

####### INFO:root:Trying m = 1, t = 0... DEBUG:root:Generating shifts... DEBUG:root:Creating a lattice with 3 shifts (order = invlex, sort_shifts_reverse = False, sort_monomials_reverse = False)... DEBUG:root:Reducing a 3 x 3 lattice... DEBUG:root:Reconstructing polynomials (divide_original = True, modulus_bound = True, divide_gcd = True)... DEBUG:root:Row 0 is too large, ignoring... DEBUG:root:Row 1 is too large, ignoring... DEBUG:root:Row 2 is too large, ignoring... DEBUG:root:Reconstructed 0 polynomials DEBUG:root:Computing pairwise gcds to find trivial roots... DEBUG:root:Using Groebner basis method to find roots... Traceback (most recent call last): File "/crypto-attacks/attacks/rsa/boneh_durfee.py", line 94, in p, q = attack(N, e, p_bits, delta=delta) TypeError: cannot unpack non-iterable NoneType object #######

What parameter(s) is wrong?

A added example of your code to /attacks/rsa/boneh_durfee.py:

####### import logging

Some logging so we can see what's happening.

logging.basicConfig(level=logging.DEBUG)

N = 88320836926176610260238895174120738360949322009576866758081671082752401596826820274141832913391890604999466444724537056453777218596634375604879123818123658076245218807184443147162102569631427096787406420042132112746340310992380094474893565028303466135529032341382899333117011402408049370805729286122880037249 e = 36224751658507610673165956970793195381480143363550601971796688201449789736497322700382657163240771111376677180786660893671085854060092736865293791299460933460067267613023891500397200389824179925263846148644777638774319680682025117466596019474987378275216579013846855328009375540444176771945272078755317168511 p_bits = 512 delta = 0.26

p, q = attack(N, e, p_bits, delta=delta) assert p * q == N print(f"Found p = {p} and q = {q}") #######

jvdsn commented 1 year ago

You are right, the example code in the README is outdated. I will update it shortly, but in essence you would need to use attack(N, e, p_bits, delta=delta, m=3) to get the desired output.

shemon11 commented 1 year ago

It working! Thank you very much! If you are not busy now, please, can you write example for frey_ruck_attack.py or where i can find it information?

jvdsn commented 1 year ago

See https://github.com/jvdsn/crypto-attacks/blob/master/test/test_ecc.py#L84