prekey

package
v0.0.0-...-97e1097 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package prekey defines a pre-key and signed pre-key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	RegistrationID        uint32
	DeviceID              address.DeviceID
	PreKeyID              *ID
	PreKeyPublic          curve.PublicKey
	SignedPreKeyID        ID
	SignedPreKeyPublic    curve.PublicKey
	SignedPreKeySignature []byte
	IdentityKey           identity.Key
}

Bundle represents a pre-key bundle as defined by the X3DH protocol.

See https://signal.org/docs/specifications/x3dh/#sending-the-initial-message for more information.

type ID

type ID uint32

ID represents a pre-key identifier.

func (ID) String

func (i ID) String() string

type PreKey

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

PreKey represents a public pre-key.

func NewPreKey

func NewPreKey(id ID, key *curve.KeyPair) *PreKey

NewPreKey creates a new pre-key.

func (*PreKey) KeyPair

func (s *PreKey) KeyPair() (*curve.KeyPair, error)

KeyPair returns the pre-key's public/private key pair.

type SignedPreKey

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

SignedPreKey represents a public signed pre-key.

func NewSigned

func NewSigned(id ID, timestamp uint64, key *curve.KeyPair, signature []byte) *SignedPreKey

NewSigned creates a new signed pre-key.

func (*SignedPreKey) KeyPair

func (s *SignedPreKey) KeyPair() (*curve.KeyPair, error)

KeyPair returns the signed pre-key's public/private key pair.

type SignedStore

type SignedStore interface {
	// Load fetches the signed pre-key associated with the id from the store.
	Load(ctx context.Context, id ID) (*SignedPreKey, bool, error)
	// Store stores the signed pre-key associated with the given ID in the store.
	Store(ctx context.Context, id ID, record *SignedPreKey) error
}

SignedStore defines a signed pre-key store.

func NewInMemSignedStore

func NewInMemSignedStore() SignedStore

NewInMemSignedStore creates a new in-memory signed pre-key store.

type Store

type Store interface {
	// Load fetches the pre-key associated with the id from the store.
	Load(ctx context.Context, id ID) (*PreKey, bool, error)
	// Store stores the pre-key associated with the given ID in the store.
	Store(ctx context.Context, id ID, preKey *PreKey) error
	// Delete removes the pre-key entry identified by the given ID from the store.
	Delete(ctx context.Context, id ID) error
}

Store defines a pre-key store.

func NewInMemStore

func NewInMemStore() Store

NewInMemStore creates a new in-memory pre-key store.

Jump to

Keyboard shortcuts

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