crypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2016 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLSCA_CERT_CHAIN = "tlsca.cert.chain"
)

Variables

View Source
var (
	// ECertSubjectRole is the ASN1 object identifier of the subject's role.
	ECertSubjectRole = asn1.ObjectIdentifier{2, 1, 3, 4, 5, 6, 7}
)

Functions

func CloseAllClients

func CloseAllClients() (bool, []error)

CloseAllClients closes all the clients initialized so far

func CloseAllPeers

func CloseAllPeers() (bool, []error)

CloseAllPeers closes all the peers initialized so far

func CloseAllValidators

func CloseAllValidators() (bool, []error)

CloseAllValidators closes all the validators initialized so far

func CloseClient

func CloseClient(client Client) error

CloseClient releases all the resources allocated by clients

func ClosePeer

func ClosePeer(peer Peer) error

ClosePeer releases all the resources allocated by peers

func CloseValidator

func CloseValidator(peer Peer) error

CloseValidator releases all the resources allocated by the validator

func RegisterClient

func RegisterClient(name string, pwd []byte, enrollID, enrollPWD string) error

RegisterClient registers a client to the PKI infrastructure

func RegisterPeer

func RegisterPeer(name string, pwd []byte, enrollID, enrollPWD string) error

RegisterPeer registers a peer to the PKI infrastructure

func RegisterValidator

func RegisterValidator(name string, pwd []byte, enrollID, enrollPWD string) error

RegisterValidator registers a validator to the PKI infrastructure

Types

type CertificateHandler

type CertificateHandler interface {

	// GetCertificate returns the certificate's DER
	GetCertificate() []byte

	// Sign signs msg using the signing key corresponding to the certificate
	Sign(msg []byte) ([]byte, error)

	// Verify verifies msg using the verifying key corresponding to the certificate
	Verify(signature []byte, msg []byte) error

	// GetTransactionHandler returns a new transaction handler relative to this certificate
	GetTransactionHandler() (TransactionHandler, error)
}

CertificateHandler exposes methods to deal with an ECert/TCert

type Client

type Client interface {
	Entity

	// NewChaincodeDeployTransaction is used to deploy chaincode.
	NewChaincodeDeployTransaction(chaincodeDeploymentSpec *obc.ChaincodeDeploymentSpec, uuid string) (*obc.Transaction, error)

	// NewChaincodeExecute is used to execute chaincode's functions.
	NewChaincodeExecute(chaincodeInvocation *obc.ChaincodeInvocationSpec, uuid string) (*obc.Transaction, error)

	// NewChaincodeQuery is used to query chaincode's functions.
	NewChaincodeQuery(chaincodeInvocation *obc.ChaincodeInvocationSpec, uuid string) (*obc.Transaction, error)

	// DecryptQueryResult is used to decrypt the result of a query transaction
	DecryptQueryResult(queryTx *obc.Transaction, result []byte) ([]byte, error)

	// GetEnrollmentCertHandler returns a CertificateHandler whose certificate is the enrollment certificate
	GetEnrollmentCertificateHandler() (CertificateHandler, error)

	// GetTCertHandlerNext returns a CertificateHandler whose certificate is the next available TCert
	GetTCertificateHandlerNext() (CertificateHandler, error)

	// GetTCertHandlerFromDER returns a CertificateHandler whose certificate is the one passed
	GetTCertificateHandlerFromDER(der []byte) (CertificateHandler, error)
}

Client is an entity able to deploy and invoke chaincode

func InitClient

func InitClient(name string, pwd []byte) (Client, error)

InitClient initializes a client named name with password pwd

type Entity

type Entity interface {

	// GetName returns this entity's name
	GetName() string
}

Entity represents a crypto object having a name

type Peer

type Peer interface {
	Entity

	// GetID returns this peer's identifier
	GetID() []byte

	// GetEnrollmentID returns this peer's enrollment id
	GetEnrollmentID() string

	// TransactionPreValidation verifies that the transaction is
	// well formed with the respect to the security layer
	// prescriptions (i.e. signature verification).
	TransactionPreValidation(tx *obc.Transaction) (*obc.Transaction, error)

	// TransactionPreExecution verifies that the transaction is
	// well formed with the respect to the security layer
	// prescriptions (i.e. signature verification). If this is the case,
	// the method prepares the transaction to be executed.
	// TransactionPreExecution returns a clone of tx.
	TransactionPreExecution(tx *obc.Transaction) (*obc.Transaction, error)

	// Sign signs msg with this validator's signing key and outputs
	// the signature if no error occurred.
	Sign(msg []byte) ([]byte, error)

	// Verify checks that signature if a valid signature of message under vkID's verification key.
	// If the verification succeeded, Verify returns nil meaning no error occurred.
	// If vkID is nil, then the signature is verified against this validator's verification key.
	Verify(vkID, signature, message []byte) error

	// GetStateEncryptor returns a StateEncryptor linked to pair defined by
	// the deploy transaction and the execute transaction. Notice that,
	// executeTx can also correspond to a deploy transaction.
	GetStateEncryptor(deployTx, executeTx *obc.Transaction) (StateEncryptor, error)
}

Peer is an entity able to verify transactions

func InitPeer

func InitPeer(name string, pwd []byte) (Peer, error)

InitPeer initializes a peer named name with password pwd

func InitValidator

func InitValidator(name string, pwd []byte) (Peer, error)

InitValidator initializes a validator named name with password pwd

type StateEncryptor

type StateEncryptor interface {

	// Encrypt encrypts message msg
	Encrypt(msg []byte) ([]byte, error)

	// Decrypt decrypts ciphertext ct obtained
	// from a call of the Encrypt method.
	Decrypt(ct []byte) ([]byte, error)
}

StateEncryptor is used to encrypt chaincode's state

type TransactionHandler

type TransactionHandler interface {

	// GetCertificateHandler returns the certificate handler relative to the certificate mapped to this transaction
	GetCertificateHandler() (CertificateHandler, error)

	// GetBinding returns a binding to the underlying transaction
	GetBinding() ([]byte, error)

	// NewChaincodeDeployTransaction is used to deploy chaincode
	NewChaincodeDeployTransaction(chaincodeDeploymentSpec *obc.ChaincodeDeploymentSpec, uuid string) (*obc.Transaction, error)

	// NewChaincodeExecute is used to execute chaincode's functions
	NewChaincodeExecute(chaincodeInvocation *obc.ChaincodeInvocationSpec, uuid string) (*obc.Transaction, error)

	// NewChaincodeQuery is used to query chaincode's functions
	NewChaincodeQuery(chaincodeInvocation *obc.ChaincodeInvocationSpec, uuid string) (*obc.Transaction, error)
}

TransactionHandler represents a single transaction that can be named by the output of the GetBinding method. This transaction is linked to a single Certificate (TCert or ECert).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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