def GenerateCollisionTree(k, stateLen):
nodesByLevel = collections.defaultdict(list)
allBytes = range(2 ** 8)
allPossibleBlocks = []
for comb in itertools.combinations(allBytes, stateLen):
byteString = b''.join(x.to_bytes(1, 'little') for x in comb)
allPossibleBlocks.append(byteString)
for level in range(k+1):
nodes = []
if level == 0:
nodes = RandomUniqueStates(2 ** k, stateLen)
else:
nodes = FindCollisions(nodesByLevel[level-1], allPossibleBlocks, stateLen)
print('Generated nodes for level %d: %s' % (level, str(nodes)))
nodesByLevel[level] = nodes
return nodesByLevel
# Now I generate a meaningful message, crafted so that it's exactly 1 block
# length, but there is no need to do so. Nobody should be seeing this
# message, only the hash.
评论列表
文章目录