summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyfraeviolae <cyfraeviolae>2022-08-26 23:02:10 -0400
committercyfraeviolae <cyfraeviolae>2022-08-26 23:02:10 -0400
commite12c7bfedf2b17b00be3df8ad5aeb100d29d471b (patch)
tree90497f231d2f3b53c2732c23717fff5aa5333e1e
parentc497de77a0002ef057a1ad50771454bcf0a43918 (diff)
remove ad cache
-rw-r--r--.gitignore1
-rw-r--r--aesgcmanalysis.py19
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)