func createMasterLock(secretLockSvc secretlock.Service) (string, error) {
	masterKeyContent := random.GetRandomBytes(uint32(32))  
	masterLockEnc, err := secretLockSvc.Encrypt(localKeyURIPrefix, &secretlock.EncryptRequest{
		Plaintext: string(masterKeyContent),
	})
	if err != nil {
		return "", fmt.Errorf("failed to create master lock from secret lock service provided: %w", err)
	}
	return masterLockEnc.Ciphertext, nil
}
createMasterLock creates master lock from secret lock service provided.
package wallet
import (
	"bytes"
	"crypto/ed25519"
	"crypto/sha256"
	"errors"
	"fmt"
	"net/http"
	"strings"
	"sync"
	"time"
	"github.com/bluele/gcache"
	"github.com/btcsuite/btcutil/base58"
	"github.com/google/tink/go/subtle/random"
	"github.com/google/uuid"
	"github.com/hyperledger/aries-framework-go/pkg/crypto"
	"github.com/hyperledger/aries-framework-go/pkg/crypto/primitive/bbs12381g2pub"
	"github.com/hyperledger/aries-framework-go/pkg/doc/jose/jwk"
	"github.com/hyperledger/aries-framework-go/pkg/kms"
	"github.com/hyperledger/aries-framework-go/pkg/kms/localkms"
	"github.com/hyperledger/aries-framework-go/pkg/kms/webkms"
	"github.com/hyperledger/aries-framework-go/pkg/secretlock"
	"github.com/hyperledger/aries-framework-go/pkg/secretlock/local"
	"github.com/hyperledger/aries-framework-go/pkg/secretlock/local/masterlock/hkdf"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
const (
	localKeyURIPrefix = "local-lock://"
	defaultCacheExpiry = 10 * time.Minute
	vmSectionCount = 2
)
const (
	Ed25519VerificationKey2018 = "ed25519verificationkey2018"
	Bls12381G1Key2020          = "bls12381g1key2020"
)
var jwkCurves = map[string]kms.KeyType{
	"Ed25519":    kms.ED25519Type,
	"P-256":      kms.ECDSAP256TypeIEEEP1363,
	"P-384":      kms.ECDSAP384TypeIEEEP1363,
	"BLS12381G2": kms.BLS12381G2Type,
}
var (
	ErrAlreadyUnlocked = errors.New("wallet already unlocked")
	ErrWalletLocked = errors.New("wallet locked")
	ErrInvalidAuthToken = errors.New("invalid auth token")
)
var (
	walletKMSInstance *walletKeyManager
	kmsStoreOnce      sync.Once
)
func keyManager() *walletKeyManager {
	kmsStoreOnce.Do(func() {
		walletKMSInstance = &walletKeyManager{
			gstore: gcache.New(0).Build(),
		}
	})
	return walletKMSInstance
}
type walletKeyManager struct {
	gstore gcache.Cache
}
func (k *walletKeyManager) createKeyManager(profileInfo *profile,
	storeProvider storage.Provider, opts *unlockOpts) (string, error) {
	if profileInfo.MasterLockCipher == "" && profileInfo.KeyServerURL == "" {
		return "", fmt.Errorf("invalid wallet profile")
	}
	token, _ := k.getKeyMangerToken(profileInfo.User)  
	if token != "" {
		return "", ErrAlreadyUnlocked
	}
	var err error
	var keyManager kms.KeyManager
	if profileInfo.MasterLockCipher != "" {
		keyManager, err = createLocalKeyManager(profileInfo.User, opts.passphrase,
			profileInfo.MasterLockCipher, opts.secretLockSvc, storeProvider)
		if err != nil {
			return "", fmt.Errorf("failed to create local key manager: %w", err)
		}
	} else {
		keyManager = createRemoteKeyManager(opts, profileInfo.KeyServerURL)
	}
	token = uuid.New().String()
	err = k.saveKeyManger(profileInfo.User, token, keyManager, opts.tokenExpiry)
	if err != nil {
		return "", fmt.Errorf("failed to persist local key manager: %w", err)
	}
	return token, nil
}
func (k *walletKeyManager) saveKeyManger(user, key string, manager kms.KeyManager, expiration time.Duration) error {
	if expiration == 0 {
		expiration = defaultCacheExpiry
	}
	err := k.gstore.SetWithExpire(user, key, expiration)
	if err != nil {
		return err
	}
	return k.gstore.SetWithExpire(key, manager, expiration)
}
func (k *walletKeyManager) getKeyManger(key string) (kms.KeyManager, error) {
	val, err := k.gstore.Get(key)
	if err != nil {
		return nil, err
	}
	return val.(kms.KeyManager), nil
}
func (k *walletKeyManager) getKeyMangerToken(user string) (string, error) {
	val, err := k.gstore.Get(user)
	if err != nil {
		return "", err
	}
	return val.(string), nil
}
func (k *walletKeyManager) removeKeyManager(user string) bool {
	token, _ := k.getKeyMangerToken(user)  
	if token != "" {
		return k.gstore.Remove(token) && k.gstore.Remove(user)
	}
	return false
}