berty: berty.tech/berty/go/internal/handshake Index | Files

package handshake

import "berty.tech/berty/go/internal/handshake"

Package handshake implements a capability-based handshake.

Handshake Sequence Diagram: --------------------------- Handshake vastely inspired by Scuttlebutt's Capability-based Handshake https://scuttlebot.io/more/protocols/shs.pdf

- a, b are ephemeral key pairs generated by respectively Requester and

Responder. Ephemeral keys are used for one handshake only and then
discarded. They guarantee the freshness of the messages and avoid
replay attacks.

- A, B are the Account IDs of respectively Requester and Responder. - a.b denotes a secret derived from the two keys a and b. - | is the concatenation operator. - box[a.b](content) denotes the encryption of content using Nacl box

with a.b as key.

- sig[A](content) denotes the signature of content verified by A.

+-----------+                       +-----------+
| Requester |                       | Responder |
+-----------+                       +-----------+
	  | ---------------------\            |
	  |-| 1. Requester Hello |            |
	  | |--------------------|            |
	  |                                   |
	  | a                                 |
	  |---------------------------------->|
	  |            ---------------------\ |
	  |            | 2. Responder Hello |-|
	  |            |--------------------| |
	  |                                   |
	  |                                 b |
	  |<----------------------------------|
	  | ----------------------------\     |
	  |-| 3. Requester Authenticate |     |
	  | |---------------------------|     |
	  |                                   |
	  | box[a.b|a.B](A,sig[A](a.b))       |
	  |---------------------------------->|
	  |           ----------------------\ |
	  |           | 4. Responder Accept |-|
	  |           |---------------------| |
	  |                                   |
	  |         box[a.b|A.B](sig[B](a.b)) |
	  |<----------------------------------|
	  | ---------------------------\      |
	  |-| 5. Requester Acknowledge |      |
	  | |--------------------------|      |
	  |                                   |
	  | ok                                |
	  |---------------------------------->|
	  |                                   |

See the documentation at https://berty.tech/protocol for more information.

Index

Package Files

doc.go handshake.go handshake.pb.go request.go response.go

Variables

var (
    ErrInvalidLengthHandshake        = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowHandshake          = fmt.Errorf("proto: integer overflow")
    ErrUnexpectedEndOfGroupHandshake = fmt.Errorf("proto: unexpected end of group")
)

func Request Uses

func Request(stream p2pnetwork.Stream, ownAccountID p2pcrypto.PrivKey, peerAccountID p2pcrypto.PubKey) error

Request init a handshake with the responder

func RequestUsingReaderWriter Uses

func RequestUsingReaderWriter(reader ggio.Reader, writer ggio.Writer, ownAccountID p2pcrypto.PrivKey, peerAccountID p2pcrypto.PubKey) error

RequestUsingReaderWriter init a handshake with the responder, using provided ggio reader and writer

func Response Uses

func Response(stream p2pnetwork.Stream, ownAccountID p2pcrypto.PrivKey) (p2pcrypto.PubKey, error)

Response handle the handshake inited by the requester

func ResponseUsingReaderWriter Uses

func ResponseUsingReaderWriter(reader ggio.Reader, writer ggio.Writer, ownAccountID p2pcrypto.PrivKey) (p2pcrypto.PubKey, error)

ResponseUsingReaderWriter handle the handshake inited by the requester, using provided ggio reader and writer

type BoxEnvelope Uses

