Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

AES tables vs. intrinsics; X11 implementation novice question in c++

Discussion in 'Questions and Help' started by Crotchfire, Feb 23, 2015.

  1. Crotchfire

    Crotchfire New Member

    Joined:
    Feb 23, 2015
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    I've been putting together my own implementation of the X11 algorithm by trying to reverse engineer stuff I find off Git... but I'm trying to understand what's going on as I do this and that certainly slows things down :)

    Anyway, the code that I've been using as my reference has an AES round implementation (Echo and Shavite) that uses a set of 4 lookup tables (each table contains 256 32bit integers). The code of interest looks like:

    y0 = AES0[(x0)& 0xFF]
    ^ AES1[(x1 >> 8) & 0xFF]
    ^ AES2[(x2 >> 16) & 0xFF]
    ^ AES3[(x3 >> 24) & 0xFF];
    y1 = AES0[(x1)& 0xFF]
    ^ AES1[(x2 >> 8) & 0xFF]
    ^ AES2[(x3 >> 16) & 0xFF]
    ^ AES3[(x0 >> 24) & 0xFF];
    y2 = AES0[(x2)& 0xFF]
    ^ AES1[(x3 >> 8) & 0xFF]
    ^ AES2[(x0 >> 16) & 0xFF]
    ^ AES3[(x1 >> 24) & 0xFF];
    y3 = AES0[(x3)& 0xFF]
    ^ AES1[(x0 >> 8) & 0xFF]
    ^ AES2[(x1 >> 16) & 0xFF]
    ^ AES3[(x2 >> 24) & 0xFF];

    I did a little bit of googling to see what I could find out about AES, and there's a fair amount to read up on, it seems. I did find that in MSVS 2010 (what I'm currently using), there are a number of AES functions already available to me (I'd provide a link, but this is my first post and the forums are understandably worried about links from first-time posters. Look up AES Intrinsics on MSDN).

    My question is this: can the behavior of that code snippet I've put up be reproduced with those AES Intrinsics? Without the lookup tables?

    I suspect they can, and I have a little bit of an idea how, but I figured I'd ask around a place like this to try and cut to the chase :)

    Note: I'm not convinced that I ought to keep or do away with the lookup tables; here I'm really just trying to better my understanding about how things are put together. That said, I'm certainly open to hearing opinions about why you think I should or shouldn't.
     
    • Like Like x 1
  2. Sub-Ether

    Sub-Ether Well-known Member

    Joined:
    Mar 31, 2014
    Messages:
    1,516
    Likes Received:
    1,254
    Trophy Points:
    183
    Interesting you try it but I suspect c++ will be super slow, although am guessing this is for learning purposes and not mining. We used Matlab in University, its a great mathematical modeling language, might suit the purpose better, I always found it more user friendly and less error prone myself.
     
  3. Crotchfire

    Crotchfire New Member

    Joined:
    Feb 23, 2015
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    There may come a day when I try to make a miner explicitly for mining purposes... but it is not this day. Right now, I'm just trying to learn as much as I can for my toy project :)

    I'm actually using c++ partly for that reason as well. I have used matlab before; really I'm most familiar/proficient with Python and R. I'm doing this in c++ though, because I'm trying to better acquaint myself with better/efficient coding/optimization practices in a lower level language.