func KeyPathToKeys(path string) (keys [][]byte, err error) {
	if path == "" || path[0] != '/' {
		return nil, cmn.NewError("key path string must start with a forward slash '/'")
	}
	parts := strings.Split(path[1:], "/")
	keys = make([][]byte, len(parts))
	for i, part := range parts {
		if strings.HasPrefix(part, "x:") {
			hexPart := part[2:]
			key, err := hex.DecodeString(hexPart)
			if err != nil {
				return nil, cmn.ErrorWrap(err, "decoding hex-encoded part #%d: /%s", i, part)
			}
			keys[i] = key
		} else {
			key, err := url.PathUnescape(part)
			if err != nil {
				return nil, cmn.ErrorWrap(err, "decoding url-encoded part #%d: /%s", i, part)
			}
			keys[i] = []byte(key)  
		}
	}
	return keys, nil
}
Decode a path to a list of keys. Path must begin with `/`.
Each key must use a known encoding.
package merkle
import (
	"encoding/hex"
	"fmt"
	"net/url"
	"strings"
	cmn "github.com/XuanMaoSecLab/DolphinChain/libs/common"
)
type keyEncoding int
const (
	KeyEncodingURL keyEncoding = iota
	KeyEncodingHex
	KeyEncodingMax  
)
type Key struct {
	name []byte
	enc  keyEncoding
}
type KeyPath []Key
func (pth KeyPath) AppendKey(key []byte, enc keyEncoding) KeyPath {
	return append(pth, Key{key, enc})
}
func (pth KeyPath) String() string {
	res := ""
	for _, key := range pth {
		switch key.enc {
		case KeyEncodingURL:
			res += "/" + url.PathEscape(string(key.name))
		case KeyEncodingHex:
			res += "/x:" + fmt.Sprintf("%X", key.name)
		default:
			panic("unexpected key encoding type")
		}
	}
	return res
}