Some terminologies

Before we go to HP encoding, I will try to introduce some terminologies in advance. However, this part relates to Trie in Ethereum and perhaps you are not familiar with it. Don’t worry about that, I will try to skip that things and let us approach it by an intuitional way.

Let’s play a game. I will give you a map and a path, you have to find the animal which I am implying.

The path is: 3–2–3

The map of animals

In order to solve this game, we do step by step following:

Start at Root and the first element in path is 3, it means we must get the element of Root which labeled by number 3 and we can see that the value of that element is A. Find node A, the next element in path is 2 so we get the value in node A is D. Find node D, the last element in path is 3, obviously the value we find out is ‘Whale’.

So, the animal of the game is whale. Let’s try another path: 3–1–3–2 (the result is ‘Chicken’).

By this game we get familiar with some terminologies:

Key : Root, A, B, C, D and E in game are keys

: Root, A, B, C, D and E in game are keys Node : the content corresponding with the key in the right part of each row. For example: {1: ‘Dog’, 2: B, 3: A} .

: the content corresponding with the key in the right part of each row. For example: . Path : path is like 2–2–3 in game.

: path is like 2–2–3 in game. Value : you can see it has some elements in all nodes, every element is a key-value pair. Value is the right part of element, value can be a key or a name of animal.

: you can see it has some elements in all nodes, every element is a key-value pair. Value is the right part of element, value can be a key or a name of animal. Nibble: hex form of 4 bits is a nibble. For example: 0x1 , 0x4 , 0xf …

Differentiate RLD from HP encoding

It’s really easy to differentiate RLP from HP encoding, RLP is used for encoding/decoding Value and HP encoding is used for encoding/decoding Path.