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 ¶
- func GetAssetId(assetNamespace string, id string) string
- func GetAssetKey(stub cached_stub.CachedStubInterface, assetId string, keyPath []string, ...) ([]byte, error)
- func GetAssetKeyId(stub cached_stub.CachedStubInterface, assetId string) (string, error)
- func GetAssetManager(stub cached_stub.CachedStubInterface, caller data_model.User) asset_manager.AssetManager
- func GetAssetPrivateData(stub cached_stub.CachedStubInterface, assetData data_model.Asset, ...) ([]byte, error)
- func GetEncryptedAssetData(stub cached_stub.CachedStubInterface, assetId string) (data_model.Asset, error)
- func Init(stub cached_stub.CachedStubInterface, logLevel ...shim.LoggingLevel) ([]byte, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAssetId ¶
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 ¶
func GetAssetManager(stub cached_stub.CachedStubInterface, caller data_model.User) asset_manager.AssetManager
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. |