card

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: GPL-3.0 Imports: 8 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 card builds, signs and verifies a party's card.

A card travels and is stored as its exact bytes plus a detached Ed25519 signature by the party's root key. The signature is checked over the raw bytes before any parsing, so no JSON canonicalization is needed: a card whose signature fails is never parsed.

Unknown fields follow SSH certificates: a card names in its top-level "critical" list the fields a reader must understand; a critical field this reader does not know refuses the whole card, and any other unknown field is ignored. The rule applies to top-level fields.

Index

Constants

View Source
const Version = 1

Version is the card format version this reader understands.

Variables

View Source
var (
	ErrSignature       = errors.New("card: root signature does not verify")
	ErrCriticalUnknown = errors.New("card: unknown critical field")
	ErrParty           = errors.New("card: party is not the signing root")
)

Errors a reader can match.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID      string   `json:"id"`
	Accepts []string `json:"accepts"`
}

Agent is one agent of the party and the message kinds it accepts.

type Card

type Card struct {
	V      int       `json:"v"`
	Party  string    `json:"party"`
	Keys   []Key     `json:"keys"`
	Agents []Agent   `json:"agents"`
	Relays []string  `json:"relays"`
	Issued time.Time `json:"issued"`
	// Details is the in-channel extension (receiver types, model, policy);
	// absent from the card placed as envelope #0.
	Details json.RawMessage `json:"details,omitempty"`
	// Critical names the top-level fields a reader must understand.
	Critical []string `json:"critical,omitempty"`
}

Card is a party's self-signed description: its root key, its operational keys, its agents and its relays.

func New

func New(id *keys.Identity, pk *keys.PartyKeys, agents []Agent, relays []string, issued time.Time) *Card

New builds a card for a party from its identity and party keys.

func Verify

func Verify(s *Signed, root ed25519.PublicKey) (*Card, error)

Verify checks s against the pinned root public key, then parses it. A card whose signature fails is not parsed.

type Key

type Key struct {
	Identity       string       `json:"identity"`
	RegistrationID uint32       `json:"registrationId"`
	SignedPrekey   SignedPrekey `json:"signedPrekey"`
	From           time.Time    `json:"from"`
	Until          *time.Time   `json:"until"`
}

Key is one operational key bundle; the libsignal device id is always keys.DeviceID.

func (*Key) IdentityKey

func (k *Key) IdentityKey() (*identity.Key, error)

IdentityKey is the key's libsignal identity public key.

func (*Key) Retired

func (k *Key) Retired(at time.Time) bool

Retired reports whether the key's void time has passed — the revocation a rotation card carries (design §3.2): the new identity key, and the old key's until. A retired key signs nothing and opens nothing from then on.

func (*Key) SignedPrekeyPublic

func (k *Key) SignedPrekeyPublic() (ecc.ECPublicKeyable, [64]byte, error)

SignedPrekeyPublic is the signed prekey's public key and its signature.

type Signed

type Signed struct {
	Body []byte
	Sig  []byte
}

Signed is a card as it travels: the exact bytes and the root's detached signature.

func Sign

func Sign(c *Card, root *keys.Root) (*Signed, error)

Sign serializes c and signs the bytes with the root key. c.Party must be the root's id.

type SignedPrekey

type SignedPrekey struct {
	ID  uint32 `json:"id"`
	Pub string `json:"pub"`
	Sig []byte `json:"sig"`
}

SignedPrekey is the public half of a signed prekey and the identity key's XEdDSA signature over its serialized public key.

Jump to

Keyboard shortcuts

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