Documentation ¶
Overview ¶
Package bcpb is a generated protocol buffer package.
It is generated from these files:
types.proto
It has these top-level messages:
BlockHeader Block TxHeader TxInput TxOutput Tx
Index ¶
- Variables
- func ValidatePublicKeyAddress(address []byte, h hash.Hash) bool
- type Block
- func (blk *Block) AddSigner(pubkey PublicKey)
- func (blk *Block) Clone() *Block
- func (*Block) Descriptor() ([]byte, []int)
- func (m *Block) GetDigest() Digest
- func (m *Block) GetHeader() *BlockHeader
- func (m *Block) GetSignatures() [][]byte
- func (m *Block) GetTxs() []Digest
- func (blk *Block) HasSignatures() bool
- func (blk *Block) Height() uint32
- func (m *Block) Marshal() (dAtA []byte, err error)
- func (m *Block) MarshalTo(dAtA []byte) (int, error)
- func (blk *Block) ProposerSigned() bool
- func (*Block) ProtoMessage()
- func (m *Block) Reset()
- func (blk *Block) SetHash(h hasher.Hasher)
- func (blk *Block) SetProposer(pubkey PublicKey)
- func (blk *Block) SetSigners(signers ...PublicKey)
- func (blk *Block) SetTxs(txns []*Tx, hf hasher.Hasher)
- func (blk *Block) Sign(pubkey PublicKey, signature []byte) error
- func (blk *Block) SignatureCount() int32
- func (m *Block) Size() (n int)
- func (m *Block) String() string
- func (m *Block) Unmarshal(dAtA []byte) error
- type BlockHeader
- func (*BlockHeader) Descriptor() ([]byte, []int)
- func (m *BlockHeader) GetHeight() uint32
- func (m *BlockHeader) GetN() int32
- func (m *BlockHeader) GetNonce() uint64
- func (m *BlockHeader) GetPrevBlock() Digest
- func (m *BlockHeader) GetProposerIndex() int32
- func (m *BlockHeader) GetQ() int32
- func (m *BlockHeader) GetRoot() Digest
- func (m *BlockHeader) GetS() int32
- func (m *BlockHeader) GetSigners() []PublicKey
- func (m *BlockHeader) GetTimestamp() int64
- func (header *BlockHeader) HasSigners() bool
- func (header *BlockHeader) Hash(h hasher.Hasher) Digest
- func (m *BlockHeader) Marshal() (dAtA []byte, err error)
- func (m *BlockHeader) MarshalTo(dAtA []byte) (int, error)
- func (header *BlockHeader) Proposer() PublicKey
- func (*BlockHeader) ProtoMessage()
- func (m *BlockHeader) Reset()
- func (header *BlockHeader) SignerIndex(pubkey PublicKey) int
- func (m *BlockHeader) Size() (n int)
- func (m *BlockHeader) String() string
- func (m *BlockHeader) Unmarshal(dAtA []byte) error
- type DataKey
- type Digest
- type Digests
- type PublicKey
- type Tx
- func (tx *Tx) AddInput(in *TxInput)
- func (tx *Tx) AddOutput(out *TxOutput)
- func (tx *Tx) DataHash(h hasher.Hasher) Digest
- func (*Tx) Descriptor() ([]byte, []int)
- func (m *Tx) GetDigest() Digest
- func (m *Tx) GetHeader() *TxHeader
- func (m *Tx) GetInputs() []*TxInput
- func (m *Tx) GetOutputs() []*TxOutput
- func (tx *Tx) IsBase() bool
- func (m *Tx) Marshal() (dAtA []byte, err error)
- func (m *Tx) MarshalTo(dAtA []byte) (int, error)
- func (*Tx) ProtoMessage()
- func (m *Tx) Reset()
- func (tx *Tx) SetDigest(h hasher.Hasher)
- func (m *Tx) Size() (n int)
- func (m *Tx) String() string
- func (m *Tx) Unmarshal(dAtA []byte) error
- type TxHeader
- func (*TxHeader) Descriptor() ([]byte, []int)
- func (m *TxHeader) GetData() Digest
- func (m *TxHeader) GetDataSize() int64
- func (m *TxHeader) GetTimestamp() int64
- func (header *TxHeader) Hash(h hasher.Hasher) Digest
- func (m *TxHeader) Marshal() (dAtA []byte, err error)
- func (m *TxHeader) MarshalTo(dAtA []byte) (int, error)
- func (*TxHeader) ProtoMessage()
- func (m *TxHeader) Reset()
- func (m *TxHeader) Size() (n int)
- func (m *TxHeader) String() string
- func (m *TxHeader) Unmarshal(dAtA []byte) error
- type TxInput
- func (txi *TxInput) AddArgs(args ...[]byte)
- func (txi *TxInput) AddPubKey(pk PublicKey) bool
- func (txi *TxInput) Args() [][]byte
- func (*TxInput) Descriptor() ([]byte, []int)
- func (m *TxInput) GetIndex() int32
- func (m *TxInput) GetPubKeys() []PublicKey
- func (m *TxInput) GetRef() Digest
- func (m *TxInput) GetSignatures() [][]byte
- func (txi *TxInput) HasPubKey(pubkey []byte) (int, bool)
- func (txi *TxInput) Hash(hf hasher.Hasher) Digest
- func (txi *TxInput) IsBase() bool
- func (m *TxInput) Marshal() (dAtA []byte, err error)
- func (m *TxInput) MarshalTo(dAtA []byte) (int, error)
- func (*TxInput) ProtoMessage()
- func (m *TxInput) Reset()
- func (txi *TxInput) Sign(pk PublicKey, sig []byte) error
- func (m *TxInput) Size() (n int)
- func (m *TxInput) String() string
- func (m *TxInput) Unmarshal(dAtA []byte) error
- type TxOutput
- func (txo *TxOutput) Copy() *TxOutput
- func (*TxOutput) Descriptor() ([]byte, []int)
- func (m *TxOutput) GetData() []byte
- func (m *TxOutput) GetDataKey() DataKey
- func (m *TxOutput) GetLabels() []string
- func (m *TxOutput) GetLogic() []byte
- func (m *TxOutput) GetMetrics() map[string]float64
- func (m *TxOutput) GetPubKeys() []PublicKey
- func (m *TxOutput) GetTags() map[string]string
- func (txo *TxOutput) HasPublicKey(pk PublicKey) bool
- func (m *TxOutput) Marshal() (dAtA []byte, err error)
- func (m *TxOutput) MarshalTo(dAtA []byte) (int, error)
- func (*TxOutput) ProtoMessage()
- func (txo *TxOutput) RemovePublicKey(pk PublicKey) bool
- func (m *TxOutput) Reset()
- func (txo *TxOutput) SetRequiredSignatures(c uint8)
- func (m *TxOutput) Size() (n int)
- func (m *TxOutput) String() string
- func (m *TxOutput) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSignatureVerificationFailed is returned when a signature cannot be // verified ErrSignatureVerificationFailed = errors.New("signature verification failed") // ErrNotAuthorized is returned when the given public is not allowed to // access the output ErrNotAuthorized = errors.New("not authorized") // ErrSignerNotInBlock is returned when a signer signs a block but is not // a participant block signer ErrSignerNotInBlock = errors.New("signer not in block") // ErrSignerAlreadySigned is returned when a signer tries to sign when they // already have ErrSignerAlreadySigned = errors.New("signer already signed") )
var ( ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") )
Functions ¶
Types ¶
type Block ¶
type Block struct { // Block header. All signature data should be part of the ledger Header *BlockHeader `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"` // List of tx ids part of this block Txs []Digest `protobuf:"bytes,2,rep,name=Txs,casttype=Digest" json:"Txs,omitempty"` // Signatures associated to each pubkey Signatures [][]byte `protobuf:"bytes,3,rep,name=Signatures" json:"Signatures,omitempty"` // Digest of the block Digest Digest `protobuf:"bytes,4,opt,name=Digest,proto3,casttype=Digest" json:"Digest,omitempty"` }
Block is a ledger block
func (*Block) Descriptor ¶
func (*Block) GetHeader ¶
func (m *Block) GetHeader() *BlockHeader
func (*Block) GetSignatures ¶
func (*Block) HasSignatures ¶
HasSignatures returns true if the block has the required number of signatures as specified by the S value in the header
func (*Block) ProposerSigned ¶
ProposerSigned returns true if the proposer has signed the block
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) SetProposer ¶
SetProposer sets the proposer index given the public key. If the public is not in the signers it is added and then the index is set
func (*Block) SetSigners ¶
SetSigners sets the signers resetting all signatures
func (*Block) Sign ¶
Sign adds the public key and signature to the block. They are added at the same index. If the public key is already in Signers then the signature is set to the corresponding index in the Signatures field
func (*Block) SignatureCount ¶
SignatureCount returns the number of signatures in the block. This is different from the S value which represents the 'required' signatures
type BlockHeader ¶
type BlockHeader struct { // Block height in the chain. Genesis will always be 0 Height uint32 `protobuf:"varint,1,opt,name=Height,proto3" json:"Height,omitempty"` // Previous block digest. This is zero for the genesis block PrevBlock Digest `protobuf:"bytes,2,opt,name=PrevBlock,proto3,casttype=Digest" json:"PrevBlock,omitempty"` // Timestamp when block creation was started Timestamp int64 `protobuf:"varint,3,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"` // Incrementing nonce Nonce uint64 `protobuf:"varint,4,opt,name=Nonce,proto3" json:"Nonce,omitempty"` // Root hash of all tx's Root Digest `protobuf:"bytes,5,opt,name=Root,proto3,casttype=Digest" json:"Root,omitempty"` // All block signers Signers []PublicKey `protobuf:"bytes,6,rep,name=Signers,casttype=PublicKey" json:"Signers,omitempty"` // Node that proposed the block ProposerIndex int32 `protobuf:"varint,7,opt,name=ProposerIndex,proto3" json:"ProposerIndex,omitempty"` // Total number of signers for this block N int32 `protobuf:"varint,8,opt,name=N,proto3" json:"N,omitempty"` // Number of signatures. This must be a atleast quorum value of N S int32 `protobuf:"varint,9,opt,name=S,proto3" json:"S,omitempty"` // Number of commits. This must be a atleast quorum value of N Q int32 `protobuf:"varint,10,opt,name=Q,proto3" json:"Q,omitempty"` }
func (*BlockHeader) Descriptor ¶
func (*BlockHeader) Descriptor() ([]byte, []int)
func (*BlockHeader) GetHeight ¶
func (m *BlockHeader) GetHeight() uint32
func (*BlockHeader) GetN ¶
func (m *BlockHeader) GetN() int32
func (*BlockHeader) GetNonce ¶
func (m *BlockHeader) GetNonce() uint64
func (*BlockHeader) GetPrevBlock ¶
func (m *BlockHeader) GetPrevBlock() Digest
func (*BlockHeader) GetProposerIndex ¶
func (m *BlockHeader) GetProposerIndex() int32
func (*BlockHeader) GetQ ¶
func (m *BlockHeader) GetQ() int32
func (*BlockHeader) GetRoot ¶
func (m *BlockHeader) GetRoot() Digest
func (*BlockHeader) GetS ¶
func (m *BlockHeader) GetS() int32
func (*BlockHeader) GetSigners ¶
func (m *BlockHeader) GetSigners() []PublicKey
func (*BlockHeader) GetTimestamp ¶
func (m *BlockHeader) GetTimestamp() int64
func (*BlockHeader) HasSigners ¶
func (header *BlockHeader) HasSigners() bool
HasSigners returns true if the block has the number of signers as specified by N
func (*BlockHeader) Hash ¶
func (header *BlockHeader) Hash(h hasher.Hasher) Digest
Hash returns the hash of the header
func (*BlockHeader) Marshal ¶
func (m *BlockHeader) Marshal() (dAtA []byte, err error)
func (*BlockHeader) Proposer ¶
func (header *BlockHeader) Proposer() PublicKey
Proposer returns the public key of the block proposer
func (*BlockHeader) ProtoMessage ¶
func (*BlockHeader) ProtoMessage()
func (*BlockHeader) Reset ¶
func (m *BlockHeader) Reset()
func (*BlockHeader) SignerIndex ¶
func (header *BlockHeader) SignerIndex(pubkey PublicKey) int
SignerIndex returns the index in the signers list given the public key
func (*BlockHeader) Size ¶
func (m *BlockHeader) Size() (n int)
func (*BlockHeader) String ¶
func (m *BlockHeader) String() string
func (*BlockHeader) Unmarshal ¶
func (m *BlockHeader) Unmarshal(dAtA []byte) error
type DataKey ¶
type DataKey []byte
DataKey represents a data key. This is a token key as opposed to a crypto key It is in the format <type>:<some uinque key in type>, where type is the datatype with the remainder to be used as an identifier
func NewDataKey ¶
NewDataKey returns a new data key with the given type and id delimited by ':'
type Digest ¶
type Digest []byte
Digest is a hash with the hash function used. The format is as follows algo ':' hash
func NewZeroDigest ¶
NewZeroDigest returns a zero digest for the given hash function
func ParseDigest ¶
ParseDigest parses a digest string into a digest
type PublicKey ¶
type PublicKey []byte
PublicKey contains public key bytes
type Tx ¶
type Tx struct { // Tx header including the transaction type Header *TxHeader `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"` Inputs []*TxInput `protobuf:"bytes,2,rep,name=Inputs" json:"Inputs,omitempty"` Outputs []*TxOutput `protobuf:"bytes,3,rep,name=Outputs" json:"Outputs,omitempty"` // Transaction digest Digest Digest `protobuf:"bytes,4,opt,name=Digest,proto3,casttype=Digest" json:"Digest,omitempty"` }
func NewBaseTx ¶
NewBaseTx returns a new base transaction. This is used when new entities are being created
func (*Tx) DataHash ¶
DataHash hashes all inputs and outputs updating the DataSize in the header and returning the data digest
func (*Tx) Descriptor ¶
func (*Tx) GetOutputs ¶
func (*Tx) IsBase ¶
IsBase returns true if this is a base tx i.e. inputs do not reference any outputs
func (*Tx) ProtoMessage ¶
func (*Tx) ProtoMessage()
type TxHeader ¶
type TxHeader struct { // Tx timestamp Timestamp int64 `protobuf:"varint,1,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"` // Payload hash Data Digest `protobuf:"bytes,2,opt,name=Data,proto3,casttype=Digest" json:"Data,omitempty"` // Payload size DataSize int64 `protobuf:"varint,3,opt,name=DataSize,proto3" json:"DataSize,omitempty"` }
func (*TxHeader) Descriptor ¶
func (*TxHeader) GetDataSize ¶
func (*TxHeader) GetTimestamp ¶
func (*TxHeader) ProtoMessage ¶
func (*TxHeader) ProtoMessage()
type TxInput ¶
type TxInput struct { // Previous tx. Empty if no ref is specificed along with the index // then it is considered a base tx Ref Digest `protobuf:"bytes,1,opt,name=Ref,proto3,casttype=Digest" json:"Ref,omitempty"` // Output index in txn. -1 if no previous output needed as input Index int32 `protobuf:"varint,2,opt,name=Index,proto3" json:"Index,omitempty"` // Public key as set in the output tx being referenced and used to verify // the signature below. These are strictly used to assist in the // verification of signatures and are not necessarily required to be // specified as in the input PubKeys []PublicKey `protobuf:"bytes,3,rep,name=PubKeys,casttype=PublicKey" json:"PubKeys,omitempty"` // Data needed to unlock TxnOutput OR i.e. // signature along with any other data. This is used in conjunction with // the TxnOutput referenced by the above fields to unlock the referenced // TxnOutput. All data after the pub keys length is consider part of the // state transition and unlock logic Signatures [][]byte `protobuf:"bytes,4,rep,name=Signatures" json:"Signatures,omitempty"` }
TxnInput contains all data needed to use the referenced output
func NewBaseTxInput ¶
NewBaseTxInput creates a new base TxnInput with arbitrary data as the signature. This is used in for example the genesis block
func NewTxInput ¶
NewTxInput creates a new transaction input. It inits the signatures to the the number of given public keys
func (*TxInput) AddArgs ¶
AddArgs adds inputs args to the txinput. Args are always after all signatures
func (*TxInput) AddPubKey ¶
AddPubKey adds a public key to the input if it does not exist. It also adjusts the signatures slices accordingly if the addition is successful
func (*TxInput) Args ¶
Args returns all arguments minus the signatures needed as input. Inputs are located after the given number of public keys in the signatures files
func (*TxInput) Descriptor ¶
func (*TxInput) GetPubKeys ¶
func (*TxInput) GetSignatures ¶
func (*TxInput) IsBase ¶
IsBase returns true if the reference is not present and the index is set to -1. This is true for creation of entities
func (*TxInput) ProtoMessage ¶
func (*TxInput) ProtoMessage()
type TxOutput ¶
type TxOutput struct { // Key used to identify the data DataKey DataKey `protobuf:"bytes,1,opt,name=DataKey,proto3,casttype=DataKey" json:"DataKey,omitempty"` // Actual data associated to the key Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` // Counter incremented on each write // int64 Counter = 3; Metrics map[string]float64 `` /* 150-byte string literal not displayed */ Tags map[string]string `` /* 142-byte string literal not displayed */ Labels []string `protobuf:"bytes,6,rep,name=Labels" json:"Labels,omitempty"` // Recipients (plural) public key. These are check along with the logic PubKeys []PublicKey `protobuf:"bytes,7,rep,name=PubKeys,casttype=PublicKey" json:"PubKeys,omitempty"` // Defines the 'verification' logic using TxnInput.Signature as data. This // is run as a check along with the public key match Logic []byte `protobuf:"bytes,8,opt,name=Logic,proto3" json:"Logic,omitempty"` }
func (*TxOutput) Descriptor ¶
func (*TxOutput) GetDataKey ¶
func (*TxOutput) GetMetrics ¶
func (*TxOutput) GetPubKeys ¶
func (*TxOutput) HasPublicKey ¶
HasPublicKey return true if the public key is one of the public keys listed in the output
func (*TxOutput) ProtoMessage ¶
func (*TxOutput) ProtoMessage()
func (*TxOutput) RemovePublicKey ¶
RemovePublicKey removes the public key returning true if it was removed
func (*TxOutput) SetRequiredSignatures ¶
SetRequiredSignatures sets the required signatures to mutate the output