func (k Keeper) GetRevokedCertificates(ctx sdk.Context, subject string, subjectKeyID string) types.Certificates {
	if !k.IsRevokedCertificatesPresent(ctx, subject, subjectKeyID) {
		return types.NewCertificates([]types.Certificate{})
	}
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetRevokedCertificateKey(subject, subjectKeyID))
	var cert types.Certificates
	k.cdc.MustUnmarshalBinaryBare(bz, &cert)
	return cert
}
/*
Revoked Certificate (root or non-root)

Gets the entire Revoked Certificates record associated with a Subject/SubjectKeyID combination.
package keeper
import (
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/internal/types"
)
type Keeper struct {
	storeKey sdk.StoreKey
	cdc *codec.Codec
}
func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec) Keeper {
	return Keeper{storeKey: storeKey, cdc: cdc}
}
func (k Keeper) GetApprovedCertificates(ctx sdk.Context, subject string, subjectKeyID string) types.Certificates {
	if !k.IsApprovedCertificatesPresent(ctx, subject, subjectKeyID) {
		return types.NewCertificates([]types.Certificate{})
	}
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetApprovedCertificateKey(subject, subjectKeyID))
	var cert types.Certificates
	k.cdc.MustUnmarshalBinaryBare(bz, &cert)
	return cert
}
func (k Keeper) SetApprovedCertificates(ctx sdk.Context, subject string, subjectKeyID string,
	certificates types.Certificates) {
	if len(certificates.Items) == 0 {
		panic("Cannot set approved Certificates record with no items")
	}
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetApprovedCertificateKey(subject, subjectKeyID), k.cdc.MustMarshalBinaryBare(certificates))
}
func (k Keeper) AddApprovedCertificate(ctx sdk.Context, certificate types.Certificate) {
	certificates := k.GetApprovedCertificates(ctx, certificate.Subject, certificate.SubjectKeyID)
	certificates.Items = append(certificates.Items, certificate)
	k.SetApprovedCertificates(ctx, certificate.Subject, certificate.SubjectKeyID, certificates)
}
func (k Keeper) IsApprovedCertificatesPresent(ctx sdk.Context, subject string, subjectKeyID string) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetApprovedCertificateKey(subject, subjectKeyID))
}
func (k Keeper) IterateApprovedCertificatesRecords(ctx sdk.Context, prefix string,
	process func(info types.Certificates) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, append(types.ApprovedCertificatePrefix, []byte(prefix)...))
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var certificates types.Certificates
		k.cdc.MustUnmarshalBinaryBare(val, &certificates)
		if process(certificates) {
			return
		}
		iter.Next()
	}
}
func (k Keeper) DeleteApprovedCertificates(ctx sdk.Context, subject string, subjectKeyID string) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetApprovedCertificateKey(subject, subjectKeyID))
}
func (k Keeper) GetProposedCertificate(ctx sdk.Context,
	subject string, subjectKeyID string) types.ProposedCertificate {
	if !k.IsProposedCertificatePresent(ctx, subject, subjectKeyID) {
		panic("Proposed Certificate does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetProposedCertificateKey(subject, subjectKeyID))
	var cert types.ProposedCertificate
	k.cdc.MustUnmarshalBinaryBare(bz, &cert)
	return cert
}
func (k Keeper) SetProposedCertificate(ctx sdk.Context, certificate types.ProposedCertificate) {
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetProposedCertificateKey(
		certificate.Subject, certificate.SubjectKeyID), k.cdc.MustMarshalBinaryBare(certificate))
}
func (k Keeper) IsProposedCertificatePresent(ctx sdk.Context, subject string, subjectKeyID string) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetProposedCertificateKey(subject, subjectKeyID))
}
func (k Keeper) IterateProposedCertificates(ctx sdk.Context,
	process func(info types.ProposedCertificate) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.ProposedCertificatePrefix)
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var proposedCertificate types.ProposedCertificate
		k.cdc.MustUnmarshalBinaryBare(val, &proposedCertificate)
		if process(proposedCertificate) {
			return
		}
		iter.Next()
	}
}
func (k Keeper) DeleteProposedCertificate(ctx sdk.Context, subject string, subjectKeyID string) {
	if !k.IsProposedCertificatePresent(ctx, subject, subjectKeyID) {
		panic("Proposed Certificate does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetProposedCertificateKey(subject, subjectKeyID))
}
func (k Keeper) GetChildCertificates(ctx sdk.Context, issuer string, authorityKeyID string) types.ChildCertificates {
	if !k.IsChildCertificatesPresent(ctx, issuer, authorityKeyID) {
		return types.NewChildCertificates(issuer, authorityKeyID)
	}
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetChildCertificatesKey(issuer, authorityKeyID))
	var childCertificates types.ChildCertificates
	k.cdc.MustUnmarshalBinaryBare(bz, &childCertificates)
	return childCertificates
}
func (k Keeper) SetChildCertificates(ctx sdk.Context, childCertificates types.ChildCertificates) {
	if len(childCertificates.CertIdentifiers) == 0 {
		panic("Cannot set ChildCertificates record with no CertIdentifiers")
	}
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetChildCertificatesKey(childCertificates.Issuer,
		childCertificates.AuthorityKeyID), k.cdc.MustMarshalBinaryBare(childCertificates))
}
func (k Keeper) IsChildCertificatesPresent(ctx sdk.Context, issuer string, authorityKeyID string) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetChildCertificatesKey(issuer, authorityKeyID))
}
func (k Keeper) IterateChildCertificatesRecords(ctx sdk.Context,
	process func(info types.ChildCertificates) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.ChildCertificatesPrefix)
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var childCertificatesRecord types.ChildCertificates
		k.cdc.MustUnmarshalBinaryBare(val, &childCertificatesRecord)
		if process(childCertificatesRecord) {
			return
		}
		iter.Next()
	}
}
func (k Keeper) DeleteChildCertificates(ctx sdk.Context, issuer string, authorityKeyID string) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetChildCertificatesKey(issuer, authorityKeyID))
}
func (k Keeper) SetUniqueCertificateKey(ctx sdk.Context, issuer string, serialNumber string) {
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetUniqueCertificateKey(issuer, serialNumber), k.cdc.MustMarshalBinaryBare(true))
}
func (k Keeper) IsUniqueCertificateKeyPresent(ctx sdk.Context, issuer string, serialNumber string) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetUniqueCertificateKey(issuer, serialNumber))
}
func (k Keeper) DeleteUniqueCertificateKey(ctx sdk.Context, issuer string, serialNumber string) {
	if !k.IsUniqueCertificateKeyPresent(ctx, issuer, serialNumber) {
		panic("Unique Certificate Key does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetUniqueCertificateKey(issuer, serialNumber))
}
func (k Keeper) GetProposedCertificateRevocation(ctx sdk.Context,
	subject string, subjectKeyID string) types.ProposedCertificateRevocation {
	if !k.IsProposedCertificateRevocationPresent(ctx, subject, subjectKeyID) {
		panic("Proposed Certificate Revocation does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetProposedCertificateRevocationKey(subject, subjectKeyID))
	var revocation types.ProposedCertificateRevocation
	k.cdc.MustUnmarshalBinaryBare(bz, &revocation)
	return revocation
}
func (k Keeper) SetProposedCertificateRevocation(ctx sdk.Context, revocation types.ProposedCertificateRevocation) {
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetProposedCertificateRevocationKey(
		revocation.Subject, revocation.SubjectKeyID), k.cdc.MustMarshalBinaryBare(revocation))
}
func (k Keeper) IsProposedCertificateRevocationPresent(ctx sdk.Context, subject string, subjectKeyID string) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetProposedCertificateRevocationKey(subject, subjectKeyID))
}
func (k Keeper) IterateProposedCertificateRevocations(ctx sdk.Context,
	process func(info types.ProposedCertificateRevocation) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.ProposedCertificateRevocationPrefix)
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var revocation types.ProposedCertificateRevocation
		k.cdc.MustUnmarshalBinaryBare(val, &revocation)
		if process(revocation) {
			return
		}
		iter.Next()
	}
}
func (k Keeper) DeleteProposedCertificateRevocation(ctx sdk.Context, subject string, subjectKeyID string) {
	if !k.IsProposedCertificateRevocationPresent(ctx, subject, subjectKeyID) {
		panic("Proposed Certificate Revocation does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetProposedCertificateRevocationKey(subject, subjectKeyID))
}