summaryrefslogtreecommitdiff
path: root/tools/certtools.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-02-23 12:01:20 +0100
committerLinus Nordberg <linus@nordberg.se>2015-02-27 02:45:46 +0100
commitbdfa89bcf0b8f65554baabda52b107a2ab36690a (patch)
treeebd39c69dbf7ef8427ff2acad9dc7f5be07efb36 /tools/certtools.py
parentdb418ce9f59dc2e2861fd7b2398f94c4faf509e9 (diff)
Add consistency proof checking to testcase1
Fix consistency proof checking when first size is power of 2
Diffstat (limited to 'tools/certtools.py')
-rw-r--r--tools/certtools.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/certtools.py b/tools/certtools.py
index fdff0e1..2fb1492 100644
--- a/tools/certtools.py
+++ b/tools/certtools.py
@@ -549,8 +549,11 @@ def nodes_for_index(pos, treesize):
level += 1
return nodes
-def verify_consistency_proof(consistency_proof, first, second):
+def verify_consistency_proof(consistency_proof, first, second, oldhash_input):
+ if 2 ** bits(first - 1) == first:
+ consistency_proof = [oldhash_input] + consistency_proof
chain = zip(nodes_for_subtree(first, second), consistency_proof)
+ assert len(nodes_for_subtree(first, second)) == len(consistency_proof)
(_, hash) = reduce(lambda e1, e2: combine_two_hashes(e1, e2, second), chain)
(_, oldhash) = reduce(lambda e1, e2: combine_two_hashes(e1, e2, first), chain)
return (oldhash, hash)