func BuildLogLeaf(logPrefix string,
	merkleLeaf ct.MerkleTreeLeaf, leafIndex int64,
	cert ct.ASN1Cert, chain []ct.ASN1Cert, isPrecert bool,
) (trillian.LogLeaf, error) {
	leafData, err := tls.Marshal(merkleLeaf)
	if err != nil {
		glog.Warningf("%s: Failed to serialize Merkle leaf: %v", logPrefix, err)
		return trillian.LogLeaf{}, err
	}
	extraData, err := ExtraDataForChain(cert, chain, isPrecert)
	if err != nil {
		glog.Warningf("%s: Failed to serialize chain for ExtraData: %v", logPrefix, err)
		return trillian.LogLeaf{}, err
	}
	leafIDHash := sha256.Sum256(cert.Data)
	return trillian.LogLeaf{
		LeafValue:        leafData,
		ExtraData:        extraData,
		LeafIndex:        leafIndex,
		LeafIdentityHash: leafIDHash[:],
	}, nil
}
BuildLogLeaf returns a Trillian LogLeaf structure for a (pre-)cert and the
chain of certificates leading it up to a known root.
package util
import (
	"crypto/sha256"
	"github.com/golang/glog"
	ct "github.com/google/certificate-transparency-go"
	"github.com/google/certificate-transparency-go/tls"
	"github.com/google/trillian"
)