Documentation ¶
Index ¶
- Variables
- type Config
- type KV
- type Peer
- 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 *KV, recipient Peer) *delphi.Message
- func (g *Principal) DropPeer(p Peer)
- 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() error
- func (g *Principal) MarshalPEM() ([]byte, error)
- func (g *Principal) Save(fd afero.File) error
- func (g *Principal) SignConfig() error
- func (g *Principal) UnmarshalPEM(b []byte) error
- func (g Principal) VerifyConfig() error
- func (g *Principal) WithConfigFile(fd afero.File) error
- func (g *Principal) WithRand(randy io.Reader)
- type Verity
Constants ¶
This section is empty.
Variables ¶
var ErrBadHex = pear.Defer("bad hex")
var ErrBadPem = pear.Defer("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 { //Priv delphi.Key `yaml:"priv" json:"priv" msgpack:"priv"` Pub delphi.Key `yaml:"pub" json:"pub" msgpack:"pub"` Props *KV `yaml:"props,omitempty" json:"props,omitempty" msgpack:"props,omitempty"` Peers map[delphi.Key]*KV `yaml:"peers,omitempty" json:"peers,omitempty" msgpack:"peers,omitempty"` File afero.File `yaml:"-" json:"-" msgpack:"-"` Verity *Verity `yaml:"ver" json:"ver" msgpack:"ver"` }
a Config is an object suitable for serializing and storing [Peer]s and key-value pairs
func PrincipalToConfig ¶
func (*Config) WithDescriptor ¶
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 map[delphi.Key]Peer `msgpack:"peers" json:"peers" yaml:"peers"` Config *Config `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 ¶
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"` }