asset_mgmt

package
v0.0.0-...-aeb4a1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package asset_mgmt is responsible for storing any type of asset on the ledger. It handles encryption/decryption of asset private data as well as indexing.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAssetId

func GetAssetId(assetNamespace string, id string) string

GetAssetId returns the assetId given the asset's namespace and unique identifier.

Example
assetId := GetAssetId("data_model.Asset", "asset1")

fmt.Println(assetId)
Output:

asset_hFOXaLsPZF3BnIi3pgDqC7u7yuLs2WL5RxvJRGm/Vbg=

func GetAssetKey

func GetAssetKey(stub cached_stub.CachedStubInterface, assetId string, keyPath []string, startKey []byte) ([]byte, error)

GetAssetKey returns decrypted asset key given a key path. Caller must supply the key path. If keyPath is valid, it returns decrypted asset key. If keyPath is invalid, it returns nil for asset key and the error.

func GetAssetKeyId

func GetAssetKeyId(stub cached_stub.CachedStubInterface, assetId string) (string, error)

GetAssetKeyId returns the asset key id for the given assetId. Returns an error if asset with assetId does not exist.

Example
stub := cached_stub.NewCachedStub(test_utils.CreateExampleMockStub())

// assume asset1 exists in the asset index table
GetAssetKeyId(stub, GetAssetId("data_model.Asset", "asset1"))
Output:

func GetAssetManager

GetAssetManager constructs and returns an assetManagerImpl instance.

Example
stub := cached_stub.NewCachedStub(test_utils.CreateExampleMockStub())
caller := test_utils.CreateTestUser("caller1")

GetAssetManager(stub, caller)
Output:

func GetAssetPrivateData

func GetAssetPrivateData(stub cached_stub.CachedStubInterface, assetData data_model.Asset, assetKey []byte) ([]byte, error)

GetAssetPrivateData returns an asset's private data bytes. Caller should provide proper assetKey for decryption. If decryption is successful, it returns decrypted private data bytes. If assetKey is nil, it returns encrypted private data bytes and nil for error. If assetKey is invalid, it returns encrypted private data bytes and an error.

func GetEncryptedAssetData

func GetEncryptedAssetData(stub cached_stub.CachedStubInterface, assetId string) (data_model.Asset, error)

GetEncryptedAssetData returns an asset object with encrypted PrivateData. If the AssetId passed in does not exist, it returns an empty data_model.Asset object. It is the caller's responsibility to check if the return object is empty.

func Init

func Init(stub cached_stub.CachedStubInterface, logLevel ...shim.LoggingLevel) ([]byte, error)

Init sets up the asset_mgmt package.

Types

This section is empty.

Directories

Path Synopsis
Package asset_key_func provides asset key related functions.
Package asset_key_func provides asset key related functions.
Package asset_manager is an interface for high-level asset management functions.
Package asset_manager is an interface for high-level asset management functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL