On the wire format: /----------------------+----------------+----------------+-- | SHA1 hash (20 bytes) | node (4 bytes) | node (4 bytes) | \----------------------+----------------+----------------+-- The hash is of the packet following the hash appended with the secret key (which obviously isn't sent). packet' = serialize tree hash = sha1(packet' + password) packet = hash + packet Every node occupies four bytes. The high twelve bits don't matter to us, so that's where the number of children are stored. The lower 20 bits store the 20 bits of address that are significant in our network. /-----------------------+-------------------\ | numchildren (12 bits) | address & 0xfffff | \-----------------------+-------------------/ Every node is followed by its children, recursively. So a tree that looks like: A / \ B C / \ \ D E F Would be stored like (2|A) (2|B) (0|D) (0|E) (1|C) (0|F). This packing and unpacking can be done recursively relatively easily.