func RandomID() (id ID, err error) {
	idBytes := make([]byte, sha256.Size)
	if _, err = rand.Read(idBytes); err != nil {
		return
	}
	copy(id[:], idBytes)
	return
}
RandomID creates a random id which can for example be used in unit tests.
package identity
import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"
	"math/rand"
	"strings"
	"github.com/iotaledger/hive.go/cerrors"
	"github.com/iotaledger/hive.go/crypto/ed25519"
	"github.com/iotaledger/hive.go/marshalutil"
	"github.com/mr-tron/base58"
	"golang.org/x/xerrors"
)
const IDLength = sha256.Size
type ID [IDLength]byte
func NewID(key ed25519.PublicKey) ID {
	return sha256.Sum256(key.Bytes())
}
func IDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (id ID, err error) {
	idBytes, err := marshalUtil.ReadBytes(IDLength)
	if err != nil {
		err = xerrors.Errorf("failed to parse ID (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	copy(id[:], idBytes)
	return
}
func (id ID) Bytes() []byte {
	return id[:]
}
func (id ID) String() string {
	return base58.Encode(id[:8])
}
func ParseID(s string) (ID, error) {
	var id ID
	b, err := hex.DecodeString(strings.TrimPrefix(s, "0x"))
	if err != nil {
		return id, err
	}
	if len(b) != len(ID{}) {
		return id, fmt.Errorf("invalid length: need %d hex chars", hex.EncodedLen(len(ID{})))
	}
	copy(id[:], b)
	return id, nil
}