From e12c7bfedf2b17b00be3df8ad5aeb100d29d471b Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Fri, 26 Aug 2022 23:02:10 -0400 Subject: remove ad cache --- .gitignore | 1 - aesgcmanalysis.py | 19 ++++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 14835b2..a30ebc9 100644 --- a/.gitignore +++ b/.gitignore @@ -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) -- cgit v1.2.3