func New(p provider) (*Command, error) {
	verifiableStore, err := verifiablestore.New(p)
	if err != nil {
		return nil, fmt.Errorf("new vc store : %w", err)
	}
	didStore, err := didstore.New(p)
	if err != nil {
		return nil, fmt.Errorf("new did store : %w", err)
	}
	return &Command{
		verifiableStore: verifiableStore,
		didStore:        didStore,
		resolver:        verifiable.NewVDRKeyResolver(p.VDRegistry()),
		ctx:             p,
		documentLoader:  p.JSONLDDocumentLoader(),
	}, nil
}
New returns new verifiable credential controller command instance.
package verifiable
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"strings"
	"github.com/piprate/json-gold/ld"
	"github.com/hyperledger/aries-framework-go/pkg/common/log"
	"github.com/hyperledger/aries-framework-go/pkg/controller/command"
	"github.com/hyperledger/aries-framework-go/pkg/controller/internal/cmdutil"
	ariescrypto "github.com/hyperledger/aries-framework-go/pkg/crypto"
	"github.com/hyperledger/aries-framework-go/pkg/doc/did"
	"github.com/hyperledger/aries-framework-go/pkg/doc/signature/jsonld"
	verifiablesigner "github.com/hyperledger/aries-framework-go/pkg/doc/signature/signer"
	"github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite"
	"github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/bbsblssignature2020"
	"github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/ed25519signature2018"
	"github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/jsonwebsignature2020"
	"github.com/hyperledger/aries-framework-go/pkg/doc/verifiable"
	"github.com/hyperledger/aries-framework-go/pkg/framework/aries/api/vdr"
	"github.com/hyperledger/aries-framework-go/pkg/internal/logutil"
	"github.com/hyperledger/aries-framework-go/pkg/kms"
	"github.com/hyperledger/aries-framework-go/pkg/kms/localkms"
	didstore "github.com/hyperledger/aries-framework-go/pkg/store/did"
	verifiablestore "github.com/hyperledger/aries-framework-go/pkg/store/verifiable"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
var logger = log.New("aries-framework/command/verifiable")
const (
	InvalidRequestErrorCode = command.Code(iota + command.VC)
	ValidateCredentialErrorCode
	SaveCredentialErrorCode
	GetCredentialErrorCode
	GetCredentialByNameErrorCode
	GeneratePresentationErrorCode
	GeneratePresentationByIDErrorCode
	SavePresentationErrorCode
	GetPresentationErrorCode
	GetCredentialsErrorCode
	GetPresentationsErrorCode
	SignCredentialErrorCode
	RemoveCredentialByNameErrorCode
	RemovePresentationByNameErrorCode
	DeriveCredentialErrorCode
)
const (
	CommandName = "verifiable"
	ValidateCredentialCommandMethod       = "ValidateCredential"
	SaveCredentialCommandMethod           = "SaveCredential"
	GetCredentialCommandMethod            = "GetCredential"
	GetCredentialByNameCommandMethod      = "GetCredentialByName"
	GetCredentialsCommandMethod           = "GetCredentials"
	SignCredentialCommandMethod           = "SignCredential"
	DeriveCredentialCommandMethod         = "DeriveCredential"
	SavePresentationCommandMethod         = "SavePresentation"
	GetPresentationCommandMethod          = "GetPresentation"
	GetPresentationsCommandMethod         = "GetPresentations"
	GeneratePresentationCommandMethod     = "GeneratePresentation"
	GeneratePresentationByIDCommandMethod = "GeneratePresentationByID"
	RemoveCredentialByNameCommandMethod   = "RemoveCredentialByName"
	RemovePresentationByNameCommandMethod = "RemovePresentationByName"
	errEmptyCredentialName   = "credential name is mandatory"
	errEmptyPresentationName = "presentation name is mandatory"
	errEmptyCredentialID     = "credential id is mandatory"
	errEmptyPresentationID   = "presentation id is mandatory"
	errEmptyDID              = "did is mandatory"
	errEmptyCredential       = "credential is mandatory is mandatory"
	errEmptyFrame            = "frame is mandatory is mandatory"
	vcID   = "vcID"
	vcName = "vcName"
	vpID   = "vpID"
	creatorParts = 2
	Ed25519Signature2018 = "Ed25519Signature2018"
	JSONWebSignature2020 = "JsonWebSignature2020"
	BbsBlsSignature2020 = "BbsBlsSignature2020"
	Ed25519Curve = "Ed25519"
	P256KeyCurve = "P-256"
	P384KeyCurve = "P-384"
	P521KeyCurve = "P-521"
	Ed25519VerificationKey = "Ed25519VerificationKey"
	JSONWebKey2020 = "JsonWebKey2020"
)
type provable interface {
	AddLinkedDataProof(context *verifiable.LinkedDataProofContext, jsonldOpts ...jsonld.ProcessorOpts) error
}
type keyResolver interface {
	PublicKeyFetcher() verifiable.PublicKeyFetcher
}
type kmsSigner struct {
	keyHandle interface{}
	crypto    ariescrypto.Crypto
	bbs       bool
}
func getKID(opts *ProofOptions) string {
	if opts.KID != "" {
		return opts.KID
	}
	idSplit := strings.Split(opts.VerificationMethod, "#")
	if len(idSplit) == creatorParts {
		return idSplit[1]
	}
	return ""
}
func newKMSSigner(keyManager kms.KeyManager, c ariescrypto.Crypto, kid string) (*kmsSigner, error) {
	keyHandler, err := keyManager.Get(kid)
	if err != nil {
		return nil, err
	}
	return &kmsSigner{keyHandle: keyHandler, crypto: c}, nil
}
func (s *kmsSigner) textToLines(txt string) [][]byte {
	lines := strings.Split(txt, "\n")
	linesBytes := make([][]byte, 0, len(lines))
	for i := range lines {
		if strings.TrimSpace(lines[i]) != "" {
			linesBytes = append(linesBytes, []byte(lines[i]))
		}
	}
	return linesBytes
}
func (s *kmsSigner) Sign(data []byte) ([]byte, error) {
	if s.bbs {
		return s.crypto.SignMulti(s.textToLines(string(data)), s.keyHandle)
	}
	v, err := s.crypto.Sign(data, s.keyHandle)
	if err != nil {
		return nil, err
	}
	return v, nil
}
type provider interface {
	StorageProvider() storage.Provider
	VDRegistry() vdr.Registry
	KMS() kms.KeyManager
	Crypto() ariescrypto.Crypto
	JSONLDDocumentLoader() ld.DocumentLoader
}
type Command struct {
	verifiableStore verifiablestore.Store
	didStore        *didstore.Store
	resolver        keyResolver
	ctx             provider
	documentLoader  ld.DocumentLoader
}