Documentation
¶
Overview ¶
Package netkeys holds a network's Ed25519 signing identity and its durable trust store of pinned peer keys.
v1 has no key rotation: losing or leaking the private key means a new network identity, and every peer has to re-trust it explicitly (`moltnet keys forget <id>` then `moltnet keys trust <id> <fingerprint>`).
Index ¶
- Constants
- Variables
- func DirForConfig(configPath string) string
- type Identity
- type Pin
- type PinStore
- func (s *PinStore) BindPairing(pairingID, networkID string) error
- func (s *PinStore) Forget(networkID string) (bool, error)
- func (s *PinStore) ForgetExact(pin Pin) error
- func (s *PinStore) ForgetPairing(pairingID string) error
- func (s *PinStore) List() ([]Pin, error)
- func (s *PinStore) Lookup(networkID string) (Pin, bool, error)
- func (s *PinStore) PairingNetworks(pairingID string) ([]string, error)
- func (s *PinStore) PinKey(pin Pin) (Pin, error)
- func (s *PinStore) PinKeyCreated(pin Pin) (Pin, bool, error)
Constants ¶
const ( PinSourceInvite = "invite" PinSourcePairing = "pairing" PinSourceOperator = "operator" // PinSourceRoom is a key a room home introduced (trust introduced). PinSourceRoom = "room" )
Pin sources.
Variables ¶
var ErrPinConflict = errors.New("network is already pinned to a different key")
ErrPinConflict means a network id is already pinned to a different key. It is never resolved automatically: an operator must forget the old pin.
Functions ¶
func DirForConfig ¶
DirForConfig is the keys directory for a network config file.
Types ¶
type Identity ¶
type Identity struct {
// contains filtered or unexported fields
}
Identity is a network's signing key. It never exposes the private key: there is no accessor, and String/JSON render only public data.
func LoadIdentity ¶
LoadIdentity loads an existing dir/network.key without creating one.
func LoadOrCreateIdentity ¶
LoadOrCreateIdentity loads dir/network.key, creating it on first use. Creation is exclusive, so a server and a CLI racing on first start agree on one key. created reports whether this call generated it.
func NewEphemeralIdentity ¶
NewEphemeralIdentity generates an in-memory identity for servers with no durable keys directory (and for tests).
func (*Identity) Fingerprint ¶
func (*Identity) MarshalJSON ¶
func (*Identity) Public ¶
func (i *Identity) Public() protocol.NetworkIdentity
Public is the identity as published on GET /v1/network.
type Pin ¶
type Pin struct {
NetworkID string `json:"network_id"`
Fingerprint string `json:"fingerprint"`
PublicKey string `json:"public_key,omitempty"`
// Trust is protocol.KeyTrustVerified, KeyTrustIntroduced or
// KeyTrustUnconfirmed.
Trust string `json:"trust"`
// Source records how the pin was learned: invite, pairing, operator.
Source string `json:"source"`
// SourceID is the pairing id for invite/pairing pins.
SourceID string `json:"source_id,omitempty"`
// IntroducedBy is the vouching room home's network id (chunk B).
IntroducedBy string `json:"introduced_by,omitempty"`
PinnedAt time.Time `json:"pinned_at"`
}
Pin binds a human-readable network id to a key fingerprint.
type PinStore ¶
type PinStore struct {
// contains filtered or unexported fields
}
PinStore is the durable trust store. With an empty path it is in-memory (tests and keyless servers) but enforces the same rules.
func NewMemoryPinStore ¶
func NewMemoryPinStore() *PinStore
func OpenPinStore ¶
OpenPinStore uses dir/pins.json; the file is created on the first pin.
func (*PinStore) BindPairing ¶
BindPairing records that pairingID's credential speaks for networkID.
func (*PinStore) ForgetExact ¶
ForgetExact removes networkID's pin only if it is still exactly pin (same key, trust, source and time), undoing one PinKeyCreated and nothing newer.
func (*PinStore) ForgetPairing ¶
ForgetPairing drops every binding of pairingID (its credential is gone).
func (*PinStore) Lookup ¶
Lookup reads the current pin for networkID. File-backed stores re-read the file so `moltnet keys trust/forget` take effect without a restart.
func (*PinStore) PairingNetworks ¶
PairingNetworks returns the networks pairing pairingID's credential has spoken for: its durable bindings (which survive a pin being re-sourced, e.g. by `moltnet keys trust`) plus any pin still sourced through it.
func (*PinStore) PinKey ¶
PinKey records pin unless the network is already pinned. Pinning the same fingerprint again returns the stored pin, upgrading it to verified when the new pin is verified. A different fingerprint is ErrPinConflict, except that a verified pin replaces an unconfirmed or introduced one.