def wots_leaf(self, address, SK1, masks): seed = self.Fa(address, SK1) pk_A = self.wots.keygen(seed, masks) def H(x, y, i): return self.H(xor(x, masks[2 * i]), xor(y, masks[2 * i + 1])) return root(l_tree(H, pk_A))
def verify(self, M, sig, PK): i, R1, sig_horst, *sig = sig PK1, Q = PK Qtree = Q[2 * ceil(log(self.wots.l, 2)):] D = self.Hdigest(R1, M) pk = pk_horst = self.horst.verify(D, sig_horst, Q) if pk_horst is False: return False subh = self.h // self.d H = lambda x, y, i: self.H(xor(x, Q[2*i]), xor(y, Q[2*i+1])) Ht = lambda x, y, i: self.H(xor(x, Qtree[2*i]), xor(y, Qtree[2*i+1])) for _ in range(self.d): wots_sig, wots_path, *sig = sig pk_wots = self.wots.verify(pk, wots_sig, Q) leaf = root(l_tree(H, pk_wots)) pk = construct_root(Ht, wots_path, leaf, i & 0x1f) i >>= subh return PK1 == pk
def wots_leaf(self, address, SK1, masks): seed = self.Fa(address, SK1) pk_A = self.wots.keygen(seed, masks) H = lambda x, y, i: self.H(xor(x, masks[2*i]), xor(y, masks[2*i+1])) return root(l_tree(H, pk_A))
def test_sum_l_tree(): sum_tree = list(l_tree(lambda x, y, i: x + y, range(20))) assert sum_tree[-1][0] == sum(range(20))
def test_right_tree(): max_tree = list(l_tree(lambda x, y, i: y, range(20))) assert max_tree[-1][0] == max(range(20))
def test_left_tree(): min_tree = list(l_tree(lambda x, y, i: x, range(20))) assert min_tree[-1][0] == min(range(20))