Documentation ¶
Overview ¶
Package ratchet defines the keys and parameters required to perform the Double Ratchet algorithm to send and receive encrypted messages.
Index ¶
Constants ¶
const ( ChainKeySize = 32 RootKeySize = 32 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AliceParameters ¶
type AliceParameters struct { OurIdentityKeyPair identity.KeyPair OurBaseKeyPair *curve.KeyPair TheirIdentityKey identity.Key TheirSignedPreKey curve.PublicKey TheirOneTimePreKey curve.PublicKey TheirRatchetKey curve.PublicKey }
AliceParameters represents the "Alice" side of the double ratchet algorithm required to perform X3DH.
type BobParameters ¶
type BobParameters struct { OurIdentityKeyPair identity.KeyPair OurSignedPreKeyPair *curve.KeyPair OurOneTimePreKeyPair *curve.KeyPair OurRatchetKeyPair *curve.KeyPair TheirIdentityKey identity.Key TheirBaseKey curve.PublicKey }
BobParameters represents the "Bob" side of the double ratchet algorithm required to perform X3DH.
type ChainKey ¶
type ChainKey struct {
// contains filtered or unexported fields
}
ChainKey represents a sending or receiving chain key used for Symmetric-key ratchet.
func NewChainKey ¶
NewChainKey derives a chain key from the given key and index.
func (ChainKey) MessageKeys ¶
func (c ChainKey) MessageKeys() (MessageKeys, error)
MessageKeys performs a Symmetric-key ratchet step to derive new message keys.
type MessageKeys ¶
type MessageKeys struct {
// contains filtered or unexported fields
}
MessageKeys defines the keys used to encrypt messages.
func DeriveMessageKeys ¶
func DeriveMessageKeys(inputKeyMaterial []byte, counter uint32) (MessageKeys, error)
DeriveMessageKeys derives message keys from the given input material and counter.
The input material is used as the secret for HKDF.
func NewMessageKeys ¶
func NewMessageKeys(cipherKey, macKey, iv []byte, counter uint32) (MessageKeys, error)
NewMessageKeys derives message keys from the given inputs.
func (MessageKeys) CipherKey ¶
func (m MessageKeys) CipherKey() []byte
CipherKey returns a block cipher key.
func (MessageKeys) Counter ¶
func (m MessageKeys) Counter() uint32
Counter returns the corresponding index in the chain.
func (MessageKeys) IV ¶
func (m MessageKeys) IV() []byte
IV returns an initialization vector used for encryption and decryption.
func (MessageKeys) MACKey ¶
func (m MessageKeys) MACKey() []byte
MACKey returns a key used for a MAC function like HMAC.
type RootKey ¶
type RootKey struct {
// contains filtered or unexported fields
}
RootKey is a key used for the root chain in the Double Ratchet algorithm.
func NewRootKey ¶
NewRootKey derives a root key from the given bytes.
func (RootKey) CreateChain ¶
func (r RootKey) CreateChain(ourRatchetKey curve.PrivateKey, theirRatchetKey curve.PublicKey) (RootKey, ChainKey, error)
CreateChain performs a single Diffie-Hellman ratchet step to create a new root key and chain key.