func ValidatePublicKey(publicKeyBytes []byte) error {
	if len(publicKeyBytes) != 65 {
		return fmt.Errorf("public key bytes wrong length %d != 65", len(publicKeyBytes))
	}
	if publicKeyBytes[0] != 4 {
		return fmt.Errorf("public key bytes not in uncompressed format")
	}
	_, err := ethcrypto.UnmarshalPubkey(publicKeyBytes)
	return err
}
ValidatePublicKey validated public key bytes are valid public key
package validation
import (
	"encoding/hex"
	"fmt"
	"regexp"
	"strings"
	ethcrypto "github.com/ethereum/go-ethereum/crypto"
	"github.com/jbenet/go-base58"
	"golang.org/x/crypto/blake2b"
)
var (
	didIdentifierPattern = fmt.Sprintf(`%siot(?P<hash>[a-km-zA-HJ-NP-Z1-9]{33})`, IdentifierPrefix)
	issuerPattern        = fmt.Sprintf(`%s\#%s`, didIdentifierPattern, NamePattern)
	keyNamePattern       = fmt.Sprintf(`\%s%s`, IssuerSeparator, NamePattern)
	validDidIdentifier, _ = regexp.Compile(fmt.Sprintf(`^%s$`, didIdentifierPattern))
	validIssuer, _        = regexp.Compile(fmt.Sprintf(`^%s$`, issuerPattern))
	validKeyName, _       = regexp.Compile(fmt.Sprintf(`^%s$`, keyNamePattern))
)
func ValidateIdentifier(did string) error {
	if !validDidIdentifier.Match([]byte(did)) {
		return fmt.Errorf("invalid identifier '%s' does not match pattern '%s", did, validDidIdentifier.String())
	}
	didBytes := base58.DecodeAlphabet(did[len(IdentifierPrefix):], base58.BTCAlphabet)
	didDigest, _ := Blake2bSum160(didBytes[3:23])
	didDigestHex := hex.EncodeToString(didDigest)
	didChecksum := hex.EncodeToString(didBytes[23:27])
	if !strings.HasPrefix(didDigestHex, didChecksum) {
		return fmt.Errorf("invalid identifier '%s' checksum does not match '%s' != '%s", did, didDigestHex, didChecksum)
	}
	return nil
}
func ValidateIssuer(issuer string) error {
	if validIssuer.Match([]byte(issuer)) {
		return nil
	}
	return fmt.Errorf("invalid issuer '%s' does not match pattern '%s", issuer, validIssuer.String())
}