ratchet

package
v0.0.0-...-e34fb4d Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2022 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Package ratchet provides the methods necessary to establish a new double ratchet session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateReceiverSession

func CalculateReceiverSession(parameters *ReceiverParameters) (*session.KeyPair, error)

CalculateReceiverSession calculates the key agreement for a sender. This should be used when we are receiving a message from someone for the first time.

func CalculateSenderSession

func CalculateSenderSession(parameters *SenderParameters) (*session.KeyPair, error)

CalculateSenderSession calculates the key agreement for a recipient. This should be used when we are trying to send a message to someone for the first time.

func CalculateSymmetricSession

func CalculateSymmetricSession(parameters *SymmetricParameters) (*session.KeyPair, error)

CalculateSymmetricSession calculates the key agreement between two users. This works by both clients exchanging KeyExchange messages to first establish a session. This is useful for establishing a session if both users are online.

Types

type ReceiverParameters

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

ReceiverParameters describes the session parameters if we are receiving a message from someone for the first time. These parameters are used as the basis for deriving a shared secret with the sender.

func NewEmptyReceiverParameters

func NewEmptyReceiverParameters() *ReceiverParameters

NewEmptyReceiverParameters creates an empty structure with the receiver parameters needed to create a session. You should use the `set` functions to set all the necessary keys needed to build a session.

func NewReceiverParameters

func NewReceiverParameters(ourIdentityKey *identity.KeyPair, ourSignedPreKey *ecc.ECKeyPair,
	ourOneTimePreKey *ecc.ECKeyPair, ourRatchetKey *ecc.ECKeyPair,
	theirBaseKey ecc.ECPublicKeyable, theirIdentityKey *identity.Key) *ReceiverParameters

NewReceiverParameters creates a structure with all the keys needed to construct a new session when we are receiving a message from a user for the first time.

func (*ReceiverParameters) OurIdentityKeyPair

func (r *ReceiverParameters) OurIdentityKeyPair() *identity.KeyPair

OurIdentityKeyPair returns the identity key of the receiver.

func (*ReceiverParameters) OurOneTimePreKey

func (r *ReceiverParameters) OurOneTimePreKey() *ecc.ECKeyPair

OurOneTimePreKey returns the one time prekey of the receiver.

func (*ReceiverParameters) OurRatchetKey

func (r *ReceiverParameters) OurRatchetKey() *ecc.ECKeyPair

OurRatchetKey returns the ratchet key of the receiver.

func (*ReceiverParameters) OurSignedPreKey

func (r *ReceiverParameters) OurSignedPreKey() *ecc.ECKeyPair

OurSignedPreKey returns the signed prekey of the receiver.

func (*ReceiverParameters) SetOurIdentityKeyPair

func (r *ReceiverParameters) SetOurIdentityKeyPair(ourIdentityKey *identity.KeyPair)

SetOurIdentityKeyPair sets the identity key of the receiver.

func (*ReceiverParameters) SetOurOneTimePreKey

func (r *ReceiverParameters) SetOurOneTimePreKey(ourOneTimePreKey *ecc.ECKeyPair)

SetOurOneTimePreKey sets the one time prekey of the receiver.

func (*ReceiverParameters) SetOurRatchetKey

func (r *ReceiverParameters) SetOurRatchetKey(ourRatchetKey *ecc.ECKeyPair)

SetOurRatchetKey sets the ratchet key of the receiver.

func (*ReceiverParameters) SetOurSignedPreKey

func (r *ReceiverParameters) SetOurSignedPreKey(ourSignedPreKey *ecc.ECKeyPair)

SetOurSignedPreKey sets the signed prekey of the receiver.

func (*ReceiverParameters) SetTheirBaseKey

func (r *ReceiverParameters) SetTheirBaseKey(theirBaseKey ecc.ECPublicKeyable)

SetTheirBaseKey sets the base key of the sender.

func (*ReceiverParameters) SetTheirIdentityKey

func (r *ReceiverParameters) SetTheirIdentityKey(theirIdentityKey *identity.Key)

SetTheirIdentityKey sets the identity key of the sender.

func (*ReceiverParameters) TheirBaseKey

func (r *ReceiverParameters) TheirBaseKey() ecc.ECPublicKeyable

