func (ks *fileBasedKeyStore) GetKey(ski []byte) (bccsp.Key, error) {
	if len(ski) == 0 {
		return nil, errors.New("invalid SKI. Cannot be of zero length")
	}
	suffix := ks.getSuffix(hex.EncodeToString(ski))
	switch suffix {
	case "key":
		key, err := ks.loadKey(hex.EncodeToString(ski))
		if err != nil {
			return nil, fmt.Errorf("failed loading key [%x] [%s]", ski, err)
		}
		return &aesPrivateKey{key, false}, nil
	case "sk":
		key, err := ks.loadPrivateKey(hex.EncodeToString(ski))
		if err != nil {
			return nil, fmt.Errorf("failed loading secret key [%x] [%s]", ski, err)
		}
		switch k := key.(type) {
		case *ecdsa.PrivateKey:
			return &ecdsaPrivateKey{k, true}, nil
		default:
			return nil, errors.New("secret key type not recognized")
		}
	case "pk":
		key, err := ks.loadPublicKey(hex.EncodeToString(ski))
		if err != nil {
			return nil, fmt.Errorf("failed loading public key [%x] [%s]", ski, err)
		}
		switch k := key.(type) {
		case *ecdsa.PublicKey:
			return &ecdsaPublicKey{k}, nil
		default:
			return nil, errors.New("public key type not recognized")
		}
	default:
		return ks.searchKeystoreForSKI(ski)
	}
}
GetKey returns a key object whose SKI is the one passed.
package sw
import (
	"bytes"
	"crypto/ecdsa"
	"encoding/hex"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp"
)
func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (bccsp.KeyStore, error) {
	ks := &fileBasedKeyStore{}
	return ks, ks.Init(pwd, path, readOnly)
}
type fileBasedKeyStore struct {
	path string
	readOnly bool
	isOpen   bool
	pwd []byte
	m sync.Mutex
}
func (ks *fileBasedKeyStore) Init(pwd []byte, path string, readOnly bool) error {
	if len(path) == 0 {
		return errors.New("an invalid KeyStore path provided. Path cannot be an empty string")
	}
	ks.m.Lock()
	defer ks.m.Unlock()
	if ks.isOpen {
		return errors.New("keystore is already initialized")
	}
	ks.path = path
	clone := make([]byte, len(pwd))
	copy(ks.pwd, pwd)
	ks.pwd = clone
	ks.readOnly = readOnly
	exists, err := dirExists(path)
	if err != nil {
		return err
	}
	if !exists {
		err = ks.createKeyStore()
		if err != nil {
			return err
		}
		return ks.openKeyStore()
	}
	empty, err := dirEmpty(path)
	if err != nil {
		return err
	}
	if empty {
		err = ks.createKeyStore()
		if err != nil {
			return err
		}
	}
	return ks.openKeyStore()
}
func (ks *fileBasedKeyStore) ReadOnly() bool {
	return ks.readOnly
}