chain

package
v0.0.0-...-fb2b840 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package chain provides chain keys used in double ratchet sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

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

Key is used for generating message keys. This key "ratchets" every time a message key is generated. Every time the chain key ratchets forward, its index increases by one.

func NewKey

func NewKey(kdf kdf.HKDF, key []byte, index uint32) *Key

NewKey returns a new chain key with the given kdf, key, and index

func NewKeyFromStruct

func NewKeyFromStruct(structure *KeyStructure, kdf kdf.HKDF) *Key

NewKeyFromStruct will return a chain key built from the given structure.

func (*Key) BaseMaterial

func (c *Key) BaseMaterial(seed []byte) []byte

BaseMaterial uses hmac to derive the base material used in the key derivation function for a new key.

func (*Key) Current

func (c *Key) Current() *Key

Current returns the current ChainKey struct.

func (*Key) Index

func (c *Key) Index() uint32

Index returns how many times the ChainKey has been "ratcheted" forward.

func (*Key) Key

func (c *Key) Key() []byte

Key returns the ChainKey's key material.

func (*Key) MessageKeys

func (c *Key) MessageKeys() *message.Keys

MessageKeys returns message keys, which includes the cipherkey, mac, iv, and index.

func (*Key) NextKey

func (c *Key) NextKey() *Key

NextKey uses the key derivation function to generate a new ChainKey.

func (*Key) SetIndex

func (c *Key) SetIndex(index uint32)

SetIndex sets how many times the ChainKey has been "ratcheted" forward.

func (*Key) SetKey

func (c *Key) SetKey(key []byte)

SetKey will set the ChainKey's key material.

type KeyStructure

type KeyStructure struct {
	Key   []byte
	Index uint32
}

KeyStructure is a serializeable structure for chain keys.

func NewStructFromKey

func NewStructFromKey(key *Key) *KeyStructure

NewStructFromKey will return a chain key structure for serialization.

Jump to

Keyboard shortcuts

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