@Test void shouldHashTreeRootCorrectly() { final Bytes input = Bytes.fromHexString( "0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4BF2D153F649F7B53359FE8B94A38E44C"); final Bytes expected = Bytes.fromHexString("0x89E40BFF069E391CA393901DA3287BBE35DC429265927ABE3C3F06BEC8E0B9CD"); final Bytes32 actual = HashTreeUtil.hash_tree_root(HashTreeUtil.SSZTypes.VECTOR_OF_BASIC, input); assertEquals(expected, actual); }
public static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes) { switch (sszType) { case BASIC: return hash_tree_root_basic_type(bytes); case BITLIST: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.BITLIST, int, Bytes...) for a bitlist type."); case VECTOR_OF_BASIC: return hash_tree_root_vector_of_basic_type(bytes); case VECTOR_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.TUPLE_OF_COMPOSITE, List) for a fixed length list of composite SSZ types."); case LIST_OF_BASIC: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.LIST_OF_BASIC, int, Bytes...) for a variable length list of basic SSZ type."); case LIST_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.LIST_COMPOSITE, List) for a variable length list of composite SSZ types."); case CONTAINER: throw new UnsupportedOperationException( "hash_tree_root of SSZ Containers (often implemented by POJOs) must be done by the container POJO itself, as its individual fields cannot be enumerated without reflection."); default: break; } return Bytes32.ZERO; }
HashTreeUtil { public static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes) { switch (sszType) { case BASIC: return hash_tree_root_basic_type(bytes); case BITLIST: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.BITLIST, int, Bytes...) for a bitlist type."); case VECTOR_OF_BASIC: return hash_tree_root_vector_of_basic_type(bytes); case VECTOR_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.TUPLE_OF_COMPOSITE, List) for a fixed length list of composite SSZ types."); case LIST_OF_BASIC: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.LIST_OF_BASIC, int, Bytes...) for a variable length list of basic SSZ type."); case LIST_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.LIST_COMPOSITE, List) for a variable length list of composite SSZ types."); case CONTAINER: throw new UnsupportedOperationException( "hash_tree_root of SSZ Containers (often implemented by POJOs) must be done by the container POJO itself, as its individual fields cannot be enumerated without reflection."); default: break; } return Bytes32.ZERO; } }
HashTreeUtil { public static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes) { switch (sszType) { case BASIC: return hash_tree_root_basic_type(bytes); case BITLIST: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.BITLIST, int, Bytes...) for a bitlist type."); case VECTOR_OF_BASIC: return hash_tree_root_vector_of_basic_type(bytes); case VECTOR_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.TUPLE_OF_COMPOSITE, List) for a fixed length list of composite SSZ types."); case LIST_OF_BASIC: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.LIST_OF_BASIC, int, Bytes...) for a variable length list of basic SSZ type."); case LIST_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.LIST_COMPOSITE, List) for a variable length list of composite SSZ types."); case CONTAINER: throw new UnsupportedOperationException( "hash_tree_root of SSZ Containers (often implemented by POJOs) must be done by the container POJO itself, as its individual fields cannot be enumerated without reflection."); default: break; } return Bytes32.ZERO; }  }
HashTreeUtil { public static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes) { switch (sszType) { case BASIC: return hash_tree_root_basic_type(bytes); case BITLIST: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.BITLIST, int, Bytes...) for a bitlist type."); case VECTOR_OF_BASIC: return hash_tree_root_vector_of_basic_type(bytes); case VECTOR_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.TUPLE_OF_COMPOSITE, List) for a fixed length list of composite SSZ types."); case LIST_OF_BASIC: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.LIST_OF_BASIC, int, Bytes...) for a variable length list of basic SSZ type."); case LIST_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.LIST_COMPOSITE, List) for a variable length list of composite SSZ types."); case CONTAINER: throw new UnsupportedOperationException( "hash_tree_root of SSZ Containers (often implemented by POJOs) must be done by the container POJO itself, as its individual fields cannot be enumerated without reflection."); default: break; } return Bytes32.ZERO; }  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 { public static Bytes32 hash_tree_root(SSZTypes sszType, Bytes... bytes) { switch (sszType) { case BASIC: return hash_tree_root_basic_type(bytes); case BITLIST: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.BITLIST, int, Bytes...) for a bitlist type."); case VECTOR_OF_BASIC: return hash_tree_root_vector_of_basic_type(bytes); case VECTOR_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.TUPLE_OF_COMPOSITE, List) for a fixed length list of composite SSZ types."); case LIST_OF_BASIC: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZType.LIST_OF_BASIC, int, Bytes...) for a variable length list of basic SSZ type."); case LIST_OF_COMPOSITE: throw new UnsupportedOperationException( "Use HashTreeUtil.hash_tree_root(SSZTypes.LIST_COMPOSITE, List) for a variable length list of composite SSZ types."); case CONTAINER: throw new UnsupportedOperationException( "hash_tree_root of SSZ Containers (often implemented by POJOs) must be done by the container POJO itself, as its individual fields cannot be enumerated without reflection."); default: break; } return Bytes32.ZERO; }  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; }