type BoxEnvelope struct {
    Box                  []byte   `protobuf:"bytes,1,opt,name=box,proto3" json:"box,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*BoxEnvelope) Descriptor Uses

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

func (*BoxEnvelope) GetBox Uses

func (m *BoxEnvelope) GetBox() []byte

func (*BoxEnvelope) Marshal Uses

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

func (*BoxEnvelope) MarshalTo Uses

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

func (*BoxEnvelope) MarshalToSizedBuffer Uses

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

func (*BoxEnvelope) ProtoMessage Uses

func (*BoxEnvelope) ProtoMessage()

func (*BoxEnvelope) Reset Uses

func (m *BoxEnvelope) Reset()

func (*BoxEnvelope) Size Uses

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

func (*BoxEnvelope) String Uses

func (m *BoxEnvelope) String() string

func (*BoxEnvelope) Unmarshal Uses

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

func (*BoxEnvelope) XXX_DiscardUnknown Uses

func (m *BoxEnvelope) XXX_DiscardUnknown()

func (*BoxEnvelope) XXX_Marshal Uses

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

func (*BoxEnvelope) XXX_Merge Uses

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

func (*BoxEnvelope) XXX_Size Uses

func (m *BoxEnvelope) XXX_Size() int

func (*BoxEnvelope) XXX_Unmarshal Uses

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

type HelloPayload Uses

type HelloPayload struct {
    EphemeralPubKey      []byte   `protobuf:"bytes,1,opt,name=ephemeral_pub_key,json=ephemeralPubKey,proto3" json:"ephemeral_pub_key,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*HelloPayload) Descriptor Uses

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

func (*HelloPayload) GetEphemeralPubKey Uses

func (m *HelloPayload) GetEphemeralPubKey() []byte

func (*HelloPayload) Marshal Uses

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

func (*HelloPayload) MarshalTo Uses

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

func (*HelloPayload) MarshalToSizedBuffer Uses

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

func (*HelloPayload) ProtoMessage Uses

func (*HelloPayload) ProtoMessage()

func (*HelloPayload) Reset Uses

func (m *HelloPayload) Reset()

func (*HelloPayload) Size Uses

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

func (*HelloPayload) String Uses

func (m *HelloPayload) String() string

func (*HelloPayload) Unmarshal Uses

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

func (*HelloPayload) XXX_DiscardUnknown Uses

func (m *HelloPayload) XXX_DiscardUnknown()

func (*HelloPayload) XXX_Marshal Uses

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

func (*HelloPayload) XXX_Merge Uses

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

func (*HelloPayload) XXX_Size Uses

func (m *HelloPayload) XXX_Size() int

func (*HelloPayload) XXX_Unmarshal Uses

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

type RequesterAcknowledgePayload Uses

type RequesterAcknowledgePayload struct {
    Success              bool     `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*RequesterAcknowledgePayload) Descriptor Uses

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

func (*RequesterAcknowledgePayload) GetSuccess Uses

func (m *RequesterAcknowledgePayload) GetSuccess() bool

func (*RequesterAcknowledgePayload) Marshal Uses

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

func (*RequesterAcknowledgePayload) MarshalTo Uses

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

func (*RequesterAcknowledgePayload) MarshalToSizedBuffer Uses

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

func (*RequesterAcknowledgePayload) ProtoMessage Uses

func (*RequesterAcknowledgePayload) ProtoMessage()

func (*RequesterAcknowledgePayload) Reset Uses

func (m *RequesterAcknowledgePayload) Reset()

func (*RequesterAcknowledgePayload) Size Uses

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

func (*RequesterAcknowledgePayload) String Uses

func (m *RequesterAcknowledgePayload) String() string

func (*RequesterAcknowledgePayload) Unmarshal Uses

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

func (*RequesterAcknowledgePayload) XXX_DiscardUnknown Uses

func (m *RequesterAcknowledgePayload) XXX_DiscardUnknown()

func (*RequesterAcknowledgePayload) XXX_Marshal Uses

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

func (*RequesterAcknowledgePayload) XXX_Merge Uses

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

func (*RequesterAcknowledgePayload) XXX_Size Uses

func (m *RequesterAcknowledgePayload) XXX_Size() int

func (*RequesterAcknowledgePayload) XXX_Unmarshal Uses

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

type RequesterAuthenticatePayload Uses

type RequesterAuthenticatePayload struct {
    RequesterAccountId   []byte   `protobuf:"bytes,1,opt,name=requester_account_id,json=requesterAccountId,proto3" json:"requester_account_id,omitempty"`
    RequesterAccountSig  []byte   `protobuf:"bytes,2,opt,name=requester_account_sig,json=requesterAccountSig,proto3" json:"requester_account_sig,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*RequesterAuthenticatePayload) Descriptor Uses

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

func (*RequesterAuthenticatePayload) GetRequesterAccountId Uses

func (m *RequesterAuthenticatePayload) GetRequesterAccountId() []byte

func (*RequesterAuthenticatePayload) GetRequesterAccountSig Uses

func (m *RequesterAuthenticatePayload) GetRequesterAccountSig() []byte

func (*RequesterAuthenticatePayload) Marshal Uses

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

func (*RequesterAuthenticatePayload) MarshalTo Uses

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

func (*RequesterAuthenticatePayload) MarshalToSizedBuffer Uses

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

func (*RequesterAuthenticatePayload) ProtoMessage Uses

func (*RequesterAuthenticatePayload) ProtoMessage()

func (*RequesterAuthenticatePayload) Reset Uses

func (m *RequesterAuthenticatePayload) Reset()

func (*RequesterAuthenticatePayload) Size Uses

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

func (*RequesterAuthenticatePayload) String Uses

func (m *RequesterAuthenticatePayload) String() string

func (*RequesterAuthenticatePayload) Unmarshal Uses

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

func (*RequesterAuthenticatePayload) XXX_DiscardUnknown Uses

func (m *RequesterAuthenticatePayload) XXX_DiscardUnknown()

func (*RequesterAuthenticatePayload) XXX_Marshal Uses

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

func (*RequesterAuthenticatePayload) XXX_Merge Uses

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

func (*RequesterAuthenticatePayload) XXX_Size Uses

func (m *RequesterAuthenticatePayload) XXX_Size() int

func (*RequesterAuthenticatePayload) XXX_Unmarshal Uses

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

type ResponderAcceptPayload Uses

type ResponderAcceptPayload struct {
    ResponderAccountSig  []byte   `protobuf:"bytes,1,opt,name=responder_account_sig,json=responderAccountSig,proto3" json:"responder_account_sig,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*ResponderAcceptPayload) Descriptor Uses

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

func (*ResponderAcceptPayload) GetResponderAccountSig Uses

func (m *ResponderAcceptPayload) GetResponderAccountSig() []byte

func (*ResponderAcceptPayload) Marshal Uses

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

func (*ResponderAcceptPayload) MarshalTo Uses

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

func (*ResponderAcceptPayload) MarshalToSizedBuffer Uses

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

func (*ResponderAcceptPayload) ProtoMessage Uses

func (*ResponderAcceptPayload) ProtoMessage()

func (*ResponderAcceptPayload) Reset Uses

func (m *ResponderAcceptPayload) Reset()

func (*ResponderAcceptPayload) Size Uses

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

func (*ResponderAcceptPayload) String Uses

func (m *ResponderAcceptPayload) String() string

func (*ResponderAcceptPayload) Unmarshal Uses

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

func (*ResponderAcceptPayload) XXX_DiscardUnknown Uses

func (m *ResponderAcceptPayload) XXX_DiscardUnknown()

func (*ResponderAcceptPayload) XXX_Marshal Uses

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

func (*ResponderAcceptPayload) XXX_Merge Uses

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

func (*ResponderAcceptPayload) XXX_Size Uses

func (m *ResponderAcceptPayload) XXX_Size() int

func (*ResponderAcceptPayload) XXX_Unmarshal Uses

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

Package handshake imports 14 packages (graph). Updated 2020-09-28. Refresh now. Tools for package owners.