summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-11-23 00:16:55 +0100
committeremkael <emkael@tlen.pl>2017-11-23 00:16:55 +0100
commit0e18bb97107e945874a6cfa61042ee960f3fd766 (patch)
treedc59f5fb1a450a81009542e1a4cd7d7331687602
parent81bfd1d61aeff52569b83b16f2cc25c37e549254 (diff)
Analysis script:
* dumps diffs between successive hashes, in hex, for full 160 bits of output hash and for the used 96-bit portion * counts how many bits differ * charts the diffusion distribution against theoretical distribution
-rw-r--r--analyze.py44
-rw-r--r--results-original/multiple.dump.pngbin0 -> 111140 bytes
-rw-r--r--results-original/single.dump.pngbin0 -> 111872 bytes
-rw-r--r--results-patched/multiple.dump.pngbin0 -> 100256 bytes
-rw-r--r--results-patched/single.dump.pngbin0 -> 99936 bytes
5 files changed, 44 insertions, 0 deletions
diff --git a/analyze.py b/analyze.py
new file mode 100644
index 0000000..75d8686
--- /dev/null
+++ b/analyze.py
@@ -0,0 +1,44 @@
+import gmpy, numpy, scipy.misc, sys
+import matplotlib.pyplot as plot
+
+input_file = file(sys.argv[1])
+
+ideal_hash_diffusion = [int(scipy.misc.comb(160, n)) for n in range(0, 161)]
+hash_diffusion = [0] * 161
+ideal_deal_diffusion = [int(scipy.misc.comb(96, n)) for n in range(0, 97)]
+deal_diffusion = [0] * 97
+
+prev_seed = None
+prev_output = 0
+prev_deal = 0
+
+for line in input_file:
+ bits = line.split()
+ output = int(bits[1], 16)
+ seed = bits[0][8:48]
+ deal = output & 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000
+ if seed == prev_seed:
+ results = [output ^ prev_output, deal ^ prev_deal]
+ results += [gmpy.popcount(l) for l in results]
+ hash_diffusion[results[2]] += 1
+ deal_diffusion[results[3]] += 1
+ print '%040x %040x %3d %3d' % tuple(results)
+ prev_output = output
+ prev_deal = deal
+ prev_seed = seed
+
+ideal_hash_diffusion_normalized = [float(n)/sum(ideal_hash_diffusion) for n in ideal_hash_diffusion]
+hash_diffusion_normalized = [float(n)/sum(hash_diffusion) for n in hash_diffusion]
+ideal_deal_diffusion_normalized = [float(n)/sum(ideal_deal_diffusion) for n in ideal_deal_diffusion]
+deal_diffusion_normalized = [float(n)/sum(deal_diffusion) for n in deal_diffusion]
+
+figure = plot.figure(figsize=(20,20))
+hash_plot = figure.add_subplot(211, title='Full hash diffusion')
+hash_plot.plot(ideal_hash_diffusion_normalized)
+hash_plot.plot(hash_diffusion_normalized)
+hash_plot.legend(['Ideal', 'Actual'])
+deal_plot = figure.add_subplot(212, title='96-bit deal diffusion')
+deal_plot.plot(ideal_deal_diffusion_normalized)
+deal_plot.plot(deal_diffusion_normalized)
+deal_plot.legend(['Ideal', 'Actual'])
+figure.savefig(sys.argv[1] + '.png')
diff --git a/results-original/multiple.dump.png b/results-original/multiple.dump.png
new file mode 100644
index 0000000..f07bcfb
--- /dev/null
+++ b/results-original/multiple.dump.png
Binary files differ
diff --git a/results-original/single.dump.png b/results-original/single.dump.png
new file mode 100644
index 0000000..848a6e2
--- /dev/null
+++ b/results-original/single.dump.png
Binary files differ
diff --git a/results-patched/multiple.dump.png b/results-patched/multiple.dump.png
new file mode 100644
index 0000000..beb9c68
--- /dev/null
+++ b/results-patched/multiple.dump.png
Binary files differ
diff --git a/results-patched/single.dump.png b/results-patched/single.dump.png
new file mode 100644
index 0000000..dd8fce1
--- /dev/null
+++ b/results-patched/single.dump.png
Binary files differ