예제 #1
0
 def send_crypttext_hash_tree_to_all_shareholders(self):
     self.log("sending crypttext hash tree", level=log.NOISY)
     self.set_status("Sending Crypttext Hash Tree")
     self.set_encode_and_push_progress(extra=0.3)
     t = HashTree(self._crypttext_hashes)
     all_hashes = list(t)
     self.uri_extension_data["crypttext_root_hash"] = t[0]
     dl = []
     for shareid in list(self.landlords):
         dl.append(self.send_crypttext_hash_tree(shareid, all_hashes))
     return self._gather_responses(dl)
예제 #2
0
 def send_all_share_hash_trees(self):
     # Each bucket gets a set of share hash tree nodes that are needed to validate their
     # share. This includes the share hash itself, but does not include the top-level hash
     # root (which is stored securely in the URI instead).
     self.log("sending all share hash trees", level=log.NOISY)
     self.set_status("Sending Share Hash Trees")
     self.set_encode_and_push_progress(extra=0.6)
     dl = []
     for h in self.share_root_hashes:
         assert h
     # create the share hash tree
     t = HashTree(self.share_root_hashes)
     # the root of this hash tree goes into our URI
     self.uri_extension_data['share_root_hash'] = t[0]
     # now send just the necessary pieces out to each shareholder
     for i in range(self.num_shares):
         # the HashTree is given a list of leaves: 0,1,2,3..n .
         # These become nodes A+0,A+1,A+2.. of the tree, where A=n-1
         needed_hash_indices = t.needed_hashes(i, include_leaf=True)
         hashes = [(hi, t[hi]) for hi in needed_hash_indices]
         dl.append(self.send_one_share_hash_tree(i, hashes))
     return self._gather_responses(dl)
예제 #3
0
 def send_one_block_hash_tree(self, shareid, block_hashes):
     t = HashTree(block_hashes)
     all_hashes = list(t)
     # all_hashes[0] is the root hash, == hash(ah[1]+ah[2])
     # all_hashes[1] is the left child, == hash(ah[3]+ah[4])
     # all_hashes[n] == hash(all_hashes[2*n+1] + all_hashes[2*n+2])
     self.share_root_hashes[shareid] = t[0]
     if shareid not in self.landlords:
         return defer.succeed(None)
     sh = self.landlords[shareid]
     d = sh.put_block_hashes(all_hashes)
     d.addErrback(self._remove_shareholder, shareid, "put_block_hashes")
     return d
예제 #4
0
 def send_all_share_hash_trees(self):
     # Each bucket gets a set of share hash tree nodes that are needed to validate their
     # share. This includes the share hash itself, but does not include the top-level hash
     # root (which is stored securely in the URI instead).
     self.log("sending all share hash trees", level=log.NOISY)
     self.set_status("Sending Share Hash Trees")
     self.set_encode_and_push_progress(extra=0.6)
     dl = []
     for h in self.share_root_hashes:
         assert h
     # create the share hash tree
     t = HashTree(self.share_root_hashes)
     # the root of this hash tree goes into our URI
     self.uri_extension_data['share_root_hash'] = t[0]
     # now send just the necessary pieces out to each shareholder
     for i in range(self.num_shares):
         # the HashTree is given a list of leaves: 0,1,2,3..n .
         # These become nodes A+0,A+1,A+2.. of the tree, where A=n-1
         needed_hash_indices = t.needed_hashes(i, include_leaf=True)
         hashes = [(hi, t[hi]) for hi in needed_hash_indices]
         dl.append(self.send_one_share_hash_tree(i, hashes))
     return self._gather_responses(dl)