summaryrefslogtreecommitdiff
path: root/tools/merge.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/merge.py')
-rwxr-xr-xtools/merge.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/merge.py b/tools/merge.py
index 3aeecdf..7c6e357 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -9,7 +9,10 @@ import base64
import urllib
import urllib2
import sys
+import time
+from certtools import build_merkle_tree, create_sth_signature, check_sth_signature
+ctbaseurl = "https://127.0.0.1:8080/"
frontendnodes = ["https://127.0.0.1:8082/"]
storagenodes = ["https://127.0.0.1:8081/"]
@@ -142,6 +145,28 @@ for new_entry in new_entries:
added_entries += 1
print "added", added_entries, "entries"
+tree = build_merkle_tree(logorder)
+tree_size = len(logorder)
+root_hash = tree[-1][0]
+timestamp = int(time.time() * 1000)
+privatekey = base64.decodestring(
+ "MHcCAQEEIMM/FjZ4FSzfENTTwGpTve6CP+IVr"
+ "Y7p8OKV634uJI/foAoGCCqGSM49AwEHoUQDQg"
+ "AE4qWq6afhBUi0OdcWUYhyJLNXTkGqQ9PMS5l"
+ "qoCgkV2h1ZvpNjBH2u8UbgcOQwqDo66z6BWQJ"
+ "GolozZYmNHE2kQ==")
+
+tree_head_signature = create_sth_signature(tree_size, timestamp,
+ root_hash, privatekey)
+
+sth = {"tree_size": tree_size, "timestamp": timestamp,
+ "sha256_root_hash": base64.b64encode(root_hash),
+ "tree_head_signature": base64.b64encode(tree_head_signature)}
+
+check_sth_signature(ctbaseurl, sth)
+
+print "root hash", base64.b16encode(root_hash)
+
for frontendnode in frontendnodes:
print "distributing for node", frontendnode
curpos = get_curpos(frontendnode)
@@ -154,4 +179,4 @@ for frontendnode in frontendnodes:
for missingentry in missingentries:
hash = base64.b64decode(missingentry)
sendentry(frontendnode, read_chain(hash), hash)
- sendsth(frontendnode, {"tree_size": len(logorder)})
+ sendsth(frontendnode, sth)