func (sm *SignedManifest) UnmarshalJSON(b []byte) error {
	sm.all = make([]byte, len(b), len(b))
	copy(sm.all, b)
	jsig, err := libtrust.ParsePrettySignature(b, "signatures")
	if err != nil {
		return err
	}
	bytes, err := jsig.Payload()
	if err != nil {
		return err
	}
	sm.Canonical = make([]byte, len(bytes), len(bytes))
	copy(sm.Canonical, bytes)
	var manifest Manifest
	if err := json.Unmarshal(sm.Canonical, &manifest); err != nil {
		return err
	}
	sm.Manifest = manifest
	return nil
}
UnmarshalJSON populates a new SignedManifest struct from JSON data.
package schema1
import (
	"encoding/json"
	"fmt"
	"github.com/docker/distribution"
	"github.com/docker/distribution/manifest"
	"github.com/docker/libtrust"
	"github.com/opencontainers/go-digest"
)
const (
	MediaTypeManifest = "application/vnd.docker.distribution.manifest.v1+json"
	MediaTypeSignedManifest = "application/vnd.docker.distribution.manifest.v1+prettyjws"
	MediaTypeManifestLayer = "application/vnd.docker.container.image.rootfs.diff+x-gtar"
)
var (
	SchemaVersion = manifest.Versioned{
		SchemaVersion: 1,
	}
)
func init() {
	schema1Func := func(b []byte) (distribution.Manifest, distribution.Descriptor, error) {
		sm := new(SignedManifest)
		err := sm.UnmarshalJSON(b)
		if err != nil {
			return nil, distribution.Descriptor{}, err
		}
		desc := distribution.Descriptor{
			Digest:    digest.FromBytes(sm.Canonical),
			Size:      int64(len(sm.Canonical)),
			MediaType: MediaTypeSignedManifest,
		}
		return sm, desc, err
	}
	err := distribution.RegisterManifestSchema(MediaTypeSignedManifest, schema1Func)
	if err != nil {
		panic(fmt.Sprintf("Unable to register manifest: %s", err))
	}
	err = distribution.RegisterManifestSchema("", schema1Func)
	if err != nil {
		panic(fmt.Sprintf("Unable to register manifest: %s", err))
	}
	err = distribution.RegisterManifestSchema("application/json", schema1Func)
	if err != nil {
		panic(fmt.Sprintf("Unable to register manifest: %s", err))
	}
}
type FSLayer struct {
	BlobSum digest.Digest `json:"blobSum"`
}
type History struct {
	V1Compatibility string `json:"v1Compatibility"`
}
type Manifest struct {
	manifest.Versioned
	Name string `json:"name"`
	Tag string `json:"tag"`
	Architecture string `json:"architecture"`
	FSLayers []FSLayer `json:"fsLayers"`
	History []History `json:"history"`
}
type SignedManifest struct {
	Manifest
	Canonical []byte `json:"-"`
	all []byte
}