orangecertcc / dfa-ladder

Differential Fault Attack Simulations on Montgomery Ladder
GNU General Public License v3.0
2 stars 0 forks source link

Error: 'sage.rings.integer.Integer' object has no attribute 'bit_length' #1

Open Deep7448 opened 2 years ago

Deep7448 commented 2 years ago

Good afternoon!

When trying to execute the script "solve_hnp.py " the following error occurs:

deep@DESKTOP-9J8KERB:/mnt/c/Downloads/btccrc/dfa-ladder-main/pysimul$ python3 solve_hnp.py ecdsa_normal.txt Elliptic curve: secp256r1 Public key: (0x8ee77b680aa20aeae7db9f3cf134779ce8d0741d0c8906e3b8db63e06b4c4b4, 0x4765cf7845f6e803894f8c75c2b34fe4fa3c8021b28484783c5fa30c45794d2) HNP with 52 signatures... 'sage.rings.integer.Integer' object has no attribute 'bit_length' Command is "python3 solve_hnp.py filename

Please tell me, what could be the reason for this error?

2022-03-15_18-06-02

Thank you in advance for your explanations!

arusson commented 2 years ago

The issue is the fpylll package that comes with Sagemath is used, and the integer by default are Sage integers ZZ (that have the attribute nbits() instead of bit_length()) and not Python int.

First solution: use the fork that solves the issue by casting the Sagemath integers into Python int: https://github.com/ZAS0RIN/dfa-ladder. Then it should work independently of how fpylll was installed. I do not have control of this repository anymore, so I can't include the fix.

Second solution: install fpylll in a venv environnement:

python3 -m venv venv
source venv/bin/activate
python3 -m pip install Cython pytest cysignals flake8
python3 -m pip install fpylll

Then you can run the scripts.