utils

package
v0.0.0-...-cfcde66 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 23 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// NonceSize is the default NonceSize
	NonceSize = 24
)

Variables

This section is empty.

Functions

func ComputeProposalTxID

func ComputeProposalTxID(nonce, creator []byte) (string, error)

ComputeProposalTxID computes TxID as the Hash computed over the concatenation of nonce and creator.

func ComputeProposalTxIDByGenerator

func ComputeProposalTxIDByGenerator(generator []byte) (string, error)

func ComputeSHA256

func ComputeSHA256(data []byte) (hash []byte)

ComputeSHA256 returns SHA2-256 on data

func CreateChaincodeProposal

func CreateChaincodeProposal(typ cb.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error)

CreateChaincodeProposal creates a proposal from given input. It returns the proposal and the transaction id associated to the proposal

func CreateChaincodeProposalWithTransient

func CreateChaincodeProposalWithTransient(typ cb.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTransient creates a proposal from given input It returns the proposal and the transaction id associated to the proposal

func CreateChaincodeProposalWithTxIDGeneratorAndTransient

func CreateChaincodeProposalWithTxIDGeneratorAndTransient(typ cb.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, generator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTransient creates a proposal from given input It returns the proposal and the transaction id associated to the proposal

func CreateChaincodeProposalWithTxIDNonceAndTransient

func CreateChaincodeProposalWithTxIDNonceAndTransient(txid string, typ cb.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, nonce, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error)

CreateChaincodeProposalWithTxIDNonceAndTransient creates a proposal from given input

func CreateProposalFromCIS

func CreateProposalFromCIS(typ cb.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error)

CreateProposalFromCIS returns a proposal given a serialized identity and a ChaincodeInvocationSpec

func CreateSignedTx

func CreateSignedTx(proposal *peer.Proposal, signer *ecdsa.PrivateKey, creator []byte, resps ...*peer.ProposalResponse) (*cb.Envelope, error)

CreateSignedTx assembles an Envelope message from proposal, endorsements, and a signer. This function should be called by a client when it has collected enough endorsements for a proposal to create a transaction and submit it to peers for ordering

func CreateUtcTimestamp

func CreateUtcTimestamp() *timestamp.Timestamp

CreateUtcTimestamp returns a google/protobuf/Timestamp in UTC

func DERToPrivateKey

func DERToPrivateKey(der []byte) (key interface{}, err error)

DERToPrivateKey unmarshals a der to private key

func GetBytesChaincodeActionPayload

func GetBytesChaincodeActionPayload(cap *peer.ChaincodeActionPayload) ([]byte, error)

GetBytesChaincodeActionPayload get the bytes of ChaincodeActionPayload from the message

func GetBytesChaincodeProposalPayload

func GetBytesChaincodeProposalPayload(cpp *peer.ChaincodeProposalPayload) ([]byte, error)

GetBytesChaincodeProposalPayload gets the chaincode proposal payload

func GetBytesPayload

func GetBytesPayload(payl *cb.Payload) ([]byte, error)

GetBytesPayload get the bytes of Payload from the message

func GetBytesProposal

func GetBytesProposal(prop *peer.Proposal) ([]byte, error)

GetBytesProposal returns the bytes of a proposal message

func GetBytesProposalPayloadForTx

func GetBytesProposalPayloadForTx(payload *peer.ChaincodeProposalPayload, visibility []byte) ([]byte, error)

GetBytesProposalPayloadForTx takes a ChaincodeProposalPayload and returns its serialized version according to the visibility field

func GetBytesTransaction

func GetBytesTransaction(tx *peer.Transaction) ([]byte, error)

GetBytesTransaction get the bytes of Transaction from the message

func GetChaincodeAction

func GetChaincodeAction(caBytes []byte) (*peer.ChaincodeAction, error)

GetChaincodeAction gets the ChaincodeAction given chaicnode action bytes

func GetChaincodeActionPayload

func GetChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error)

GetChaincodeActionPayload Get ChaincodeActionPayload from bytes

func GetChaincodeEvents

func GetChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error)

GetChaincodeEvents gets the ChaincodeEvents given chaincode event bytes

func GetChaincodeHeaderExtension

func GetChaincodeHeaderExtension(hdr *cb.Header) (*peer.ChaincodeHeaderExtension, error)

GetChaincodeHeaderExtension get chaincode header extension given header

func GetChaincodeProposalPayload

func GetChaincodeProposalPayload(bytes []byte) (*peer.ChaincodeProposalPayload, error)

GetChaincodeProposalPayload Get ChaincodeProposalPayload from bytes

func GetChaincodeSpecification

func GetChaincodeSpecification(chaincodeName string, chaincodeVersion string, funcName string, inputArgs ...string) (*peer.ChaincodeSpec, error)

func GetCurveHalfOrdersAt

func GetCurveHalfOrdersAt(c elliptic.Curve) *big.Int

func GetEnvelopeFromBlock

func GetEnvelopeFromBlock(data []byte) (*cb.Envelope, error)

GetEnvelopeFromBlock gets an envelope from a block's Data field.

func GetHash

func GetHash() hash.Hash

func GetHeader

