peer

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package peer implements peer identity using did:key with ed25519 keys.

did:key is the simplest DID method: the DID itself encodes the public key, so resolution requires no network and no registry. Sufficient for v0.1 (single binary, no inter-Coggo federation). v0.3+ may add did:web.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePublicKey

func DecodePublicKey(did string) ([]byte, error)

DecodePublicKey parses a did:key DID back to its 32-byte ed25519 public key.

func NewDID

func NewDID() (did string, pub, priv []byte, err error)

NewDID generates a fresh ed25519 keypair and the corresponding did:key DID.

func NewPeer

func NewPeer(name, description string) (*types.Peer, error)

NewPeer constructs a fresh Peer with default settings. The caller assigns the human-readable name and persists the result.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the in-memory + on-disk index of peers hosted by this binary. Backed by a single peers.json file under the data dir; rewritten atomically.

Per-peer state (events, entities) lives in the Store, not here. The Registry is the directory of identities and their settings only.

func Open

func Open(dataDir string) (*Registry, error)

Open loads the registry from disk, creating an empty file if missing.

func (*Registry) Add

func (r *Registry) Add(p *types.Peer) error

Add registers a new peer. Fails if name or DID is already taken.

func (*Registry) ByDID

func (r *Registry) ByDID(did string) *types.Peer

ByDID returns the peer with the given DID, or nil.

func (*Registry) ByName

func (r *Registry) ByName(name string) *types.Peer

ByName returns the peer registered under name, or nil.

func (*Registry) List

func (r *Registry) List() []*types.Peer

List returns all peers in deterministic order (by name).

func (*Registry) Rename

func (r *Registry) Rename(oldName, newName string) error

Rename changes a peer's human-readable name.

func (*Registry) Resolve

func (r *Registry) Resolve(nameOrDID string) (*types.Peer, error)

Resolve accepts either a peer name or a DID and returns the peer.

func (*Registry) UpdateSettings

func (r *Registry) UpdateSettings(name string, s types.PeerSettings) error

UpdateSettings replaces the settings for a peer (looked up by name).

Jump to

Keyboard shortcuts

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