encryption

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: MIT Imports: 11 Imported by: 0

README

Hyperledger Fabric chaincode kit (CCKit)

Encryption extension

Allows to encrypt all data in ledger

Based on example

Using ECDH for establishing secret key

ECDH (Elliptic curve Diffie-Hellman): both parties can establish a secret value by sending only the public key of their ephemeral or static key pair to the other party. If the key pair of one of the parties is trusted by the other party then that key pair may also be used for authentication.

Documentation

Index

Constants

View Source
const TransientMapKey = `ENCODE_KEY`

Variables

View Source
var (
	// ErrKeyNotDefinedInTransientMap occurs when key not defined in transient map
	ErrKeyNotDefinedInTransientMap = errors.New(`key 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 ArgsDecryptIfKeyProvided

func ArgsDecryptIfKeyProvided(next router.ContextHandlerFunc, pos ...int) router.ContextHandlerFunc

ArgsDecryptIfKeyProvided - pre middleware, decrypts chaincode method arguments if key provided in transient map

func Decrypt

func Decrypt(key, value []byte) ([]byte, error)

Decrypt decrypts value with key

func DecryptArgs

func DecryptArgs(key []byte, args [][]byte) ([][]byte, error)

DecryptArgs decrypt args

func DecryptBytesWith

func DecryptBytesWith(key []byte) state.FromBytesTransformer

DecryptBytesWith decrypts by with key - used for decrypting data after reading from state

func Encrypt

func Encrypt(key []byte, value interface{}) ([]byte, error)

Encrypt converts value to []byte and encrypts its with key

func EncryptArgs

func EncryptArgs(key []byte, args ...interface{}) ([][]byte, error)

EncryptArgs encrypt args

func EncryptBytesWith

func EncryptBytesWith(key []byte) state.ToBytesTransformer

EncryptBytesWith encrypts bytes with key - used for encrypting data for state

func KeyFromTransient

func KeyFromTransient(c router.Context) ([]byte, error)

KeyFromTransient gets key for encrypting/decrypting from transient map

func KeyPartsEncryptedWith

func KeyPartsEncryptedWith(encryptKey []byte) state.KeyPartsTransformer

KeyPartsEncryptedWith encrypts key parts

func NewEncryptOnDemandPaymentCC added in v0.3.1

func NewEncryptOnDemandPaymentCC() *router.Chaincode

Chaincode with encrypting data on demand (if encrypting key is provided in transient map)

func NewEncryptPaymentCC added in v0.3.1

func NewEncryptPaymentCC() *router.Chaincode

Chaincode with required encrypting (encrypting key must be provided in transient map)

func State

func State(c router.Context, key []byte) (state.State, error)

State encrypting the data before putting to state and decrypting the data after getting from state

func StateWithTransientKey

func StateWithTransientKey(c router.Context) (state.State, error)

StateWithTransientKey creates encrypted state state with provided key for symmetric encryption/decryption

func StateWithTransientKeyIfProvided added in v0.3.1

func StateWithTransientKeyIfProvided(c router.Context) (state.State, error)

StateWithTransientKeyIfProvided creates encrypted state wrapper with provided key for symmetric encryption/decryption if key provided, otherwise - standard state wrapper without encryption

func TransientMapWithKey

func TransientMapWithKey(key []byte) map[string][]byte

TransientMapWithKey creates transient map with encrypting/decrypting key

Types

type Payment added in v0.3.1

type Payment struct {
	Type   string
	Id     string
	Amount int
}

func (Payment) Key added in v0.3.1

func (p Payment) Key() ([]string, error)

Jump to

Keyboard shortcuts

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