Documentation ¶
Overview ¶
Package ratchet implements a ratcheting algorithm to generate keypairs for curve25519, using SHA256.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidDuration signifies that a given duration was invalid, that is smaller than 1. ErrInvalidDuration = errors.New("ratchet: invalid duration") // ErrNoService signifies that attempting to send to a close service will fail. ErrNoService = errors.New("ratchet: ratchet fountain service stopped") // ErrRatchetNotFound signifies that a secret was requested that refers to a ratchet state that is not current. ErrRatchetNotFound = errors.New("ratchet: ratchet not found") )
Functions ¶
This section is empty.
Types ¶
type Fountain ¶
type Fountain struct {
// contains filtered or unexported fields
}
Fountain is a ratchet with timing information, that is: When did a ratchet start, and how often does it update.
func NewFountain ¶
NewFountain returns a new Fountain for ratchets, it creates a new underlying ratchet, sets the start date to now, and sets the duration. Returns nil on error. Service MUST be started.
func (*Fountain) StartService ¶
func (f *Fountain) StartService()
StartService starts the ratcheting services.
func (*Fountain) Unmarshall ¶
Unmarshall a fountain from byte slice, returns nil on error. Service MUST be started.
type PreGenerator ¶
type PreGenerator struct {
// contains filtered or unexported fields
}
PreGenerator is a fountain pregenerator.
func NewPregeneratorFromFountain ¶
func NewPregeneratorFromFountain(f *Fountain, pregenInterval int64) *PreGenerator
NewPregeneratorFromFountain creates a new PreGenerator from a fountain. Use only when creating a new fountain. Use UnmarshallGenerator when unmarshalling.
func (*PreGenerator) Generate ¶
func (pg *PreGenerator) Generate() *types.RatchetList
Generate new ratchet states.
func (*PreGenerator) Marshall ¶
func (pg *PreGenerator) Marshall() []byte
Marshall the PreGenerator.
func (*PreGenerator) Unmarshall ¶
func (pg *PreGenerator) Unmarshall(f *Fountain, d []byte) *PreGenerator
Unmarshall a pregenerator from bytes and the fountain. Return nil on error.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring contains three ratchets, one current, one past, one future.
func NewRatchetRing ¶
NewRatchetRing returns a new, possibly filled, RatchetRing. pastStep is the expected counter value for the past value. Operates on a copy of ratchet.
func (*Ring) Current ¶
Current returns a copy of the current ratchet state for marshalling. The past state will be lost in marshalling.
func (*Ring) CurrentStep ¶
CurrentStep returns the counter of the current ratchet.
type SecretFunc ¶
SecretFunc is a function that returns a secret for a ratchet key.
type State ¶
type State struct { PublicKey [32]byte // Curve25519 public key. // contains filtered or unexported fields }
State contains the static and dynamic elements of the ratchet.
func NewRatchet ¶
NewRatchet creates a new ratchet state from a random source.
func (*State) SharedSecret ¶
SharedSecret creates a shared secret from the RatchetKey and a curve25519 public key (in) by multiplying RatchetKey and with in, and drawing the sha256 of the result.
func (*State) Unmarshall ¶
Unmarshall a ratchet state, returns nil on error.