Skip to content

Commit

Permalink
Separates service internal namespace from externally added keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
andresuribe87 committed Jul 10, 2023
1 parent a85975f commit 0cedb57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/service/keystore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type ServiceKey struct {

const (
namespace = "keystore"
serviceNamespace = "keystore:service-internal"
publicNamespaceSuffix = ":public-keys"
skKey = "ssi-service-key"
keyNotFoundErrMsg = "key not found"
Expand Down Expand Up @@ -193,14 +194,14 @@ func storeServiceKey(ctx context.Context, tx storage.Tx, key ServiceKey) error {
if err != nil {
return sdkutil.LoggingErrorMsg(err, "could not marshal service key")
}
if err = tx.Write(ctx, namespace, skKey, keyBytes); err != nil {
if err = tx.Write(ctx, serviceNamespace, skKey, keyBytes); err != nil {
return sdkutil.LoggingErrorMsg(err, "could store marshal service key")
}
return nil
}

func getServiceKey(ctx context.Context, db storage.ServiceStorage) ([]byte, error) {
storedKeyBytes, err := db.Read(ctx, namespace, skKey)
storedKeyBytes, err := db.Read(ctx, serviceNamespace, skKey)
if err != nil {
return nil, sdkutil.LoggingErrorMsg(err, "could not get service key")
}
Expand Down

0 comments on commit 0cedb57

Please sign in to comment.