summaryrefslogtreecommitdiff
path: root/tools/testcase1.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-02-20 01:58:17 +0100
committerMagnus Ahltorp <map@kth.se>2015-02-20 01:58:17 +0100
commit4ad45f4b58fe0432f0ee48d9e2fa3cb61792e765 (patch)
tree9d4d35b06bb17077765c27ad279906a839a5ce5c /tools/testcase1.py
parentd01055be865c2f36100b123f66baf44c8a4d4557 (diff)
testcase1: Actually verify inclusion proof
Diffstat (limited to 'tools/testcase1.py')
-rwxr-xr-xtools/testcase1.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/testcase1.py b/tools/testcase1.py
index 415d475..ce322f1 100755
--- a/tools/testcase1.py
+++ b/tools/testcase1.py
@@ -84,8 +84,15 @@ def get_and_validate_proof(timestamp, chain, leaf_index, nentries):
leaf_hash = get_leaf_hash(merkle_tree_leaf)
sth = get_sth(baseurl)
proof = get_proof_by_hash(baseurl, leaf_hash, sth["tree_size"])
- assert_equal(proof["leaf_index"], leaf_index, "leaf_index")
- assert_equal(len(proof["audit_path"]), nentries, "audit_path length")
+ leaf_index = proof["leaf_index"]
+ inclusion_proof = [base64.b64decode(e) for e in proof["audit_path"]]
+ assert_equal(leaf_index, leaf_index, "leaf_index")
+ assert_equal(len(inclusion_proof), nentries, "audit_path length")
+
+ calc_root_hash = verify_inclusion_proof(inclusion_proof, leaf_index, sth["tree_size"], leaf_hash)
+ root_hash = base64.b64decode(sth["sha256_root_hash"])
+
+ assert_equal(root_hash, calc_root_hash, "verified root hash", nodata=True)
get_and_check_entry(timestamp, chain, leaf_index)
def get_and_check_entry(timestamp, chain, leaf_index):