Documentation
¶
Index ¶
- Variables
- type Config
- type IPeer
- type IPeerList
- type KV
- type Peer
- func (p Peer) Art() string
- func (p Peer) Config() (string, map[string]string)
- func (p Peer) Contract()
- func (p Peer) Equal(q Peer) bool
- func (p Peer) Expand()
- func (p Peer) Grip() string
- func (p Peer) MarshalBinary() ([]byte, error)
- func (p Peer) MarshalPEM() ([]byte, error)
- func (p Peer) Nickname() string
- func (p Peer) UnmarshalBinary(b []byte) error
- type PeerList
- type Principal
- func (g *Principal) AddPeer(p Peer) error
- func (g *Principal) Art() string
- func (g *Principal) AsPeer() Peer
- func (g *Principal) Compose(body []byte, headers *delphi.KV, recipient Peer) *delphi.Message
- func (g *Principal) DropPeer(p Peer)
- func (p *Principal) Export() *Config
- func (g *Principal) FromBin(r io.Reader) error
- func (g *Principal) FromPem(r io.Reader) error
- func (g *Principal) HasPeer(p Peer) bool
- func (g *Principal) LoadConfig(c *Config) error
- func (g *Principal) MarshalPEM() ([]byte, error)
- func (g *Principal) Nickname() string
- func (g *Principal) Save(fd afero.File) error
- func (g *Principal) SignConfig(conf *Config) error
- func (g *Principal) ToBin() []byte
- func (g *Principal) UnmarshalPEM(b []byte) error
- func (g *Principal) VerifyConfig(c *Config) error
- func (g *Principal) WithConfigFile(fd afero.File) error
- func (g *Principal) WithRand(randy io.Reader)
- type Serde
- type Verity
Constants ¶
This section is empty.
Variables ¶
var ErrBadHex = errors.New("bad hex")
var ErrBadPem = errors.New("malformed pem")
var ErrNoPrivKey = pear.Defer("no private key")
var ErrNoPubKey = pear.Defer("no public key")
var ErrPeerExists = pear.Defer("peer already exists")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Pub delphi.Key `yaml:"pub" json:"pub" msgpack:"pub"` Props *KV `yaml:"props,omitempty" json:"props,omitempty" msgpack:"props,omitempty"` Peers *PeerList `yaml:"peers,omitempty" json:"peers,omitempty" msgpack:"peers,omitempty"` //File afero.File `yaml:"-" json:"-" msgpack:"-"` Verity *Verity `yaml:"ver" json:"ver" msgpack:"ver"` // contains filtered or unexported fields }
a Config is an object suitable for serializing and storing [Peer]s and key-value pairs
func PrincipalToConfig ¶
type KV ¶
type KV = omap.OrderedMap[string, string]
KV is a key-value store whose keys are ordered, offering deterministic serialization
type Peer ¶
type Peer struct { delphi.Key `msgpack:"pub" json:"pub" yaml:"pub"` Properties *KV `msgpack:"props" json:"props" yaml:"yaml"` }
func (Peer) Grip ¶
a key grip is a string short enough to be recognizable by the human eye and long enough to be reasonably unique
func (Peer) MarshalBinary ¶
func (Peer) MarshalPEM ¶
MarshalPEM marshals a PEM to a Peer.
func (Peer) UnmarshalBinary ¶
type Principal ¶
type Principal struct { delphi.Principal `msgpack:"priv" json:"priv" yaml:"priv"` Props *KV `msgpack:"props" json:"props" yaml:"props"` Peers PeerList `msgpack:"peers" json:"peers" yaml:"peers"` //Config *Config `msgpack:"-" json:"-" yaml:"-"` ConfigFile io.ReadWriter `msgpack:"-" json:"-" yaml:"-"` // contains filtered or unexported fields }
a Principal is a public/private key-pair with some properties, and knowlege of [Peer]s
func NewPrincipal ¶
NewPrincipal creates a new Principal.
func PrincipalFrom ¶
PrincipalFrom assumes binary format, but maybe it should assume PEM
func (*Principal) Art ¶
Art returns the ASCII art representing a public key. It can be used for easy visual identification.
func (*Principal) AsPeer ¶
AsPeer converts a Principal (public and private key) to a Peer (just public key)
func (*Principal) Compose ¶
Compose creates a message for a recipient. It's syntactic sugar for delphi.NewMessage
func (*Principal) LoadConfig ¶
load a config file and attach data to a Principal
func (*Principal) MarshalPEM ¶
MarshalPEM marshals a Principal to PEM format
func (*Principal) SignConfig ¶
SignConfig signs a config calculating a digest, adding a nonce, and producing a signature
func (*Principal) UnmarshalPEM ¶
UnmarshalPEM converts a PEM to a Principal
func (*Principal) VerifyConfig ¶
type Verity ¶
type Verity struct { Nonce []byte `yaml:"nonce" json:"nonce" msgpack:"nonce"` Signature []byte `yaml:"sig" json:"sig" msgpack:"sig"` }
Verity is a struct that holds a signature plus some randomness that was involved in calculating the signature.