@Test void testMerge() { List<Bytes32> result = new ArrayList<>(2); result.add(null); result.add(null); HashTreeUtil.merge( Bytes32.fromHexString("0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4"), 0, result, 2, 1); assertEquals( Arrays.asList( Bytes.fromHexString( "0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4"), null), result); }
static void merge(Bytes32 h, int i, List<Bytes32> tmp, long count, int depth) { int j = 0; while (true) { if ((i & (1 << j)) == 0) { if (i == count && j < depth) { h = Hash.sha2_256(Bytes.concatenate(h, zerohashes.get(j))); } else { break; } } else { h = Hash.sha2_256(Bytes.concatenate(tmp.get(j), h)); } j += 1; } tmp.set(j, h); }
HashTreeUtil { static void merge(Bytes32 h, int i, List<Bytes32> tmp, long count, int depth) { int j = 0; while (true) { if ((i & (1 << j)) == 0) { if (i == count && j < depth) { h = Hash.sha2_256(Bytes.concatenate(h, zerohashes.get(j))); } else { break; } } else { h = Hash.sha2_256(Bytes.concatenate(tmp.get(j), h)); } j += 1; } tmp.set(j, h); } }
HashTreeUtil { static void merge(Bytes32 h, int i, List<Bytes32> tmp, long count, int depth) { int j = 0; while (true) { if ((i & (1 << j)) == 0) { if (i == count && j < depth) { h = Hash.sha2_256(Bytes.concatenate(h, zerohashes.get(j))); } else { break; } } else { h = Hash.sha2_256(Bytes.concatenate(tmp.get(j), h)); } j += 1; } tmp.set(j, h); }  }
HashTreeUtil { static void merge(Bytes32 h, int i, List<Bytes32> tmp, long count, int depth) { int j = 0; while (true) { if ((i & (1 << j)) == 0) { if (i == count && j < depth) { h = Hash.sha2_256(Bytes.concatenate(h, zerohashes.get(j))); } else { break; } } else { h = Hash.sha2_256(Bytes.concatenate(tmp.get(j), h)); } j += 1; } tmp.set(j, h); }  static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes); @SuppressWarnings({"rawtypes", "unchecked"}) static Bytes32 hash_tree_root(SSZTypes sszType, SSZImmutableCollection bytes); static Bytes32 hash_tree_root_list_ul(SSZList<Bytes> bytes); static Bytes32 hash_tree_root_vector_uint64(SSZVector<UInt64> vector); @SuppressWarnings({"rawtypes", "unchecked"}) static Bytes32 hash_tree_root(SSZTypes sszType, SSZList bytes); static Bytes32 merkleize1(List<Bytes32> sszChunks, long limit); static Bytes32 merkleize(List<Bytes32> chunks, long limit); static Bytes32 merkleize(List<Bytes32> sszChunks); static Bytes32 hash_tree_root_bitlist(Bitlist bitlist); static Bytes32 hash_tree_root_bitvector(Bitvector bitvector); static Bytes32 hash_tree_root_list_bytes(SSZList<Bytes32> bytes); }
HashTreeUtil { static void merge(Bytes32 h, int i, List<Bytes32> tmp, long count, int depth) { int j = 0; while (true) { if ((i & (1 << j)) == 0) { if (i == count && j < depth) { h = Hash.sha2_256(Bytes.concatenate(h, zerohashes.get(j))); } else { break; } } else { h = Hash.sha2_256(Bytes.concatenate(tmp.get(j), h)); } j += 1; } tmp.set(j, h); }  static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes); @SuppressWarnings({"rawtypes", "unchecked"}) static Bytes32 hash_tree_root(SSZTypes sszType, SSZImmutableCollection bytes); static Bytes32 hash_tree_root_list_ul(SSZList<Bytes> bytes); static Bytes32 hash_tree_root_vector_uint64(SSZVector<UInt64> vector); @SuppressWarnings({"rawtypes", "unchecked"}) static Bytes32 hash_tree_root(SSZTypes sszType, SSZList bytes); static Bytes32 merkleize1(List<Bytes32> sszChunks, long limit); static Bytes32 merkleize(List<Bytes32> chunks, long limit); static Bytes32 merkleize(List<Bytes32> sszChunks); static Bytes32 hash_tree_root_bitlist(Bitlist bitlist); static Bytes32 hash_tree_root_bitvector(Bitvector bitvector); static Bytes32 hash_tree_root_list_bytes(SSZList<Bytes32> bytes); static final int BYTES_PER_CHUNK; }