bdls

package module
v0.0.0-...-28f164c Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

README

BDLS

Efficient BFT in partial synchronous networks

GoDoc License Build Status Go Report Card Coverage Statusd Sourcegraph

BDLS Consensus

Introduction

BDLS is an innovative BFT consensus algorithm that features safety and liveness by presenting a mathematically proven secure BFT protocol that is resilient in open networks such as the Internet. BDLS overcomes many problems, such as the deadlock problem caused by unreliable p2p/broadcast channels. These problems are all very relevant to existing realistic open network scenarios, and are the focus of extensive work in improving Internet security, but it is an area largely ignored by most in mainstream BFT protocol design. (Paper: https://eprint.iacr.org/2019/1460.pdf or https://dl.acm.org/doi/abs/10.1145/3538227 or https://doi.org/10.1145/3538227 or https://www.doi.org/10.1007/978-3-030-91859-0_2 )

For this library, to make the runtime behavior of consensus algorithm predictable as function: y = f(x, t), where 'x' is the message it received, and 't' is the time while being called, then'y' is the deterministic status of consensus after 'x' and 't' applied to 'f', it has been designed in a deterministic scheme, without parallel computing, networking, and the correctness of program implementation can be proven with proper test cases.

Features

  1. Pure algorithm implementation in deterministic and predictable behavior, easily to be integrated into existing projects, refer to DFA for more.
  2. Well-tested on various platforms with complicated cases.
  3. Auto back-off under heavy payload, guaranteed finalization(worst case gurantee).
  4. Easy integratation into Blockchain & non-Blockchain consensus, like WAL replication in database.
  5. Builtin network emulation for various network latency with comprehensive statistics.

Documentation

For complete documentation, see the associated Godoc.

Install BDLS on Ubuntu Server 20.04

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install autoconf automake libtool curl make g++ unzip
cd /tmp
wget https://go.dev/dl/go1.17.5.linux-amd64.tar.gz
sudo tar -xvf go1.17.5.linux-amd64.tar.gz
sudo mv go /usr/local
cd
echo 'export GOROOT=/usr/local/go' >> .profile
echo 'export GOPATH=$HOME/go' >> .profile
echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> .profile
source ~/.profile 
go version
go env
git clone https://github.com/hyperledger-labs/bdls.git
cd bdls/
git checkout master
cd cmd/emucon/
go build .
./emucon help genkeys
./emucon genkeys --count 4

[open four terminals to run four participants. if you log to remote Linux, 
you may use tmux commands. In tmux, you can switch termian using "ctrl+b d" 
and use "tmux attach -t 0" to enter the terminal. Use "tmux list-session" 
to check the current active terminals]


./emucon run --id 0 --listen ":4680"
./emucon run --id 1 --listen ":4681"
./emucon run --id 2 --listen ":4682"
./emucon run --id 3 --listen ":4683"

cd ../..
go test -v -cpuprofile=cpu.out -memprofile=mem.out -timeout 2h

Regenerate go.mod and go.sum

rm go.*
go mod init github.com/hyperledger-labs/bdls
go mod tidy
go mod vendor

See benchmark ourput at: AMD-NORMAL.TXT and PI4-OVERLOAD.TXT

Specification

  1. Consensus messages are specified in message.proto, users of this library can encapsulate this message in a carrier message, like gossip in TCP.
  2. Consensus algorithm is NOT thread-safe, it MUST be protected by some synchronization mechanism, like sync.Mutex or chan + goroutine.

Usage

  1. A testing IPC peer -- ipc_peer.go
  2. A testing TCP node -- TCP based Consensus Emualtor

Status

On-going

Documentation

Overview

Package bdls implements Sperax Byzantine Fault Tolerance in Partially Connected Asynchronous Networks based on https://eprint.iacr.org/2019/1460.pdf.

To make the runtime behavior of consensus algorithm predictable, as a function: y = f(x, t), where 'x' is the message it received, and 't' is the time while being called, and 'y' is the deterministic status of consensus after 'x' and 't' applied to 'f', this library has been designed in a deterministic scheme, without parallel computing, networking, and current time is a parameter to this library.

As it's a pure algorithm implementation, it's not thread-safe! Users of this library should take care of their own sychronziation mechanism.

Index

Constants

View Source
const (
	// the current BDLS protocol version,
	// version will be sent along with messages for protocol upgrading.
	ProtocolVersion = 1
	// DefaultConsensusLatency is the default propagation latency setting for
	// consensus protocol, user can adjust consensus object's latency setting
	// via Consensus.SetLatency()
	DefaultConsensusLatency = 300 * time.Millisecond

	// MaxConsensusLatency is the ceiling of latencies
	MaxConsensusLatency = 10 * time.Second
)
View Source
const (
	// SizeAxis defines byte size of X-axis or Y-axis in a public key
	SizeAxis = 32
	// SignaturePrefix is the prefix for signing a consensus message
	SignaturePrefix = "BDLS_CONSENSUS_SIGNATURE"
)
View Source
const (
	// ConfigMinimumParticipants is the minimum number of participant allow in consensus protocol
	ConfigMinimumParticipants = 4
)

Variables

View Source
var (
	// Config Related
	ErrConfigEpoch              = errors.New("Config.Epoch is nil")
	ErrConfigStateNil           = errors.New("Config.CurrentState is nil")
	ErrConfigStateCompare       = errors.New("Config.StateCompare function has not set")
	ErrConfigStateValidate      = errors.New("Config.StateValidate function has not set")
	ErrConfigPrivateKey         = errors.New("Config.PrivateKey has not set")
	ErrConfigParticipants       = errors.New("Config.Participants must contain at least 4 participants")
	ErrConfigPubKeyToCoordinate = errors.New("Config.must contain at least 4 participants")

	// common errors related to every message
	ErrMessageVersion            = errors.New("the message has different version")
	ErrMessageValidator          = errors.New("the message has been rejected by external validator")
	ErrMessageIsEmpty            = errors.New("the message being verified is empty")
	ErrMessageUnknownMessageType = errors.New("unrecognized message type")
	ErrMessageSignature          = errors.New("cannot verify the signature of this message")
	ErrMessageUnknownParticipant = errors.New("the message is from unknown partcipants")

	// <roundchange> related
	ErrRoundChangeHeightMismatch  = errors.New("the <roundchange> message has another height than expected")
	ErrRoundChangeRoundLower      = errors.New("the <roundchange> message has lower round than expected")
	ErrRoundChangeStateValidation = errors.New("the state data validation failed <roundchange> message")

	// <lock> related
	ErrLockEmptyState              = errors.New("the state is empty in <lock> message")
	ErrLockStateValidation         = errors.New("the state data validation failed <lock> message")
	ErrLockHeightMismatch          = errors.New("the <lock> message has another height than expected")
	ErrLockRoundLower              = errors.New("the <lock> message has lower round than expected")
	ErrLockNotSignedByLeader       = errors.New("the <lock> message is not signed by leader")
	ErrLockProofUnknownParticipant = errors.New("the proofs in <lock> message has unknown participant")
	ErrLockProofTypeMismatch       = errors.New("the proofs in <lock> message is not <roundchange>")
	ErrLockProofHeightMismatch     = errors.New("the proofs in <lock> message has mismatched height")
	ErrLockProofRoundMismatch      = errors.New("the proofs in <lock> message has mismatched round")
	ErrLockProofStateValidation    = errors.New("the proofs in <lock> message has invalid state data")
	ErrLockProofInsufficient       = errors.New("the <lock> message has insufficient <roundchange> proofs to the proposed state")

	// <select> related
	ErrSelectStateValidation         = errors.New("the state data validation failed <select> message")
	ErrSelectHeightMismatch          = errors.New("the <select> message has another height than expected")
	ErrSelectRoundLower              = errors.New("the <select> message has lower round than expected")
	ErrSelectNotSignedByLeader       = errors.New("the <select> message is not signed by leader")
	ErrSelectStateMismatch           = errors.New("the <select> message has nil state but proof contains non-nil state")
	ErrSelectProofUnknownParticipant = errors.New("the proofs in <select> message has unknown participant")
	ErrSelectProofTypeMismatch       = errors.New("the proofs in <select> message is not <roundchange>")
	ErrSelectProofHeightMismatch     = errors.New("the proofs in <select> message has mismatched height")
	ErrSelectProofRoundMismatch      = errors.New("the proofs in <select> message has mismatched round")
	ErrSelectProofStateValidation    = errors.New("the proofs in <select> message has invalid state data")
	ErrSelectProofNotTheMaximal      = errors.New("the proposed state is not the maximal one in the <select> message")
	ErrSelectProofInsufficient       = errors.New("the <select> message has insufficient overall proofs")
	ErrSelectProofExceeded           = errors.New("the <select> message overall state proposals exceeded maximal")

	// <decide> Related
	ErrDecideHeightLower             = errors.New("the <decide> message has lower height than expected")
	ErrDecideEmptyState              = errors.New("the state is empty in <decide> message")
	ErrDecideStateValidation         = errors.New("the state data validation failed <decide> message")
	ErrDecideNotSignedByLeader       = errors.New("the <decide> message is not signed by leader")
	ErrDecideProofUnknownParticipant = errors.New("the proofs in <decide> message has unknown participant")
	ErrDecideProofTypeMismatch       = errors.New("the proofs in <decide> message is not <commit>")
	ErrDecideProofHeightMismatch     = errors.New("the proofs in <decide> message has mismatched height")
	ErrDecideProofRoundMismatch      = errors.New("the proofs in <decide> message has mismatched round")
	ErrDecideProofStateValidation    = errors.New("the proofs in <decide> message has invalid state data")
	ErrDecideProofInsufficient       = errors.New("the <decide> message has insufficient <commit> proofs to the proposed state")

	// <lock-release> related
	ErrLockReleaseStatus = errors.New("received <lock-release> message in non LOCK-RELEASE state")

	// <commit> related
	ErrCommitEmptyState      = errors.New("the state is empty in <commit> message")
	ErrCommitStateMismatch   = errors.New("the state in <commit> message does not match what leader has locked")
	ErrCommitStateValidation = errors.New("the state data validation failed <commit> message")
	ErrCommitStatus          = errors.New("received <commit> message in non COMMIT state")
	ErrCommitHeightMismatch  = errors.New("the <commit> message has another height than expected")
	ErrCommitRoundMismatch   = errors.New("the <commit> message is from another round")

	// <decide> verification
	ErrMismatchedTargetState = errors.New("the state in <decide> message does not match the provided target state")
)
View Source
var (
	ErrInvalidLengthMessage        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMessage          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupMessage = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ErrPubKey = errors.New("incorrect pubkey format")

ErrPubKey will be returned if error found while decoding message's public key

View Source
var MessageType_name = map[int32]string{
	0: "Nop",
	1: "RoundChange",
	2: "Lock",
	3: "Select",
	4: "Commit",
	5: "LockRelease",
	6: "Decide",
	7: "Resync",
}
View Source
var MessageType_value = map[string]int32{
	"Nop":         0,
	"RoundChange": 1,
	"Lock":        2,
	"Select":      3,
	"Commit":      4,
	"LockRelease": 5,
	"Decide":      6,
	"Resync":      7,
}
View Source
var S256Curve elliptic.Curve = btcec.S256()

secp256k1 elliptic curve

Functions

func VerifyConfig

func VerifyConfig(c *Config) error

VerifyConfig verifies the integrity of this config when creating new consensus object

Types

type Config

type Config struct {
	// the starting time point for consensus
	Epoch time.Time
	// CurrentHeight
	CurrentHeight uint64
	// PrivateKey
	PrivateKey *ecdsa.PrivateKey
	// Consensus Group
	Participants []Identity
	// EnableCommitUnicast sets to true to enable <commit> message to be delivered via unicast
	// if not(by default), <commit> message will be broadcasted
	EnableCommitUnicast bool

	// StateCompare is a function from user to compare states,
	// The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
	// Usually this will lead to block header comparsion in blockchain, or replication log in database,
	// users should check fields in block header to make comparison.
	StateCompare func(a State, b State) int

	// StateValidate is a function from user to validate the integrity of
	// state data.
	StateValidate func(State) bool

	// MessageValidator is an external validator to be called when a message inputs into ReceiveMessage
	MessageValidator func(c *Consensus, m *Message, signed *SignedProto) bool

	// MessageOutCallback will be called if not nil before a message send out
	MessageOutCallback func(m *Message, signed *SignedProto)

	// Identity derviation from ecdsa.PublicKey
	// (optional). Default to DefaultPubKeyToIdentity
	PubKeyToIdentity func(pubkey *ecdsa.PublicKey) (ret Identity)
}

Config is to config the parameters of BDLS consensus protocol

type Consensus

type Consensus struct {
	// contains filtered or unexported fields
}

Consensus implements a deterministic BDLS consensus protocol.

It has no internal clocking or IO, and no parallel processing. The runtime behavior is predictable and deterministic. Users should write their own timing and IO function to feed in messages and ticks to trigger timeouts.

func NewConsensus

func NewConsensus(config *Config) (*Consensus, error)

NewConsensus creates a BDLS consensus object to participant in consensus procedure, the consensus object returned is data in memory without goroutines or other non-deterministic objects, and errors will be returned if there is problem, with the given config.

func (*Consensus) CurrentProof

func (c *Consensus) CurrentProof() *SignedProto

CurrentProof returns current <decide> message for current height

func (*Consensus) CurrentState

func (c *Consensus) CurrentState() (height uint64, round uint64, data State)

CurrentState returns current state along with current height & round, It's caller's responsibility to check if ReceiveMessage() has created a new height.

func (*Consensus) HasProposed

func (c *Consensus) HasProposed(state State) bool

HasProposed checks whether some state has been proposed via <roundchange> <lock> or left in c.unconfirmed

func (*Consensus) Join

func (c *Consensus) Join(p PeerInterface) bool

Join adds a peer to consensus for message delivery, a peer is identified by its address.

func (*Consensus) Leave

func (c *Consensus) Leave(addr net.Addr) bool

Leave removes a peer from consensus, identified by its address

func (*Consensus) Propose

func (c *Consensus) Propose(s State)

Propose adds a new state to unconfirmed queue to particpate in consensus at next height.

func (*Consensus) ReceiveMessage

func (c *Consensus) ReceiveMessage(bts []byte, now time.Time) (err error)

ReceiveMessage processes incoming consensus messages, and returns error if message cannot be processed for some reason.

func (*Consensus) SetLatency

func (c *Consensus) SetLatency(latency time.Duration)

SetLatency sets participants expected latency for consensus core

func (*Consensus) SubmitRequest

func (c *Consensus) SubmitRequest(bts []byte, now time.Time) (err error)

ReceiveMessage input to core incoming consensus messages, and returns error

func (*Consensus) Update

func (c *Consensus) Update(now time.Time) error

Update will process timing event for the state machine, callers from outside MUST call this function periodically(like 20ms).

func (*Consensus) ValidateDecideMessage

func (c *Consensus) ValidateDecideMessage(bts []byte, targetState []byte) error

ValidateDecideMessage validates a <decide> message for non-participants, the consensus core must be correctly initialized to validate. the targetState is to compare the target state enclosed in decide message

type IPCPeer

type IPCPeer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IPCPeer represents an in-process peer for testing, which sends messages directly via function call, message delivery latency can be customizable to emulate variety of network latency. Delay is randomized with standard normal distribution based on given parameters.

func NewIPCPeer

func NewIPCPeer(c *Consensus, latency time.Duration) *IPCPeer

NewIPCPeer creates IPC based peer with latency, latency is distributed with standard normal distribution.

func (*IPCPeer) Close

func (p *IPCPeer) Close()

Close this peer

func (*IPCPeer) GetBytesCount

func (p *IPCPeer) GetBytesCount() int64

GetBytesCount returns messages bytes count this peer received

func (*IPCPeer) GetLatencies

func (p *IPCPeer) GetLatencies() (min time.Duration, max time.Duration, total time.Duration)

GetLatencies returns actual generated latency

func (*IPCPeer) GetLatestState

func (p *IPCPeer) GetLatestState() (height uint64, round uint64, data State)

GetLatestState returns latest state

func (*IPCPeer) GetMessageCount

func (p *IPCPeer) GetMessageCount() int64

GetMessageCount returns messages count this peer received

func (*IPCPeer) GetPublicKey

func (p *IPCPeer) GetPublicKey() *ecdsa.PublicKey

GetPublicKey returns peer's public key as identity

func (*IPCPeer) Propose

func (p *IPCPeer) Propose(s State)

Propose a state, awaiting to be finalized at next height.

func (*IPCPeer) RemoteAddr

func (p *IPCPeer) RemoteAddr() net.Addr

RemoteAddr implements Peer.RemoteAddr, the address is p's memory address

func (*IPCPeer) Send

func (p *IPCPeer) Send(msg []byte) error

Send implements Peer.Send

func (*IPCPeer) Update

func (p *IPCPeer) Update()

Update will call itself perodically

type Identity

type Identity [2 * SizeAxis]byte

Identity is a user-defined struct to encode X-axis and Y-axis for a publickey in an array

func DefaultPubKeyToIdentity

func DefaultPubKeyToIdentity(pubkey *ecdsa.PublicKey) (ret Identity)

default method to derive coordinate from public key

type Message

type Message struct {
	// Type of this message
	Type MessageType `protobuf:"varint,1,opt,name=Type,proto3,enum=bdls.MessageType" json:"Type,omitempty"`
	// Height in consensus
	Height uint64 `protobuf:"varint,2,opt,name=Height,proto3" json:"Height,omitempty"`
	// Round in consensus
	Round uint64 `protobuf:"varint,3,opt,name=Round,proto3" json:"Round,omitempty"`
	// Proposed state (optional)
	State []byte `protobuf:"bytes,4,opt,name=State,proto3" json:"State,omitempty"`
	// Proofs related
	Proof []*SignedProto `protobuf:"bytes,5,rep,name=Proof,proto3" json:"Proof,omitempty"`
	// for lock-release, it's an embeded <lock> message
	LockRelease          *SignedProto `protobuf:"bytes,6,opt,name=LockRelease,proto3" json:"LockRelease,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

Message defines a consensus message

func DecodeMessage

func DecodeMessage(bts []byte) (*Message, error)

DecodeMessage decodes a binary representation of consensus message.

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetHeight

func (m *Message) GetHeight() uint64

func (*Message) GetLockRelease

func (m *Message) GetLockRelease() *SignedProto

func (*Message) GetProof

func (m *Message) GetProof() []*SignedProto

func (*Message) GetRound

func (m *Message) GetRound() uint64

func (*Message) GetState

func (m *Message) GetState() []byte

func (*Message) GetType

func (m *Message) GetType() MessageType

func (*Message) Marshal

func (m *Message) Marshal() (dAtA []byte, err error)

func (*Message) MarshalTo

func (m *Message) MarshalTo(dAtA []byte) (int, error)

func (*Message) MarshalToSizedBuffer

func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) Size

func (m *Message) Size() (n int)

func (*Message) String

func (m *Message) String() string

func (*Message) Unmarshal

func (m *Message) Unmarshal(dAtA []byte) error

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

type MessageType

type MessageType int32

MessageType defines supported message types

const (
	// No operation, for default message type, and keepalive connection
	MessageType_Nop MessageType = 0
	// MessageRoundChange = <roundchange> message
	MessageType_RoundChange MessageType = 1
	// MessageLock = <lock> message
	MessageType_Lock MessageType = 2
	// MessageSelect = <select> message
	MessageType_Select MessageType = 3
	// MessageCommit = <commit> message
	MessageType_Commit MessageType = 4
	// MessageLockRelease = <lock-release> message
	MessageType_LockRelease MessageType = 5
	// MessageDecide = <decide> message
	MessageType_Decide MessageType = 6
	// MessageResync= <resync> message
	MessageType_Resync MessageType = 7
)

func (MessageType) EnumDescriptor

func (MessageType) EnumDescriptor() ([]byte, []int)

func (MessageType) String

func (x MessageType) String() string

type PeerInterface

type PeerInterface interface {
	// GetPublicKey returns peer's public key as identity
	GetPublicKey() *ecdsa.PublicKey
	// RemoteAddr returns remote addr
	RemoteAddr() net.Addr
	// Send a msg to this peer
	Send(msg []byte) error
}

PeerInterface is a channel for consensus to send message to the peer

type PubKeyAxis

type PubKeyAxis [SizeAxis]byte

PubKeyAxis defines X-axis or Y-axis in a public key

func (PubKeyAxis) Marshal

func (t PubKeyAxis) Marshal() ([]byte, error)

Marshal implements protobuf MarshalTo

func (*PubKeyAxis) MarshalText

func (t *PubKeyAxis) MarshalText() (text []byte, err error)

String representation of Axis

func (*PubKeyAxis) MarshalTo

func (t *PubKeyAxis) MarshalTo(data []byte) (n int, err error)

MarshalTo implements protobuf MarshalTo

func (*PubKeyAxis) Size

func (t *PubKeyAxis) Size() int

Size implements protobuf Size

func (*PubKeyAxis) String

func (t *PubKeyAxis) String() string

String representation of Axis

func (*PubKeyAxis) Unmarshal

func (t *PubKeyAxis) Unmarshal(data []byte) error

Unmarshal implements protobuf Unmarshal

type SignedProto

type SignedProto struct {
	Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	// the Message encoded raw protobuf in bytes
	Message []byte `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
	// signer's public key
	X PubKeyAxis `protobuf:"bytes,3,opt,name=x,proto3,customtype=PubKeyAxis" json:"x"`
	Y PubKeyAxis `protobuf:"bytes,4,opt,name=y,proto3,customtype=PubKeyAxis" json:"y"`
	// signature r,s for prefix+messages+version+x+y above
	R                    []byte   `protobuf:"bytes,5,opt,name=r,proto3" json:"r,omitempty"`
	S                    []byte   `protobuf:"bytes,6,opt,name=s,proto3" json:"s,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

SignedProto defines a message with signature and it's publickey

func DecodeSignedMessage

func DecodeSignedMessage(bts []byte) (*SignedProto, error)

DecodeSignedMessage decodes a binary representation of signed consensus message.

func (*SignedProto) Descriptor

func (*SignedProto) Descriptor() ([]byte, []int)

func (*SignedProto) GetMessage

func (m *SignedProto) GetMessage() []byte

func (*SignedProto) GetR

func (m *SignedProto) GetR() []byte

func (*SignedProto) GetS

func (m *SignedProto) GetS() []byte

func (*SignedProto) GetVersion

func (m *SignedProto) GetVersion() uint32

func (*SignedProto) Hash

func (sp *SignedProto) Hash() []byte

Hash concats and hash as follows: blake2b(signPrefix + version + pubkey.X + pubkey.Y+len_32bit(msg) + message)

func (*SignedProto) Marshal

func (m *SignedProto) Marshal() (dAtA []byte, err error)

func (*SignedProto) MarshalTo

func (m *SignedProto) MarshalTo(dAtA []byte) (int, error)

func (*SignedProto) MarshalToSizedBuffer

func (m *SignedProto) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SignedProto) ProtoMessage

func (*SignedProto) ProtoMessage()

func (*SignedProto) PublicKey

func (sp *SignedProto) PublicKey(curve elliptic.Curve) *ecdsa.PublicKey

PublicKey returns the public key of this signed message

func (*SignedProto) Reset

func (m *SignedProto) Reset()

func (*SignedProto) Sign

func (sp *SignedProto) Sign(m *Message, privateKey *ecdsa.PrivateKey)

Sign the message with a private key

func (*SignedProto) Size

func (m *SignedProto) Size() (n int)

func (*SignedProto) String

func (m *SignedProto) String() string

func (*SignedProto) Unmarshal

func (m *SignedProto) Unmarshal(dAtA []byte) error

func (*SignedProto) Verify

func (sp *SignedProto) Verify(curve elliptic.Curve) bool

Verify the signature of this signed message

func (*SignedProto) XXX_DiscardUnknown

func (m *SignedProto) XXX_DiscardUnknown()

func (*SignedProto) XXX_Marshal

func (m *SignedProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SignedProto) XXX_Merge

func (m *SignedProto) XXX_Merge(src proto.Message)

func (*SignedProto) XXX_Size

func (m *SignedProto) XXX_Size() int

func (*SignedProto) XXX_Unmarshal

func (m *SignedProto) XXX_Unmarshal(b []byte) error

type State

type State []byte

State is the data to participant in consensus. This could be candidate blocks in blockchain systems

type StateHash

type StateHash [blake2b.Size256]byte

StateHash = H(State)

Directories

Path Synopsis
Package agent-tcp implements a TCP based agent to participate in consensus Challenge-Response scheme has been adopted to do interactive authentication
Package agent-tcp implements a TCP based agent to participate in consensus Challenge-Response scheme has been adopted to do interactive authentication
cmd
crypto
blake2b
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
btcec
Package btcec implements support for the elliptic curves needed for bitcoin.
Package btcec implements support for the elliptic curves needed for bitcoin.

Jump to

Keyboard shortcuts

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