When serialising a variable length of depths and extension status, we do not need to encode the number of depths/extension status, because this matches the number of stems.We could therefore ask the user to provide the number of stems.
This however, means we will need a method which iterates over all of the keys and figures out how many stems we have. This is a linear time operation and also makes for a less than desirable UX. Instead, we can encode the length using a u32 which takes up an extra 4 bytes in the proof, a u16 may also possibly be sufficient, but has not been confirmed, so will stick with a u32.
When serialising a variable length of depths and extension status, we do not need to encode the number of depths/extension status, because this matches the number of stems.We could therefore ask the user to provide the number of stems.
This however, means we will need a method which iterates over all of the keys and figures out how many stems we have. This is a linear time operation and also makes for a less than desirable UX. Instead, we can encode the length using a u32 which takes up an extra 4 bytes in the proof, a u16 may also possibly be sufficient, but has not been confirmed, so will stick with a u32.