TheirBaseKey returns the base key of the sender.

func (*ReceiverParameters) TheirIdentityKey

func (r *ReceiverParameters) TheirIdentityKey() *identity.Key

TheirIdentityKey returns the identity key of the sender.

type SenderParameters

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

SenderParameters describes the session parameters if we are sending the recipient a message for the first time. These parameters are used as the basis for deriving a shared secret with a recipient.

func NewEmptySenderParameters

func NewEmptySenderParameters() *SenderParameters

NewEmptySenderParameters creates an empty structure with the sender parameters needed to create a session. You should use the `set` functions to set all the necessary keys needed to build a session.

func NewSenderParameters

func NewSenderParameters(ourIdentityKey *identity.KeyPair, ourBaseKey *ecc.ECKeyPair,
	theirIdentityKey *identity.Key, theirSignedPreKey ecc.ECPublicKeyable,
	theirRatchetKey ecc.ECPublicKeyable, theirOneTimePreKey ecc.ECPublicKeyable) *SenderParameters

NewSenderParameters creates a structure with all the keys needed to construct a new session when we are sending a message to a recipient for the first time.

func (*SenderParameters) OurBaseKey

func (s *SenderParameters) OurBaseKey() *ecc.ECKeyPair

OurBaseKey returns the base ECC key pair of the sender.

func (*SenderParameters) OurIdentityKey

func (s *SenderParameters) OurIdentityKey() *identity.KeyPair

OurIdentityKey returns the identity key pair of the sender.

func (*SenderParameters) SetOurBaseKey

func (s *SenderParameters) SetOurBaseKey(ourBaseKey *ecc.ECKeyPair)

SetOurBaseKey sets the base ECC key pair of the sender.

func (*SenderParameters) SetOurIdentityKey

func (s *SenderParameters) SetOurIdentityKey(ourIdentityKey *identity.KeyPair)

SetOurIdentityKey sets the identity key pair of the sender.

func (*SenderParameters) SetTheirIdentityKey

func (s *SenderParameters) SetTheirIdentityKey(theirIdentityKey *identity.Key)

SetTheirIdentityKey sets the identity public key of the receiver.

func (*SenderParameters) SetTheirOneTimePreKey

func (s *SenderParameters) SetTheirOneTimePreKey(theirOneTimePreKey ecc.ECPublicKeyable)

SetTheirOneTimePreKey sets the receiver's one time prekey.

func (*SenderParameters) SetTheirRatchetKey

func (s *SenderParameters) SetTheirRatchetKey(theirRatchetKey ecc.ECPublicKeyable)

SetTheirRatchetKey sets the receiver's ratchet key.

func (*SenderParameters) SetTheirSignedPreKey

func (s *SenderParameters) SetTheirSignedPreKey(theirSignedPreKey ecc.ECPublicKeyable)

SetTheirSignedPreKey sets the signed pre key of the receiver.

func (*SenderParameters) TheirIdentityKey

func (s *SenderParameters) TheirIdentityKey() *identity.Key

TheirIdentityKey returns the identity public key of the receiver.

func (*SenderParameters) TheirOneTimePreKey

func (s *SenderParameters) TheirOneTimePreKey() ecc.ECPublicKeyable

TheirOneTimePreKey returns the receiver's one time prekey.

func (*SenderParameters) TheirRatchetKey

func (s *SenderParameters) TheirRatchetKey() ecc.ECPublicKeyable

TheirRatchetKey returns the receiver's ratchet key.

func (*SenderParameters) TheirSignedPreKey

func (s *SenderParameters) TheirSignedPreKey() ecc.ECPublicKeyable

TheirSignedPreKey returns the signed pre key of the receiver.

type SymmetricParameters

type SymmetricParameters struct {
	OurBaseKey         *ecc.ECKeyPair
	OurRatchetKey      *ecc.ECKeyPair
	OurIdentityKeyPair *identity.KeyPair

	TheirBaseKey     ecc.ECPublicKeyable
	TheirRatchetKey  ecc.ECPublicKeyable
	TheirIdentityKey *identity.Key
}

SymmetricParameters describes the session parameters for sessions where both users are online, which doesn't use prekeys for setup.

Jump to

Keyboard shortcuts

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