Merge the top two hashes into one.
Start creating the authpath for the node on the top.
Sanity test for hash_stack.
1 t { 2 import dcrypt.pqc.sphincs.sphincs256: hash_2n_n; 3 4 enum hash_bytes = 32; 5 alias ubyte[hash_bytes] hash_t; 6 alias TreeUtil!(hash_2n_n, ubyte[hash_bytes], ubyte[2*hash_bytes]) Tree; 7 Tree.hash_stack!4 stack; 8 9 hash_t mask1 = 111; 10 hash_t mask2 = 222; 11 12 ubyte[2*hash_bytes] mask = mask1~mask2; 13 14 hash_t[4] l; 15 for(uint i = 0; i < l.length; ++i) l[i] = cast(ubyte) (i+1); 16 17 assert(stack.empty); 18 stack.push(l[0]); 19 stack.push(l[1]); 20 assert(l[1] == stack.pop()); 21 assert(l[0] == stack.pop()); 22 23 stack.push(l[0]); 24 stack.push(l[1]); 25 26 stack.reduce(mask); 27 hash_t hash1 = stack.pop(); 28 assert(stack.empty); 29 30 hash_t hash2 = hash_nodes(l[0], l[1], mask); 31 assert(hash1 == hash2)
Helper struct for treehash algorithm.