handshake

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

View Source
var File_handshake_handshake_proto protoreflect.FileDescriptor

Functions

func RequestUsingReaderWriter

func RequestUsingReaderWriter(ctx context.Context, logger *zap.Logger, reader protoio.Reader, writer protoio.Writer, ownAccountID p2pcrypto.PrivKey, peerAccountID p2pcrypto.PubKey) error

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

func ResponseUsingReaderWriter

func ResponseUsingReaderWriter(ctx context.Context, logger *zap.Logger, reader protoio.Reader, writer protoio.Writer, ownAccountID p2pcrypto.PrivKey) (p2pcrypto.PubKey, error)

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

Types

type BoxEnvelope

type BoxEnvelope struct {
	Box []byte `protobuf:"bytes,1,opt,name=box,proto3" json:"box,omitempty"`
	// contains filtered or unexported fields
}

func (*BoxEnvelope) Descriptor deprecated

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

Deprecated: Use BoxEnvelope.ProtoReflect.Descriptor instead.

func (*BoxEnvelope) GetBox

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

func (*BoxEnvelope) ProtoMessage

func (*BoxEnvelope) ProtoMessage()

func (*BoxEnvelope) ProtoReflect

func (x *BoxEnvelope) ProtoReflect() protoreflect.Message

func (*BoxEnvelope) Reset

func (x *BoxEnvelope) Reset()

func (*BoxEnvelope) String

func (x *BoxEnvelope) String() string

type HelloPayload

type HelloPayload struct {
	EphemeralPubKey []byte `protobuf:"bytes,1,opt,name=ephemeral_pub_key,json=ephemeralPubKey,proto3" json:"ephemeral_pub_key,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloPayload) Descriptor deprecated

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

Deprecated: Use HelloPayload.ProtoReflect.Descriptor instead.

func (*HelloPayload) GetEphemeralPubKey

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

func (*HelloPayload) ProtoMessage

func (*HelloPayload) ProtoMessage()

func (*HelloPayload) ProtoReflect

func (x *HelloPayload) ProtoReflect() protoreflect.Message

func (*HelloPayload) Reset

func (x *HelloPayload) Reset()

func (*HelloPayload) String

func (x *HelloPayload) String() string

type RequesterAcknowledgePayload

type RequesterAcknowledgePayload struct {
	Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	// contains filtered or unexported fields
}

func (*RequesterAcknowledgePayload) Descriptor deprecated

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

Deprecated: Use RequesterAcknowledgePayload.ProtoReflect.Descriptor instead.

func (*RequesterAcknowledgePayload) GetSuccess

func (x *RequesterAcknowledgePayload) GetSuccess() bool

func (*RequesterAcknowledgePayload) ProtoMessage

func (*RequesterAcknowledgePayload) ProtoMessage()

func (*RequesterAcknowledgePayload) ProtoReflect

func (*RequesterAcknowledgePayload) Reset

func (x *RequesterAcknowledgePayload) Reset()

func (*RequesterAcknowledgePayload) String

func (x *RequesterAcknowledgePayload) String() string

type RequesterAuthenticatePayload

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"`
	// contains filtered or unexported fields
}

func (*RequesterAuthenticatePayload) Descriptor deprecated

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

Deprecated: Use RequesterAuthenticatePayload.ProtoReflect.Descriptor instead.

func (*RequesterAuthenticatePayload) GetRequesterAccountId

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

func (*RequesterAuthenticatePayload) GetRequesterAccountSig

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

func (*RequesterAuthenticatePayload) ProtoMessage

func (*RequesterAuthenticatePayload) ProtoMessage()

func (*RequesterAuthenticatePayload) ProtoReflect

func (*RequesterAuthenticatePayload) Reset

func (x *RequesterAuthenticatePayload) Reset()

func (*RequesterAuthenticatePayload) String

type ResponderAcceptPayload

type ResponderAcceptPayload struct {
	ResponderAccountSig []byte `protobuf:"bytes,1,opt,name=responder_account_sig,json=responderAccountSig,proto3" json:"responder_account_sig,omitempty"`
	// contains filtered or unexported fields
}

func (*ResponderAcceptPayload) Descriptor deprecated

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

Deprecated: Use ResponderAcceptPayload.ProtoReflect.Descriptor instead.

func (*ResponderAcceptPayload) GetResponderAccountSig

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

func (*ResponderAcceptPayload) ProtoMessage

func (*ResponderAcceptPayload) ProtoMessage()

func (*ResponderAcceptPayload) ProtoReflect

func (x *ResponderAcceptPayload) ProtoReflect() protoreflect.Message

func (*ResponderAcceptPayload) Reset

func (x *ResponderAcceptPayload) Reset()

func (*ResponderAcceptPayload) String

func (x *ResponderAcceptPayload) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