diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | aesgcmanalysis.py | 19 |
2 files changed, 8 insertions, 12 deletions
@@ -1,5 +1,4 @@ .ipynb_checkpoints tmp venv/ -ad.np square_basis.np diff --git a/aesgcmanalysis.py b/aesgcmanalysis.py index 1b01264..eefc59b 100644 --- a/aesgcmanalysis.py +++ b/aesgcmanalysis.py @@ -612,14 +612,14 @@ def gen_blocks(n, js): return blocks squarer = np.array(Ms()) -# adlookup = np.load(open('ad.np', 'rb')) -# mcsqlookup = np.load(open('square_basis.np', 'rb')) -adlookup = xr.open_dataarray('ad.nc') -mcsqlookup = xr.open_dataarray('square-basis.nc') +use_numpy = False +if use_numpy: + mcsqlookup = np.load(open('square-basis.np', 'rb')) +else: + mcsqlookup = xr.open_dataarray('square-basis.nc') def mc_squared(c, j): - # return sum(mcsqlookup[i, j] for i in range(128) if 1 == (c >> i) & 1) % 2 - return sum(mcsqlookup[i, j].to_numpy() for i in range(128) if 1 == (c >> i) & 1) % 2 + return sum(mcsqlookup[i, j] if use_numpy else mcsqlookup[i, j].to_numpy() for i in range(128) if 1 == (c >> i) & 1) % 2 def gen_ad(blocks): matret = np.zeros((128, 128)) @@ -641,11 +641,8 @@ def gen_ad(blocks): def gen_t(n, macbytes, X=None, minrows=8): T = [] for j in range(n*128): - if j < len(adlookup): - Ad = adlookup[j].to_numpy() - else: - blocks = gen_blocks(n, [j]) - Ad = gen_ad(blocks) + blocks = gen_blocks(n, [j]) + Ad = gen_ad(blocks) if X is not None: rows = min((n*128)//(X.shape[1]) - 1, macbytes*8-minrows) |