func hexToKeybytes(hex []byte) []byte {
	if hasTerm(hex) {
		hex = hex[:len(hex)-1]
	}
	if len(hex)&1 != 0 {
		panic("can't convert hex key of odd length")
	}
	key := make([]byte, len(hex)/2)
	decodeNibbles(hex, key)
	return key
}
hexToKeybytes turns hex nibbles into key bytes.
This can only be used for keys of even length.
package trie
func hexToCompact(hex []byte) []byte {
	terminator := byte(0)
	if hasTerm(hex) {
		terminator = 1
		hex = hex[:len(hex)-1]
	}
	buf := make([]byte, len(hex)/2+1)
	buf[0] = terminator << 5  
	if len(hex)&1 == 1 {
		buf[0] |= 1 << 4  
		buf[0] |= hex[0]  
		hex = hex[1:]
	}
	decodeNibbles(hex, buf[1:])
	return buf
}
func compactToHex(compact []byte) []byte {
	base := keybytesToHex(compact)
	if base[0] < 2 {
		base = base[:len(base)-1]
	}
	chop := 2 - base[0]&1
	return base[chop:]
}
func keybytesToHex(str []byte) []byte {
	l := len(str)*2 + 1
	var nibbles = make([]byte, l)
	for i, b := range str {
		nibbles[i*2] = b / 16
		nibbles[i*2+1] = b % 16
	}
	nibbles[l-1] = 16
	return nibbles
}