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 DecryptEvent(encKey []byte, event *peer.ChaincodeEvent) (decrypted *peer.ChaincodeEvent, err 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 EncryptArgsBytes(key []byte, argsBytes [][]byte) ([][]byte, error)
- func EncryptEvent(encKey []byte, event *peer.ChaincodeEvent) (encrypted *peer.ChaincodeEvent, err error)
- func EncryptInvokeResponse() router.MiddlewareFunc
- 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 EventWithTransientKeyIfProvided(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 MustDecryptEvent(encKey []byte, event *peer.ChaincodeEvent) (decrypted *peer.ChaincodeEvent)
- 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 ¶
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 ¶
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 DecryptEvent ¶
func DecryptEvent(encKey []byte, event *peer.ChaincodeEvent) (decrypted *peer.ChaincodeEvent, err error)
DecryptEvent
func EncStateContext ¶
func EncStateContext(next router.HandlerFunc, pos ...int) router.HandlerFunc
EncStateContext replaces default state with encrypted state
func EncStateContextIfKeyProvided ¶
func EncStateContextIfKeyProvided(next router.HandlerFunc, pos ...int) router.HandlerFunc
EncStateContext replaces default state with encrypted state
func EncryptArgs ¶
EncryptArgs convert args to [][]byte and encrypt args with key
func EncryptArgsBytes ¶
EncryptArgsBytes encrypt args with key
func EncryptEvent ¶
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 EncryptInvokeResponse ¶
func EncryptInvokeResponse() router.MiddlewareFunc
func EncryptWithTransientKey ¶
EncryptWithTransientKey encrypts val with key from transient map
func EventWithTransientKey ¶
EventWithTransientKey creates encrypted event wrapper with provided key for symmetric encryption/decryption
func EventWithTransientKeyIfProvided ¶
EventWithTransientKeyIfProvided returns encrypted event wrapper if key for symmetric encryption/decryption is provided, otherwise return default event wrapper
func FromBytesDecryptor ¶
func FromBytesDecryptor(key []byte) state.FromBytesTransformer
DecryptTransformer returns state.FromBytesTransformer - used for decrypting data after reading from state
func InvokeChaincode ¶
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 ¶
func KeyPartsEncryptor(encryptKey []byte) state.KeyTransformer
KeyPartsEncryptedWith encrypts key parts
func MockInvoke ¶
MockInvoke helper for invoking MockStub with transient key and encrypted args
func MustDecryptEvent ¶
func MustDecryptEvent(encKey []byte, event *peer.ChaincodeEvent) (decrypted *peer.ChaincodeEvent)
MustDecryptEvent helper for DecryptEvent. Panics in case of error.
func MustEncryptEvent ¶
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 ¶
StateWithTransientKeyIfProvided creates encrypted state wrapper with provided key for symmetric encryption/decryption if key provided, otherwise - standard state wrapper without encryption
func StringEncryptor ¶
func StringEncryptor(key []byte) state.StringTransformer
EncryptStringWith returns state.StringTransformer encrypting string with provided key
func ToBytesEncryptor ¶
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 ¶
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 ¶
NewMockStub creates wrapper for querying and invoking encrypted chaincode