func (c *Identity) ToPlain(provider identityprovider.Interface) (*identityprovider.Identity, error) {
	publicKey, err := hex.DecodeString(c.PublicKey)
	if err != nil {
		return nil, errmsg.ErrIdentityDeserialization.Wrap(err)
	}
	idSignatures, err := c.Signatures.ToPlain()
	if err != nil {
		return nil, errmsg.ErrIdentityDeserialization.Wrap(err)
	}
	return &identityprovider.Identity{
		Signatures: idSignatures,
		PublicKey:  publicKey,
		Type:       c.Type,
		ID:         c.ID,
		Provider:   provider,
	}, nil
}
ToPlain converts a CBOR serializable to a plain Identity object.
package jsonable
import (
	"encoding/hex"
	"github.com/ipfs/go-cid"
	"berty.tech/go-ipfs-log/errmsg"
	"berty.tech/go-ipfs-log/identityprovider"
	"berty.tech/go-ipfs-log/iface"
)
type Entry struct {
	V        uint64
	LogID    string
	Key      string
	Sig      string
	Hash     interface{}
	Next     []cid.Cid
	Refs     []cid.Cid
	Clock    *LamportClock
	Payload  string
	Identity *Identity
	EncryptedLinks      string
	EncryptedLinksNonce string
}
type EntryV0 struct {
	Hash    *string       `json:"hash"`
	ID      string        `json:"id"`
	Payload string        `json:"payload"`
	Next    []string      `json:"next"`
	V       uint64        `json:"v"`
	Clock   *LamportClock `json:"clock"`
	Key     string        `json:"key"`
	Sig     string        `json:"sig"`
}
type EntryV1 struct {
	V        uint64
	LogID    string
	Key      string
	Sig      string
	Hash     interface{}
	Next     []cid.Cid
	Clock    *LamportClock
	Payload  string
	Identity *Identity
}
type EntryV2 = Entry
func (c *IdentitySignature) ToPlain() (*identityprovider.IdentitySignature, error) {
	publicKey, err := hex.DecodeString(c.PublicKey)
	if err != nil {
		return nil, errmsg.ErrIdentitySigDeserialization.Wrap(err)
	}
	id, err := hex.DecodeString(c.ID)
	if err != nil {
		return nil, errmsg.ErrIdentitySigDeserialization.Wrap(err)
	}
	return &identityprovider.IdentitySignature{
		PublicKey: publicKey,
		ID:        id,
	}, nil
}
func (e *EntryV0) ToPlain(out iface.IPFSLogEntry, provider identityprovider.Interface, newClock func() iface.IPFSLogLamportClock) error {
	c := cid.Undef
	if e.Hash != nil {
		var err error
		if c, err = cid.Parse(*e.Hash); err != nil {
			return err
		}
	}
	clock := newClock()
	if err := e.Clock.ToPlain(clock); err != nil {
		return err
	}
	sig, err := hex.DecodeString(e.Sig)
	if err != nil {
		return err
	}
	key, err := hex.DecodeString(e.Key)
	if err != nil {
		return errmsg.ErrKeyDeserialization.Wrap(err)
	}
	nextValues := make([]cid.Cid, len(e.Next))
	for i, n := range e.Next {
		var err error
		nextValues[i], err = cid.Parse(n)
		if err != nil {
			return err
		}
	}
	if c.Defined() {
		out.SetHash(c)
	}
	out.SetClock(clock)
	out.SetSig(sig)
	out.SetV(e.V)
	out.SetLogID(e.ID)
	out.SetKey(key)
	out.SetSig(sig)
	out.SetNext(nextValues)
	out.SetClock(clock)
	out.SetPayload([]byte(e.Payload))
	return nil
}
type IdentitySignature struct {
	ID        string `json:"id"`
	PublicKey string `json:"public_key"`
}
type Identity struct {
	ID         string             `json:"id"`
	PublicKey  string             `json:"public_key"`
	Signatures *IdentitySignature `json:"signatures"`
	Type       string             `json:"type"`
}
type LamportClock struct {
	ID   string `json:"id"`
	Time int    `json:"time"`
}