golang

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 28 Imported by: 2

README

Documentation

Overview

tape.go is utils copied from tape project

Index

Constants

This section is empty.

Variables

View Source
var (
	// CurveHalfOrders contains the precomputed curve group orders halved.
	// It is used to ensure that signature' S value is lower or equal to the
	// curve group order halved. We accept only low-S signatures.
	// They are precomputed for efficiency reasons.
	CurveHalfOrders = map[elliptic.Curve]*big.Int{
		elliptic.P224(): new(big.Int).Rsh(elliptic.P224().Params().N, 1),
		elliptic.P256(): new(big.Int).Rsh(elliptic.P256().Params().N, 1),
		elliptic.P384(): new(big.Int).Rsh(elliptic.P384().Params().N, 1),
		elliptic.P521(): new(big.Int).Rsh(elliptic.P521().Params().N, 1),
	}
)
View Source
var SeekMax = &orderer.SeekPosition{
	Type: &orderer.SeekPosition_Specified{
		Specified: &orderer.SeekSpecified{
			Number: math.MaxUint64,
		},
	},
}
View Source
var SeekNewest = &orderer.SeekPosition{
	Type: &orderer.SeekPosition_Newest{
		Newest: &orderer.SeekNewest{},
	},
}

Functions

func CommitterFrom

func CommitterFrom(connect *grpc.ClientConn) orderer.AtomicBroadcastClient

func CreateProposal

func CreateProposal(creator []byte, channel, ccname, version string, transientMap map[string][]byte, args ...string) (proposal *peer.Proposal, txid string, err error)

func DERToPrivateKey

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

DERToPrivateKey unmarshals a der to private key

func EndorserFrom

func EndorserFrom(connect *grpc.ClientConn) peer.EndorserClient

func FindKeyFilesOrPanic

func FindKeyFilesOrPanic(dirname string) []string

func GetCertificate

func GetCertificate(f string) (*x509.Certificate, []byte, error)

func GetChaincodeHeaderExtension added in v0.0.1

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

func GetPrivateKey

func GetPrivateKey(f string) (*ecdsa.PrivateKey, error)

func GetRandomNonce

func GetRandomNonce() []byte

func IsLowS

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

func PEMtoPrivateKey

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

PEMtoPrivateKey unmarshals a pem to private key

func Ping

func Ping(target string, params Params) (connect *grpc.ClientConn, err error)

func ToAddress

func ToAddress(url string) string

ToAddress is a utility function to trim the GRPC protocol prefix as it is not needed by GO if the GRPC protocol is not found, the url is returned unchanged

func ToLowS

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

Types

type Committer

func (*Committer) SendRecv

func (committer *Committer) SendRecv(envelope *common.Envelope) (*orderer.BroadcastResponse, error)

func (*Committer) Setup

func (committer *Committer) Setup() (err error)

type Crypto

type Crypto struct {
	Creator  []byte
	PrivKey  *ecdsa.PrivateKey
	SignCert *x509.Certificate
	Digest   func([]byte) []byte
}

func LoadCryptoFrom

func LoadCryptoFrom(config CryptoConfig) (*Crypto, error)

func (*Crypto) NewSignatureHeader

func (s *Crypto) NewSignatureHeader() (*common.SignatureHeader, error)

func (*Crypto) Serialize

func (s *Crypto) Serialize() ([]byte, error)

func (*Crypto) SetDefaultDigest

func (s *Crypto) SetDefaultDigest()

func (*Crypto) Sign

func (s *Crypto) Sign(msg []byte) ([]byte, error)

type CryptoConfig

type CryptoConfig struct {
	MSPID      string
	PrivKey    string
	SignCert   string
	TLSCACerts []string
}

type ECDSASignature

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

type Endorser

type Endorser struct {
	peer.EndorserClient
	context.Context
}

func (*Endorser) ProcessProposal

func (endorser *Endorser) ProcessProposal(in *peer.SignedProposal) (*peer.ProposalResponse, error)

type Eventer

type Eventer struct {
	peer.DeliverClient
	context.Context
	peer.Deliver_DeliverWithPrivateDataClient
	Continue     func(currentDeliverResponse *peer.DeliverResponse, currentError error, deliverResponses []*peer.DeliverResponse, errors []error) bool
	ErrorReducer func(errors []error) error
	ReceiptData  interface{}
}

func EventerFrom

func EventerFrom(ctx context.Context, connect *grpc.ClientConn) Eventer

func (*Eventer) AsTransactionListener

func (eventer *Eventer) AsTransactionListener(txid string) SeekInfo

AsTransactionListener return a proper SeekInfo

func (Eventer) SendRecv

func (eventer Eventer) SendRecv(seek *common.Envelope) ([]*peer.DeliverResponse, error)

func (*Eventer) SetDefaultContinue

func (e *Eventer) SetDefaultContinue()

SetDefaultContinue TODO

type Node

type Node struct {
	Addr                  string `yaml:"addr"`
	TLSCACert             string `yaml:"tls_ca_cert"`
	TLSCAKey              string `yaml:"tls_ca_key"`
	TLSCARoot             string `yaml:"tls_ca_root"`
	TLSCACertByte         []byte
	TLSCAKeyByte          []byte
	TLSCARootByte         []byte
	SslTargetNameOverride string `json:"ssl-target-name-override"`
}

func (Node) AsGRPCClient

func (node Node) AsGRPCClient() (connect *grpc.ClientConn, err error)

type SeekInfo

type SeekInfo struct {
	*orderer.SeekInfo
}

func SeekInfoFrom

func SeekInfoFrom(start, stop *orderer.SeekPosition) SeekInfo

func (SeekInfo) Fetch

func (seekInfo SeekInfo) Fetch() SeekInfo

Fetch will only get current existing blocks. Commonly used for: get genesis block, query block content

func (SeekInfo) SignBy

func (seekInfo SeekInfo) SignBy(channel string, signer protoutil.Signer) (*common.Envelope, error)

func (SeekInfo) WaitUtilReady

func (seekInfo SeekInfo) WaitUtilReady() SeekInfo

WaitUtilReady will wait for future block Commonly used for: Wait for next block, confirming tx finality

Jump to

Keyboard shortcuts

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