diff options
author | Magnus Ahltorp <map@kth.se> | 2015-02-23 12:01:20 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2015-02-23 12:01:20 +0100 |
commit | 7d923377259b1bd67ce860a0fd3c4379adc7387d (patch) | |
tree | 7b7b9121613dd1529398e5003bf9acd617ae3f7c /tools/certtools.py | |
parent | 062c633d675a0523ed423f1f4e729d17356f6617 (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.py | 5 |
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) |