func GetHeader(bytes []byte) (*cb.Header, error)

GetHeader Get Header from bytes

func GetPayload

func GetPayload(e *cb.Envelope) (*cb.Payload, error)

GetPayload Get Payload from Envelope message

func GetProposalResponsePayload

func GetProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error)

GetProposalResponsePayload gets the proposal response payload

func GetRandomBytes

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func GetRandomNonce

func GetRandomNonce() ([]byte, error)

GetRandomNonce returns a random byte array of length NonceSize

func GetSignatureHeader

func GetSignatureHeader(bytes []byte) (*cb.SignatureHeader, error)

GetSignatureHeader Get SignatureHeader from bytes

func GetSignedEvent

func GetSignedEvent(evt *peer.Event, signer *ecdsa.PrivateKey) (*peer.SignedEvent, error)

GetSignedEvent returns a signed event given an Event message and a signing identity

func GetSignedProposal

func GetSignedProposal(prop *peer.Proposal, signer *ecdsa.PrivateKey) (*peer.SignedProposal, error)

GetSignedProposal returns a signed proposal given a Proposal message and a signing identity

func GetTransaction

func GetTransaction(txBytes []byte) (*peer.Transaction, error)

GetTransaction Get Transaction from bytes

func IsLowS

func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error)

IsLow checks that s is a low-S

func MarshalECDSASignature

func MarshalECDSASignature(r, s *big.Int) ([]byte, error)

func MarshalOrPanic

func MarshalOrPanic(pb proto.Message) []byte

MarshalOrPanic serializes a protobuf message and panics if this operation fails.

func PEMtoPrivateKey

func PEMtoPrivateKey(raw []byte, pwd []byte) (interface{}, error)

PEMtoPrivateKey unmarshals a pem to private key

func ReadCertFile

func ReadCertFile(filepath string) ([]byte, error)

func ReadPrivateKey

func ReadPrivateKey(filename string, pwd []byte) (interface{}, error)

func SerializeCert

func SerializeCert(certPEM []byte) ([]byte, error)

Serialize returns a byte array representation of this identity

func Sign

func Sign(k *ecdsa.PrivateKey, message []byte) (signature []byte, err error)

func ToChaincodeArgs

func ToChaincodeArgs(args ...string) [][]byte

ToChaincodeArgs converts string args to []byte args

func ToLowS

func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, bool, error)

func UnmarshalChannelHeader

func UnmarshalChannelHeader(bytes []byte) (*cb.ChannelHeader, error)

UnmarshalChannelHeader returns a ChannelHeader from bytes

func UnmarshalECDSASignature

func UnmarshalECDSASignature(raw []byte) (*big.Int, *big.Int, error)

func UnmarshalValidateCodeFromProposalResponse

func UnmarshalValidateCodeFromProposalResponse(response *peer.ProposalResponse) (string, error)

func Verify

func Verify(k *ecdsa.PublicKey, signature, message []byte) (valid bool, err error)

Types

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

type SerializedIdentity

type SerializedIdentity struct {
	// The identifier of the associated membership service provider
	Mspid string `protobuf:"bytes,1,opt,name=mspid" json:"mspid,omitempty"`
	// the Identity, serialized according to the rules of its MPS
	IdBytes []byte `protobuf:"bytes,2,opt,name=id_bytes,json=idBytes,proto3" json:"id_bytes,omitempty"`
}

This struct represents an Identity (with its MSP identifier) to be used to serialize it and deserialize it

func (*SerializedIdentity) GetIdBytes

func (m *SerializedIdentity) GetIdBytes() []byte

func (*SerializedIdentity) GetMspid

func (m *SerializedIdentity) GetMspid() string

func (*SerializedIdentity) ProtoMessage

func (*SerializedIdentity) ProtoMessage()

func (*SerializedIdentity) Reset

func (m *SerializedIdentity) Reset()

func (*SerializedIdentity) String

func (m *SerializedIdentity) String() string

type TxValidationFlags

type TxValidationFlags []uint8

TxValidationFlags is array of transaction validation codes. It is used when committer validates block.

func NewTxValidationFlags

func NewTxValidationFlags(size int) TxValidationFlags

NewTxValidationFlags Create new object-array of validation codes with target size. Default values: valid.

func (TxValidationFlags) Flag

func (obj TxValidationFlags) Flag(txIndex int) peer.TxValidationCode

Flag returns validation code at specified transaction

func (TxValidationFlags) IsInvalid

func (obj TxValidationFlags) IsInvalid(txIndex int) bool

IsInvalid checks if specified transaction is invalid

func (TxValidationFlags) IsSetTo

func (obj TxValidationFlags) IsSetTo(txIndex int, flag peer.TxValidationCode) bool

IsSetTo returns true if the specified transaction equals flag; false otherwise.

func (TxValidationFlags) IsValid

func (obj TxValidationFlags) IsValid(txIndex int) bool

IsValid checks if specified transaction is valid

func (TxValidationFlags) SetFlag

func (obj TxValidationFlags) SetFlag(txIndex int, flag peer.TxValidationCode)

SetFlag assigns validation code to specified transaction

Jump to

Keyboard shortcuts

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