ranea / ArxPy

Tool to find XOR differential and rotational-XOR characteristics of ARX primitives.
https://ranea.github.io/ArxPy/
MIT License
29 stars 11 forks source link

Not working with other ciphers #3

Closed Ririkosann closed 2 years ago

Ririkosann commented 2 years ago

Hi, I'm Riko, a graduate student in Japan. I am planning to use this library in my research, and I am currently testing the specifications of the library. The code in the readme works, but when I try it with a different cipher, such as Chaskey.py, it does not work. Error

round_based_search_RkCh(cipher, XorDiff, 0, 0, "btor", 4, 5, DerMode.Default, ... DerMode.Default, True, RkChSearchMode.OptimalMinSum, True, 0, None) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.9/dist-packages/arxpy/smt/search.py", line 2199, in round_based_search_RkCh cipher.set_rounds(num_rounds) AttributeError: module 'arxpy.primitives.chaskey' has no attribute 'set_rounds'

ranea commented 2 years ago

I guess you are trying to run the function round_based_search_SkCh with ChaskeyPi.

However, ChaskeyPi is a subclass of BvFunction, and round_based_search_SkCh requires a subclass of Cipher. This is a particular case; the rest of the ciphers are implemented as subclasses of Cipher and should work properly.

If you want to run round_based_search_SkCh with chaskey, the easiest way would be to implement ChaskeyPi as a Cipher.

Ririkosann commented 2 years ago

Thank you for your reply. It was very helpful. I will try to implement it as Cipher in round_based_search_SkCh. I have one more question. In round_based_search_RkCh, I get the following error. Is there a solution?

Python 3.9.9 (main, Nov 16 2021, 10:24:31) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from arxpy.differential.difference import XorDiff from arxpy.smt.search import RkChSearchMode, DerMode, round_based_search_RkCh from arxpy.primitives.chaskey import ChaskeyPi cipher = ChaskeyPi round_based_search_RkCh(cipher, XorDiff, 0, 0, "btor", 4, 5, DerMode.Default, ... DerMode.Default, True, RkChSearchMode.OptimalMinSum, True, 0, None) Num rounds: 4 Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.9/dist-packages/arxpy/smt/search.py", line 2203, in round_based_search_RkCh ch = characteristic.RelatedKeyCh(cipher, diff_type) File "/usr/local/lib/python3.9/dist-packages/arxpy/differential/characteristic.py", line 582, in init assert issubclass(bv_cipher, primitives.Cipher) AssertionError

ranea commented 2 years ago

It's the same problem, round_based_search_RkCh requires a subclass of Cipher. That is why the error says

assert issubclass(bv_cipher, primitives.Cipher)
AssertionError