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 ¶
const ( PartyPrefix = "ed25519:" CurvePrefix = "curve25519:" )
PartyPrefix and CurvePrefix tag the text form of an Ed25519 party key and a Curve25519 public key.
const DeviceID = 1
DeviceID is the libsignal device id of every party: a fleet is one device.
const FormatVersion = 1
FormatVersion is the version of the root, identity and party keys files.
const InitialPrekeys = 100
InitialPrekeys is how many one-time prekeys init generates.
Variables ¶
var Serializer = serialize.NewProtoBufSerializer()
Serializer is the libsignal serializer peer uses for records and wire messages.
Functions ¶
func ParseCurve ¶
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 ¶
ParsePartyID decodes a party id into its root public key.
Types ¶
type Identity ¶
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 ¶
GenerateIdentity makes a new identity key pair and registrationId for party.
func (*Identity) MarshalJSON ¶
MarshalJSON writes the identity file.
func (*Identity) UnmarshalJSON ¶
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 ¶
GeneratePartyKeys makes signed prekey 1, signed by the identity key, and one-time prekeys 1..n.
func (*PartyKeys) MarshalJSON ¶
MarshalJSON writes the party keys record.
func (*PartyKeys) RotateSignedPrekey ¶
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 ¶
SignedPrekeyIssued is when the current signed prekey was generated.
func (*PartyKeys) UnmarshalJSON ¶
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 (*Root) MarshalJSON ¶
MarshalJSON writes the root file.
func (*Root) UnmarshalJSON ¶
UnmarshalJSON reads the root file.