def test(self): # Check that the revocation proof is verifiable in T. isd_as = ISD_AS("1-11") if_ids = [23, 35, 120] initial_seed = b"qwerty" inst = ConnectedHashTree(isd_as, if_ids, initial_seed, HashType.SHA256) root = inst.get_root() # Call proof = inst.get_proof(120) # Tests ntools.eq_(ConnectedHashTree.verify(proof, root), True)
def test_one_timestep(self): # Check that the revocation proof is verifiable across T and T+1. # Setup isd_as = ISD_AS("1-11") if_ids = [23, 35, 120] initial_seed = b"qwerty" inst = ConnectedHashTree(isd_as, if_ids, initial_seed) root = inst.get_root() # Call next_tree = inst.get_next_tree(isd_as, if_ids, b"new!!seed") inst.update(next_tree) # Tests proof = inst.get_proof(35) # if_id = 35. ntools.eq_(ConnectedHashTree.verify(proof, root), True)
def test(self): # Setup isd_as = ISD_AS("1-11") if_ids = [23, 35, 120] initial_seed = b"qwerty" inst = ConnectedHashTree(isd_as, if_ids, initial_seed) root1_before_update = inst._ht1._nodes[0] root2_before_update = inst._ht2._nodes[0] # Call new_tree = inst.get_next_tree(isd_as, if_ids, b"new!!seed") inst.update(new_tree) # Tests root0_after_update = inst._ht0_root root1_after_update = inst._ht1._nodes[0] ntools.eq_(root1_before_update, root0_after_update) ntools.eq_(root2_before_update, root1_after_update)
def test_two_timesteps(self): # Check that the revocation proof is "NOT" verifiable across T and T+2. # Setup isd_as = ISD_AS("1-11") if_ids = [23, 35, 120] initial_seed = b"qwerty" inst = ConnectedHashTree(isd_as, if_ids, initial_seed, HashType.SHA256) root = inst.get_root() # Call new_tree = inst.get_next_tree(isd_as, if_ids, b"newseed.@1", HashType.SHA256) inst.update(new_tree) new_tree = inst.get_next_tree(isd_as, if_ids, b"newseed.@2", HashType.SHA256) inst.update(new_tree) # Tests proof = inst.get_proof(35) # if_id = 35. ntools.eq_(ConnectedHashTree.verify(proof, root), False)
def _init_hash_tree(self): ifs = list(self.ifid2br.keys()) self._hash_tree = ConnectedHashTree(self.addr.isd_as, ifs, self.hashtree_gen_key, HashType.SHA256)