Add checks that len(key)<=maxKeyLen

Add checks that the key is not bigger than maximum key length for the tree
maxLevels size, where maximum key len = ceil(maxLevels/8).

This is because if the key bits length is bigger than the maxLevels of the
tree, two different keys that their difference is at the end, will collision in
the same leaf of the tree (at the max depth).
This commit is contained in:
2021-10-04 11:27:21 +02:00
parent 0921cac304
commit 30d8b42fd3
8 changed files with 279 additions and 162 deletions

View File

@@ -1,6 +1,8 @@
package arbo
import "math/big"
import (
"math/big"
)
// SwapEndianness swaps the order of the bytes in the byte slice.
func SwapEndianness(b []byte) []byte {