Documentation
¶
Overview ¶
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Variables
- type ExRWSet
- type HashedKeyTranslator
- func (h *HashedKeyTranslator) CreateInputSNKey(id string) (Key, error)
- func (h *HashedKeyTranslator) CreateIssueActionMetadataKey(key Key) (Key, error)
- func (h *HashedKeyTranslator) CreateOutputKey(id string, index uint64) (Key, error)
- func (h *HashedKeyTranslator) CreateOutputSNKey(id string, index uint64, output []byte) (Key, error)
- func (h *HashedKeyTranslator) CreateSetupHashKey() (Key, error)
- func (h *HashedKeyTranslator) CreateSetupKey() (Key, error)
- func (h *HashedKeyTranslator) CreateTokenRequestKey(id string) (Key, error)
- func (h *HashedKeyTranslator) CreateTransferActionMetadataKey(key Key) (Key, error)
- func (h *HashedKeyTranslator) GetTransferMetadataSubKey(k string) (Key, error)
- type IssueAction
- type IssuingValidator
- type Key
- type KeyTranslator
- type KeyVersion
- type Namespace
- type RWSet
- type RWSetWrapper
- type SetupAction
- type TransferAction
- type Translator
- func (w *Translator) AddPublicParamsDependency() error
- func (w *Translator) AreTokensSpent(ids []string, graphHiding bool) ([]bool, error)
- func (w *Translator) CommitTokenRequest(raw []byte, storeHash bool) ([]byte, error)
- func (w *Translator) GetTransferMetadataSubKey(k string) (string, error)
- func (w *Translator) QueryTokens(ids []*token.ID) ([][]byte, error)
- func (w *Translator) ReadSetupParameters() ([]byte, error)
- func (w *Translator) ReadTokenRequest() ([]byte, error)
- func (w *Translator) Write(action interface{}) error
- type TxID
- type Value
Constants ¶
This section is empty.
Variables ¶
var (
NotEmpty = []byte{1}
)
Functions ¶
This section is empty.
Types ¶
type ExRWSet ¶
type ExRWSet interface {
// SetState adds a write entry to the rwset that write to given value to given key.
SetState(key Key, value Value) error
// GetState returns the value bound to the passed key
GetState(key Key) ([]byte, error)
// DeleteState adds a write entry to the rwset that deletes the passed key
DeleteState(key Key) error
// StateMustNotExist adds a read dependency that enforces that the passed key does not exist
StateMustNotExist(key Key) error
// StateMustExist adds a read dependency that enforces that the passed key does exist
// When using VersionZero, this method should be called only for keys that are guaranteed to be used only once.
StateMustExist(key Key, version KeyVersion) error
}
ExRWSet interface, used to manipulate the rwset in a more friendly way
type HashedKeyTranslator ¶
type HashedKeyTranslator struct {
KT KeyTranslator
}
func (*HashedKeyTranslator) CreateInputSNKey ¶
func (h *HashedKeyTranslator) CreateInputSNKey(id string) (Key, error)
func (*HashedKeyTranslator) CreateIssueActionMetadataKey ¶
func (h *HashedKeyTranslator) CreateIssueActionMetadataKey(key Key) (Key, error)
func (*HashedKeyTranslator) CreateOutputKey ¶
func (h *HashedKeyTranslator) CreateOutputKey(id string, index uint64) (Key, error)
func (*HashedKeyTranslator) CreateOutputSNKey ¶
func (*HashedKeyTranslator) CreateSetupHashKey ¶
func (h *HashedKeyTranslator) CreateSetupHashKey() (Key, error)
func (*HashedKeyTranslator) CreateSetupKey ¶
func (h *HashedKeyTranslator) CreateSetupKey() (Key, error)
func (*HashedKeyTranslator) CreateTokenRequestKey ¶
func (h *HashedKeyTranslator) CreateTokenRequestKey(id string) (Key, error)
func (*HashedKeyTranslator) CreateTransferActionMetadataKey ¶
func (h *HashedKeyTranslator) CreateTransferActionMetadataKey(key Key) (Key, error)
func (*HashedKeyTranslator) GetTransferMetadataSubKey ¶
func (h *HashedKeyTranslator) GetTransferMetadataSubKey(k string) (Key, error)
type IssueAction ¶
type IssuingValidator ¶
type IssuingValidator interface {
// Validate returns no error if the passed creator can issue tokens of the passed type,, an error otherwise.
Validate(creator view.Identity, tokenType string) error
}
IssuingValidator is used to establish if the creator can issue tokens of the passed type.
type KeyTranslator ¶
type KeyTranslator interface {
// CreateTokenRequestKey creates the key for a token request with the passed id
CreateTokenRequestKey(id string) (Key, error)
// CreateSetupKey creates the key for public parameters
CreateSetupKey() (Key, error)
// CreateSetupHashKey creates the key for the hashed public parameters
CreateSetupHashKey() (Key, error)
// CreateOutputKey creates the key for an output
CreateOutputKey(id string, index uint64) (Key, error)
// CreateOutputSNKey creates the key for the serial number of an output
CreateOutputSNKey(id string, index uint64, output []byte) (Key, error)
// CreateInputSNKey creates the key for the serial number of an input
CreateInputSNKey(id string) (Key, error)
// CreateIssueActionMetadataKey returns the issue action metadata key built from the passed key
CreateIssueActionMetadataKey(key string) (Key, error)
// CreateTransferActionMetadataKey returns the transfer action metadata key built from the passed subkey
CreateTransferActionMetadataKey(subkey string) (Key, error)
// GetTransferMetadataSubKey returns the subkey in the given transfer action metadata key
GetTransferMetadataSubKey(k string) (Key, error)
}
KeyTranslator is used to translate tokens' concepts into backend's keys.
type KeyVersion ¶
type KeyVersion = int
KeyVersion models the concept of a specific key version as `version zero` or `any`.
const ( // Latest value, latest version of the key known to the node Latest KeyVersion = iota // VersionZero value, version `zero` of the key VersionZero )
type RWSet ¶
type RWSet interface {
SetState(namespace string, key string, value []byte) error
GetState(namespace string, key string) ([]byte, error)
DeleteState(namespace string, key string) error
}
RWSet interface, used to read from, and write to, a rwset.
type RWSetWrapper ¶
func NewRWSetWrapper ¶
func NewRWSetWrapper(RWSet RWSet, namespace Namespace, txID TxID) *RWSetWrapper
func (*RWSetWrapper) DeleteState ¶
func (w *RWSetWrapper) DeleteState(key Key) error
func (*RWSetWrapper) StateMustExist ¶
func (w *RWSetWrapper) StateMustExist(key Key, version KeyVersion) error
func (*RWSetWrapper) StateMustNotExist ¶
func (w *RWSetWrapper) StateMustNotExist(key Key) error
type SetupAction ¶
type TransferAction ¶
type TransferAction interface {
// Serialize returns the serialized version of the action
Serialize() ([]byte, error)
// NumOutputs returns the number of outputs of the action
NumOutputs() int
// GetSerializedOutputs returns the serialized outputs of the action
GetSerializedOutputs() ([][]byte, error)
// IsRedeemAt returns true if the output is a redeem output at the passed index
IsRedeemAt(index int) bool
// SerializeOutputAt returns the serialized output at the passed index
SerializeOutputAt(index int) ([]byte, error)
// GetInputs returns the identifiers of the inputs in the action.
GetInputs() []*token.ID
// GetSerializedInputs returns the serialized inputs of the action
GetSerializedInputs() ([][]byte, error)
// GetSerialNumbers returns the serial numbers of the inputs if this action supports graph hiding
GetSerialNumbers() []string
// IsGraphHiding returns true if the action is graph hiding
IsGraphHiding() bool
// GetMetadata returns the action's metadata
GetMetadata() map[string][]byte
}
TransferAction is the action used to transfer tokens
type Translator ¶
type Translator struct {
RWSet ExRWSet
KeyTranslator KeyTranslator
TxID string
// SpentIDs the spent IDs added so far
SpentIDs []string
// contains filtered or unexported fields
}
Translator validates token requests and generates the corresponding RWSets
func New ¶
func New(txID string, rws ExRWSet, keyTranslator KeyTranslator) *Translator
func (*Translator) AddPublicParamsDependency ¶
func (w *Translator) AddPublicParamsDependency() error
func (*Translator) AreTokensSpent ¶
func (w *Translator) AreTokensSpent(ids []string, graphHiding bool) ([]bool, error)
func (*Translator) CommitTokenRequest ¶
func (w *Translator) CommitTokenRequest(raw []byte, storeHash bool) ([]byte, error)
func (*Translator) GetTransferMetadataSubKey ¶
func (w *Translator) GetTransferMetadataSubKey(k string) (string, error)
func (*Translator) QueryTokens ¶
func (w *Translator) QueryTokens(ids []*token.ID) ([][]byte, error)
func (*Translator) ReadSetupParameters ¶
func (w *Translator) ReadSetupParameters() ([]byte, error)
func (*Translator) ReadTokenRequest ¶
func (w *Translator) ReadTokenRequest() ([]byte, error)
func (*Translator) Write ¶
func (w *Translator) Write(action interface{}) error
Write checks that transactions are correct wrt. the most recent rwset state. Write checks are ones that shall be done sequentially, since transactions within a block may introduce dependencies.