keys

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: GPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package keys generates and stores a party's keys: the cold Ed25519 root key that signs cards, the identity key pair with its registrationId (the identity file, replicated to every fleet host), and the party keys record holding the signed prekey and one-time prekeys.

Index

Constants

View Source
const (
	PartyPrefix = "ed25519:"
	CurvePrefix = "curve25519:"
)

PartyPrefix and CurvePrefix tag the text form of an Ed25519 party key and a Curve25519 public key.

View Source
const DeviceID = 1

DeviceID is the libsignal device id of every party: a fleet is one device.

View Source
const FormatVersion = 1

FormatVersion is the version of the root, identity and party keys files.

View Source
const InitialPrekeys = 100

InitialPrekeys is how many one-time prekeys init generates.

Variables

Serializer is the libsignal serializer peer uses for records and wire messages.

Functions

func CurveText

func CurveText(pub [32]byte) string

CurveText is the text form of a Curve25519 public key.

func ParseCurve

func ParseCurve(s string) ([32]byte, error)

ParseCurve decodes the text form of a Curve25519 public key. It refuses any length but 32 and the all-zero point: the library zero-pads short keys and does not reject an all-zero DH result.

func ParsePartyID

func ParsePartyID(s string) (ed25519.PublicKey, error)

ParsePartyID decodes a party id into its root public key.

func PartyID

func PartyID(pub ed25519.PublicKey) string

PartyID is the text form of a party's root public key: the party's address.

Types

type Identity

type Identity struct {
	Party          ed25519.PublicKey
	KeyPair        *identity.KeyPair
	RegistrationID uint32
}

Identity is the content of the identity file: the party it belongs to, the libsignal identity key pair and the registrationId. It is the one secret replicated to every fleet host (sops-nix renders it as a plain file).

func GenerateIdentity

func GenerateIdentity(party ed25519.PublicKey) (*Identity, error)

GenerateIdentity makes a new identity key pair and registrationId for party.

func (*Identity) MarshalJSON

func (id *Identity) MarshalJSON() ([]byte, error)

MarshalJSON writes the identity file.

func (*Identity) PublicKey

func (id *Identity) PublicKey() [32]byte

PublicKey is the raw 32-byte identity public key.

func (*Identity) UnmarshalJSON

func (id *Identity) UnmarshalJSON(b []byte) error

UnmarshalJSON reads the identity file.

type PartyKeys

type PartyKeys struct {
	SignedPrekey *record.SignedPreKey
	// PreviousSignedPrekey is the signed prekey the last rotation replaced,
	// nil before the first rotation. A peer that built its session from the
	// card announcing it may not have sent its first message yet, so the key
	// opens that message until the next rotation retires it.
	PreviousSignedPrekey *record.SignedPreKey
	Prekeys              []*record.PreKey
	// NextPrekeyID is the id the next generated one-time prekey takes.
	NextPrekeyID uint32
}

PartyKeys is the party keys record: the current signed prekey, the one it replaced, and the unused one-time prekeys. It is shared by every fleet host through the store.

func GeneratePartyKeys

func GeneratePartyKeys(id *Identity, n int) (*PartyKeys, error)

GeneratePartyKeys makes signed prekey 1, signed by the identity key, and one-time prekeys 1..n.

func (*PartyKeys) MarshalJSON

func (pk *PartyKeys) MarshalJSON() ([]byte, error)

MarshalJSON writes the party keys record.

func (*PartyKeys) RotateSignedPrekey

func (pk *PartyKeys) RotateSignedPrekey(id *Identity) error

RotateSignedPrekey replaces the signed prekey with a fresh one under the next id, signed by the identity key (design §3.2: serve rotates it, no human), and keeps the replaced one as PreviousSignedPrekey. The caller commits the record, then announces the new key with the card.

func (*PartyKeys) SignedPrekeyIssued

func (pk *PartyKeys) SignedPrekeyIssued() time.Time

SignedPrekeyIssued is when the current signed prekey was generated.

func (*PartyKeys) UnmarshalJSON

func (pk *PartyKeys) UnmarshalJSON(b []byte) error

UnmarshalJSON reads the party keys record.

type Root

type Root struct {
	Key ed25519.PrivateKey
}

Root is the cold root key. It signs cards and nothing else; it lives off the fleet.

func GenerateRoot

func GenerateRoot() (*Root, error)

GenerateRoot makes a new root key.

func (*Root) MarshalJSON

func (r *Root) MarshalJSON() ([]byte, error)

MarshalJSON writes the root file.

func (*Root) Public

func (r *Root) Public() ed25519.PublicKey

Public is the root public key, the party's id.

func (*Root) UnmarshalJSON

func (r *Root) UnmarshalJSON(b []byte) error

UnmarshalJSON reads the root file.

Jump to

Keyboard shortcuts

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