Documentation ¶
Index ¶
- Constants
- Variables
- func ArgsDecrypt(next router.ContextHandlerFunc, pos ...int) router.ContextHandlerFunc
- func ArgsDecryptExcept(exceptMethod ...string) router.ContextMiddlewareFunc
- func ArgsDecryptIfKeyProvided(next router.ContextHandlerFunc, pos ...int) router.ContextHandlerFunc
- func Decrypt(key, value []byte) ([]byte, error)
- func DecryptArgs(key []byte, args [][]byte) ([][]byte, error)
- func EncStateContext(next router.HandlerFunc, pos ...int) router.HandlerFunc
- func EncStateContextIfKeyProvided(next router.HandlerFunc, pos ...int) router.HandlerFunc
- func Encrypt(key []byte, value interface{}) ([]byte, error)
- func EncryptArgs(key []byte, args ...interface{}) ([][]byte, error)
- func EncryptEvent(encKey []byte, event *peer.ChaincodeEvent) (encrypted *peer.ChaincodeEvent, err error)
- func EncryptWithTransientKey(c router.Context, val interface{}) (encrypted []byte, err error)
- func Event(c router.Context, key []byte) (state.Event, error)
- func EventWithTransientKey(c router.Context) (state.Event, error)
- func FromBytesDecryptor(key []byte) state.FromBytesTransformer
- func InvokeChaincode(stub shim.ChaincodeStubInterface, encKey []byte, chaincodeName string, ...) (interface{}, error)
- func KeyFromTransient(c router.Context) ([]byte, error)
- func KeyPartsEncryptor(encryptKey []byte) state.KeyTransformer
- func MockInvoke(cc *testing.MockStub, encKey []byte, args ...interface{}) peer.Response
- func MockQuery(cc *testing.MockStub, encKey []byte, args ...interface{}) peer.Response
- func MustEncryptEvent(encKey []byte, event *peer.ChaincodeEvent) (encrypted *peer.ChaincodeEvent)
- func State(c router.Context, key []byte) (state.State, error)
- func StateWithTransientKey(c router.Context) (state.State, error)
- func StateWithTransientKeyIfProvided(c router.Context) (state.State, error)
- func StringEncryptor(key []byte) state.StringTransformer
- func ToBytesEncryptor(key []byte) state.ToBytesTransformer
- func TransientMapWithKey(key []byte) map[string][]byte
- type MockStub
Constants ¶
const TransientMapKey = `ENCODE_KEY`
Variables ¶
var ( // ErrKeyNotDefinedInTransientMap occurs when key not defined in transient map ErrKeyNotDefinedInTransientMap = errors.New(`encryption key is not defined in transient map`) )
Functions ¶
func ArgsDecrypt ¶ added in v0.3.1
func ArgsDecrypt(next router.ContextHandlerFunc, pos ...int) router.ContextHandlerFunc
ArgsDecryptIfKeyProvided - pre middleware, decrypts chaincode method arguments, key must be provided in transient map
func ArgsDecryptExcept ¶ added in v0.4.3
func ArgsDecryptExcept(exceptMethod ...string) router.ContextMiddlewareFunc
func ArgsDecryptIfKeyProvided ¶
func ArgsDecryptIfKeyProvided(next router.ContextHandlerFunc, pos ...int) router.ContextHandlerFunc
ArgsDecryptIfKeyProvided - pre middleware, decrypts chaincode method arguments if key provided in transient map
func DecryptArgs ¶
DecryptArgs decrypt args
func EncStateContext ¶ added in v0.4.1
func EncStateContext(next router.HandlerFunc, pos ...int) router.HandlerFunc
EncStateContext replaces default state with encrypted state
func EncStateContextIfKeyProvided ¶ added in v0.4.3
func EncStateContextIfKeyProvided(next router.HandlerFunc, pos ...int) router.HandlerFunc
EncStateContext replaces default state with encrypted state
func EncryptArgs ¶
EncryptArgs encrypt args
func EncryptEvent ¶ added in v0.4.1
func EncryptEvent(encKey []byte, event *peer.ChaincodeEvent) (encrypted *peer.ChaincodeEvent, err error)
EncryptEvent encrypts event payload and event name. Event name also base64 encoded. ChaincodeId and TxId remains unencrypted
func EncryptWithTransientKey ¶ added in v0.4.1
EncryptWithTransientKey encrypts val with key from transient map
func EventWithTransientKey ¶ added in v0.4.1
EventWithTransientKey creates encrypted event wrapper with provided key for symmetric encryption/decryption
func FromBytesDecryptor ¶ added in v0.4.1
func FromBytesDecryptor(key []byte) state.FromBytesTransformer
DecryptTransformer returns state.FromBytesTransformer - used for decrypting data after reading from state
func InvokeChaincode ¶ added in v0.4.3
func InvokeChaincode( stub shim.ChaincodeStubInterface, encKey []byte, chaincodeName string, args []interface{}, channel string, target interface{}) (interface{}, error)
InvokeChaincode decrypts received payload
func KeyFromTransient ¶
KeyFromTransient gets key for encrypting/decrypting from transient map
func KeyPartsEncryptor ¶ added in v0.4.1
func KeyPartsEncryptor(encryptKey []byte) state.KeyTransformer
KeyPartsEncryptedWith encrypts key parts
func MockInvoke ¶ added in v0.4.1
MockInvoke helper for invoking MockStub with transient key and encrypted args
func MockQuery ¶ added in v0.4.1
MockQuery helper for querying MockStub with transient key and encrypted args
func MustEncryptEvent ¶ added in v0.4.1
func MustEncryptEvent(encKey []byte, event *peer.ChaincodeEvent) (encrypted *peer.ChaincodeEvent)
MustEncryptEvent helper for EncryptEvent. Panics in case of error.
func State ¶
State wrapper, encrypts the data before putting to state and decrypts the data after getting from state
func StateWithTransientKey ¶
StateWithTransientKey creates encrypted state state with provided key for symmetric encryption/decryption
func StateWithTransientKeyIfProvided ¶ added in v0.3.1
StateWithTransientKeyIfProvided creates encrypted state wrapper with provided key for symmetric encryption/decryption if key provided, otherwise - standard state wrapper without encryption
func StringEncryptor ¶ added in v0.4.1
func StringEncryptor(key []byte) state.StringTransformer
EncryptStringWith returns state.StringTransformer encrypting string with provided key
func ToBytesEncryptor ¶ added in v0.4.1
func ToBytesEncryptor(key []byte) state.ToBytesTransformer
EncryptTransformer returns state.ToBytesTransformer - used for encrypting data for state
func TransientMapWithKey ¶
TransientMapWithKey creates transient map with encrypting/decrypting key
Types ¶
type MockStub ¶ added in v0.4.1
type MockStub struct { MockStub *testing.MockStub //EncKey key for encrypt data before query/invoke EncKey []byte // DecryptInvokeResponse decrypts invoker responses DecryptInvokeResponse bool }
MockStub wrapper for querying and invoking encrypted chaincode
func NewMockStub ¶ added in v0.4.1
NewMockStub creates wrapper for querying and invoking encrypted chaincode