Documentation
¶
Overview ¶
Package agent-tcp implements a TCP based agent to participate in consensus Challenge-Response scheme has been adopted to do interactive authentication
Index ¶
- Constants
- Variables
- func ECDH(publicKey *ecdsa.PublicKey, key *ecdsa.PrivateKey) *big.Int
- type CommandType
- type Gossip
- func (*Gossip) Descriptor() ([]byte, []int)
- func (m *Gossip) GetCommand() CommandType
- func (m *Gossip) GetMessage() []byte
- func (m *Gossip) Marshal() (dAtA []byte, err error)
- func (m *Gossip) MarshalTo(dAtA []byte) (int, error)
- func (m *Gossip) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Gossip) ProtoMessage()
- func (m *Gossip) Reset()
- func (m *Gossip) Size() (n int)
- func (m *Gossip) String() string
- func (m *Gossip) Unmarshal(dAtA []byte) error
- func (m *Gossip) XXX_DiscardUnknown()
- func (m *Gossip) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Gossip) XXX_Merge(src proto.Message)
- func (m *Gossip) XXX_Size() int
- func (m *Gossip) XXX_Unmarshal(b []byte) error
- type KeyAuthChallenge
- func (*KeyAuthChallenge) Descriptor() ([]byte, []int)
- func (m *KeyAuthChallenge) GetChallenge() []byte
- func (m *KeyAuthChallenge) GetX() []byte
- func (m *KeyAuthChallenge) GetY() []byte
- func (m *KeyAuthChallenge) Marshal() (dAtA []byte, err error)
- func (m *KeyAuthChallenge) MarshalTo(dAtA []byte) (int, error)
- func (m *KeyAuthChallenge) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*KeyAuthChallenge) ProtoMessage()
- func (m *KeyAuthChallenge) Reset()
- func (m *KeyAuthChallenge) Size() (n int)
- func (m *KeyAuthChallenge) String() string
- func (m *KeyAuthChallenge) Unmarshal(dAtA []byte) error
- func (m *KeyAuthChallenge) XXX_DiscardUnknown()
- func (m *KeyAuthChallenge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *KeyAuthChallenge) XXX_Merge(src proto.Message)
- func (m *KeyAuthChallenge) XXX_Size() int
- func (m *KeyAuthChallenge) XXX_Unmarshal(b []byte) error
- type KeyAuthChallengeReply
- func (*KeyAuthChallengeReply) Descriptor() ([]byte, []int)
- func (m *KeyAuthChallengeReply) GetHMAC() []byte
- func (m *KeyAuthChallengeReply) Marshal() (dAtA []byte, err error)
- func (m *KeyAuthChallengeReply) MarshalTo(dAtA []byte) (int, error)
- func (m *KeyAuthChallengeReply) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*KeyAuthChallengeReply) ProtoMessage()
- func (m *KeyAuthChallengeReply) Reset()
- func (m *KeyAuthChallengeReply) Size() (n int)
- func (m *KeyAuthChallengeReply) String() string
- func (m *KeyAuthChallengeReply) Unmarshal(dAtA []byte) error
- func (m *KeyAuthChallengeReply) XXX_DiscardUnknown()
- func (m *KeyAuthChallengeReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *KeyAuthChallengeReply) XXX_Merge(src proto.Message)
- func (m *KeyAuthChallengeReply) XXX_Size() int
- func (m *KeyAuthChallengeReply) XXX_Unmarshal(b []byte) error
- type KeyAuthInit
- func (*KeyAuthInit) Descriptor() ([]byte, []int)
- func (m *KeyAuthInit) GetX() []byte
- func (m *KeyAuthInit) GetY() []byte
- func (m *KeyAuthInit) Marshal() (dAtA []byte, err error)
- func (m *KeyAuthInit) MarshalTo(dAtA []byte) (int, error)
- func (m *KeyAuthInit) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*KeyAuthInit) ProtoMessage()
- func (m *KeyAuthInit) Reset()
- func (m *KeyAuthInit) Size() (n int)
- func (m *KeyAuthInit) String() string
- func (m *KeyAuthInit) Unmarshal(dAtA []byte) error
- func (m *KeyAuthInit) XXX_DiscardUnknown()
- func (m *KeyAuthInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *KeyAuthInit) XXX_Merge(src proto.Message)
- func (m *KeyAuthInit) XXX_Size() int
- func (m *KeyAuthInit) XXX_Unmarshal(b []byte) error
- type TCPAgent
- type TCPPeer
Constants ¶
const ( // Frame format: // |MessageLength(4bytes)| Message(MessageLength) ... | MessageLength = 4 // Message max length(32MB) MaxMessageLength = 32 * 1024 * 1024 )
Variables ¶
var ( ErrLocalKeyAuthInit = errors.New("incorrect state for local KeyAuthInitmessage") ErrKeyNotOnCurve = errors.New("the public key is not on curve") ErrPeerKeyAuthInit = errors.New("incorrect state for peer KeyAuthInit message") ErrPeerKeyAuthChallenge = errors.New("incorrect state for peer KeyAuthChallenge message") ErrPeerKeyAuthChallengeResponse = errors.New("incorrect state for peer KeyAuthChallengeResponse message") ErrPeerAuthenticatedFailed = errors.New("public key authentication failed for peer") ErrMessageLengthExceed = errors.New("message size exceeded maximum") )
var ( ErrInvalidLengthGossip = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGossip = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGossip = fmt.Errorf("proto: unexpected end of group") )
var CommandType_name = map[int32]string{
0: "NOP",
1: "KEY_AUTH_INIT",
2: "KEY_AUTH_CHALLENGE",
3: "KEY_AUTH_CHALLENGE_REPLY",
4: "CONSENSUS",
}
var CommandType_value = map[string]int32{
"NOP": 0,
"KEY_AUTH_INIT": 1,
"KEY_AUTH_CHALLENGE": 2,
"KEY_AUTH_CHALLENGE_REPLY": 3,
"CONSENSUS": 4,
}
Functions ¶
Types ¶
type CommandType ¶
type CommandType int32
CommandType defines supported commands
const ( CommandType_NOP CommandType = 0 CommandType_KEY_AUTH_INIT CommandType = 1 CommandType_KEY_AUTH_CHALLENGE CommandType = 2 CommandType_KEY_AUTH_CHALLENGE_REPLY CommandType = 3 CommandType_CONSENSUS CommandType = 4 )
func (CommandType) EnumDescriptor ¶
func (CommandType) EnumDescriptor() ([]byte, []int)
func (CommandType) String ¶
func (x CommandType) String() string
type Gossip ¶
type Gossip struct { Command CommandType `protobuf:"varint,1,opt,name=Command,proto3,enum=agent.CommandType" json:"Command,omitempty"` Message []byte `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Gossip defines a stream based protocol
func (*Gossip) Descriptor ¶
func (*Gossip) GetCommand ¶
func (m *Gossip) GetCommand() CommandType
func (*Gossip) GetMessage ¶
func (*Gossip) MarshalToSizedBuffer ¶
func (*Gossip) ProtoMessage ¶
func (*Gossip) ProtoMessage()
func (*Gossip) XXX_DiscardUnknown ¶
func (m *Gossip) XXX_DiscardUnknown()
func (*Gossip) XXX_Marshal ¶
func (*Gossip) XXX_Unmarshal ¶
type KeyAuthChallenge ¶
type KeyAuthChallenge struct { // server ephermal publickey for client authentication X []byte `protobuf:"bytes,1,opt,name=X,proto3" json:"X,omitempty"` Y []byte `protobuf:"bytes,2,opt,name=Y,proto3" json:"Y,omitempty"` // the challenge message, the peer can create the correct HMAC with this message Challenge []byte `protobuf:"bytes,3,opt,name=Challenge,proto3" json:"Challenge,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*KeyAuthChallenge) Descriptor ¶
func (*KeyAuthChallenge) Descriptor() ([]byte, []int)
func (*KeyAuthChallenge) GetChallenge ¶
func (m *KeyAuthChallenge) GetChallenge() []byte
func (*KeyAuthChallenge) GetX ¶
func (m *KeyAuthChallenge) GetX() []byte
func (*KeyAuthChallenge) GetY ¶
func (m *KeyAuthChallenge) GetY() []byte
func (*KeyAuthChallenge) Marshal ¶
func (m *KeyAuthChallenge) Marshal() (dAtA []byte, err error)
func (*KeyAuthChallenge) MarshalToSizedBuffer ¶
func (m *KeyAuthChallenge) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*KeyAuthChallenge) ProtoMessage ¶
func (*KeyAuthChallenge) ProtoMessage()
func (*KeyAuthChallenge) Reset ¶
func (m *KeyAuthChallenge) Reset()
func (*KeyAuthChallenge) Size ¶
func (m *KeyAuthChallenge) Size() (n int)
func (*KeyAuthChallenge) String ¶
func (m *KeyAuthChallenge) String() string
func (*KeyAuthChallenge) Unmarshal ¶
func (m *KeyAuthChallenge) Unmarshal(dAtA []byte) error
func (*KeyAuthChallenge) XXX_DiscardUnknown ¶
func (m *KeyAuthChallenge) XXX_DiscardUnknown()
func (*KeyAuthChallenge) XXX_Marshal ¶
func (m *KeyAuthChallenge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*KeyAuthChallenge) XXX_Merge ¶
func (m *KeyAuthChallenge) XXX_Merge(src proto.Message)
func (*KeyAuthChallenge) XXX_Size ¶
func (m *KeyAuthChallenge) XXX_Size() int
func (*KeyAuthChallenge) XXX_Unmarshal ¶
func (m *KeyAuthChallenge) XXX_Unmarshal(b []byte) error
type KeyAuthChallengeReply ¶
type KeyAuthChallengeReply struct { HMAC []byte `protobuf:"bytes,1,opt,name=HMAC,proto3" json:"HMAC,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*KeyAuthChallengeReply) Descriptor ¶
func (*KeyAuthChallengeReply) Descriptor() ([]byte, []int)
func (*KeyAuthChallengeReply) GetHMAC ¶
func (m *KeyAuthChallengeReply) GetHMAC() []byte
func (*KeyAuthChallengeReply) Marshal ¶
func (m *KeyAuthChallengeReply) Marshal() (dAtA []byte, err error)
func (*KeyAuthChallengeReply) MarshalTo ¶
func (m *KeyAuthChallengeReply) MarshalTo(dAtA []byte) (int, error)
func (*KeyAuthChallengeReply) MarshalToSizedBuffer ¶
func (m *KeyAuthChallengeReply) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*KeyAuthChallengeReply) ProtoMessage ¶
func (*KeyAuthChallengeReply) ProtoMessage()
func (*KeyAuthChallengeReply) Reset ¶
func (m *KeyAuthChallengeReply) Reset()
func (*KeyAuthChallengeReply) Size ¶
func (m *KeyAuthChallengeReply) Size() (n int)
func (*KeyAuthChallengeReply) String ¶
func (m *KeyAuthChallengeReply) String() string
func (*KeyAuthChallengeReply) Unmarshal ¶
func (m *KeyAuthChallengeReply) Unmarshal(dAtA []byte) error
func (*KeyAuthChallengeReply) XXX_DiscardUnknown ¶
func (m *KeyAuthChallengeReply) XXX_DiscardUnknown()
func (*KeyAuthChallengeReply) XXX_Marshal ¶
func (m *KeyAuthChallengeReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*KeyAuthChallengeReply) XXX_Merge ¶
func (m *KeyAuthChallengeReply) XXX_Merge(src proto.Message)
func (*KeyAuthChallengeReply) XXX_Size ¶
func (m *KeyAuthChallengeReply) XXX_Size() int
func (*KeyAuthChallengeReply) XXX_Unmarshal ¶
func (m *KeyAuthChallengeReply) XXX_Unmarshal(b []byte) error
type KeyAuthInit ¶
type KeyAuthInit struct { // client public key X []byte `protobuf:"bytes,1,opt,name=X,proto3" json:"X,omitempty"` Y []byte `protobuf:"bytes,2,opt,name=Y,proto3" json:"Y,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*KeyAuthInit) Descriptor ¶
func (*KeyAuthInit) Descriptor() ([]byte, []int)
func (*KeyAuthInit) GetX ¶
func (m *KeyAuthInit) GetX() []byte
func (*KeyAuthInit) GetY ¶
func (m *KeyAuthInit) GetY() []byte
func (*KeyAuthInit) Marshal ¶
func (m *KeyAuthInit) Marshal() (dAtA []byte, err error)
func (*KeyAuthInit) MarshalToSizedBuffer ¶
func (m *KeyAuthInit) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*KeyAuthInit) ProtoMessage ¶
func (*KeyAuthInit) ProtoMessage()
func (*KeyAuthInit) Reset ¶
func (m *KeyAuthInit) Reset()
func (*KeyAuthInit) Size ¶
func (m *KeyAuthInit) Size() (n int)
func (*KeyAuthInit) String ¶
func (m *KeyAuthInit) String() string
func (*KeyAuthInit) Unmarshal ¶
func (m *KeyAuthInit) Unmarshal(dAtA []byte) error
func (*KeyAuthInit) XXX_DiscardUnknown ¶
func (m *KeyAuthInit) XXX_DiscardUnknown()
func (*KeyAuthInit) XXX_Marshal ¶
func (m *KeyAuthInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*KeyAuthInit) XXX_Merge ¶
func (m *KeyAuthInit) XXX_Merge(src proto.Message)
func (*KeyAuthInit) XXX_Size ¶
func (m *KeyAuthInit) XXX_Size() int
func (*KeyAuthInit) XXX_Unmarshal ¶
func (m *KeyAuthInit) XXX_Unmarshal(b []byte) error
type TCPAgent ¶
A TCPAgent binds consensus core to a TCPAgent object, which may have multiple TCPPeer
func NewTCPAgent ¶
func NewTCPAgent(consensus *bdls.Consensus, privateKey *ecdsa.PrivateKey) *TCPAgent
NewTCPAgent initiate a TCPAgent which talks consensus protocol with peers
func (*TCPAgent) GetLatestState ¶
GetLatestState returns latest state
func (*TCPAgent) RemovePeer ¶
RemovePeer removes a TCPPeer from this agent
type TCPPeer ¶
type TCPPeer struct { // mutex for all fields sync.Mutex // contains filtered or unexported fields }
TCPPeer represents a peer(endpoint) related to a tcp connection
func NewTCPPeer ¶
NewTCPPeer creates a TCPPeer with protocol over this connection
func (*TCPPeer) GetPublicKey ¶
RemoteAddr implements PeerInterface, GetPublicKey returns peer's public key, returns nil if peer's has not authenticated it's public-key
func (*TCPPeer) InitiatePublicKeyAuthentication ¶
InitiatePublicKeyAuthentication will initate a procedure to convince the other peer to trust my ownership of public key
func (*TCPPeer) RemoteAddr ¶
RemoteAddr implements PeerInterface, returns peer's address as connection identity