ratchet

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: ISC Imports: 16 Imported by: 0

Documentation

Overview

Package ratchet implements the axolotl ratchet, by Trevor Perrin. See https://github.com/trevp/axolotl/wiki.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnmarshal = errors.New("failed to unmarshal")

Functions

func EncryptedSize

func EncryptedSize(msgSize int) int

EncryptedSize returns the estimated size for an encrypted ratched message, given the specified payload msg size.

Types

type KeyExchange

type KeyExchange struct {
	Public []byte                               `json:"public"`
	Cipher zkidentity.FixedSizeSntrupCiphertext `json:"cipher"`
}

type RVPoint

type RVPoint = zkidentity.ShortID

type Ratchet

type Ratchet struct {
	MyPrivateKey   *zkidentity.FixedSizeSntrupPrivateKey
	TheirPublicKey *zkidentity.FixedSizeSntrupPublicKey
	// contains filtered or unexported fields
}

Ratchet contains the per-contact, crypto state.

func New

func New(rand io.Reader) *Ratchet

func (*Ratchet) CompleteKeyExchange

func (r *Ratchet) CompleteKeyExchange(kx *KeyExchange, alice bool) error

CompleteKeyExchange takes a KeyExchange message from the other party and establishes the ratchet.

func (*Ratchet) Decrypt

func (r *Ratchet) Decrypt(ciphertext []byte) ([]byte, error)

func (*Ratchet) DiskState

func (r *Ratchet) DiskState(lifetime time.Duration) *disk.RatchetState

func (*Ratchet) Encrypt

func (r *Ratchet) Encrypt(out, msg []byte) ([]byte, error)

Encrypt acts like append() but appends an encrypted version of msg to out.

func (*Ratchet) FillKeyExchange

func (r *Ratchet) FillKeyExchange(kx *KeyExchange) error

FillKeyExchange sets elements of kx with key exchange information from the ratchet.

func (*Ratchet) LastEncDecTimes added in v0.1.4

func (r *Ratchet) LastEncDecTimes() (time.Time, time.Time)

func (*Ratchet) NbSavedKeys added in v0.1.4

func (r *Ratchet) NbSavedKeys() int

NbSavedKeys returns the total number of saved keys.

func (*Ratchet) RecvRendezvous

func (r *Ratchet) RecvRendezvous() (RVPoint, RVPoint)

func (*Ratchet) RecvRendezvousPlainText

func (r *Ratchet) RecvRendezvousPlainText() (string, string)

func (*Ratchet) SendRendezvous

func (r *Ratchet) SendRendezvous() RVPoint

func (*Ratchet) SendRendezvousPlainText

func (r *Ratchet) SendRendezvousPlainText() string

func (*Ratchet) Unmarshal

func (r *Ratchet) Unmarshal(s *disk.RatchetState) error

func (*Ratchet) WillRatchet added in v0.1.4

func (r *Ratchet) WillRatchet() bool

WillRatchet returns whether the next message sent will cause a ratchet op.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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