func LoadStatement(r io.Reader, authority *x509.CertPool) (*Statement, error) {
	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	js, err := libtrust.ParsePrettySignature(b, "signatures")
	if err != nil {
		return nil, err
	}
	payload, err := js.Payload()
	if err != nil {
		return nil, err
	}
	var statement Statement
	err = json.Unmarshal(payload, &statement.jsonStatement)
	if err != nil {
		return nil, err
	}
	if authority == nil {
		_, err = js.Verify()
		if err != nil {
			return nil, err
		}
	} else {
		_, err = js.VerifyChains(authority)
		if err != nil {
			return nil, err
		}
	}
	statement.signature = js
	return &statement, nil
}
LoadStatement loads and verifies a statement from an input stream.
package trustgraph
import (
	"crypto/x509"
	"encoding/json"
	"io"
	"io/ioutil"
	"sort"
	"strings"
	"time"
	"github.com/docker/libtrust"
)
type jsonGrant struct {
	Subject    string `json:"subject"`
	Permission uint16 `json:"permission"`
	Grantee    string `json:"grantee"`
}
type jsonRevocation struct {
	Subject    string `json:"subject"`
	Revocation uint16 `json:"revocation"`
	Grantee    string `json:"grantee"`
}
type jsonStatement struct {
	Revocations []*jsonRevocation `json:"revocations"`
	Grants      []*jsonGrant      `json:"grants"`
	Expiration  time.Time         `json:"expiration"`
	IssuedAt    time.Time         `json:"issuedAt"`
}
func (g *jsonGrant) Grant(statement *Statement) *Grant {
	return &Grant{
		Subject:    g.Subject,
		Permission: g.Permission,
		Grantee:    g.Grantee,
		statement:  statement,
	}
}
type Statement struct {
	jsonStatement
	signature *libtrust.JSONSignature
}
func (s *Statement) IsExpired() bool {
	return s.Expiration.Before(time.Now().Add(-10 * time.Second))
}
func (s *Statement) Bytes() ([]byte, error) {
	return s.signature.PrettySignature("signatures")
}