gork

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 15 Imported by: 0

README

gork

gork is a re-write of go-oracle

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadHex = pear.Defer("bad hex")
View Source
var ErrBadPem = pear.Defer("malformed pem")
View Source
var ErrNoPrivKey = pear.Defer("no private key")
View Source
var ErrNoPubKey = pear.Defer("no public key")
View Source
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 NewConfig

func NewConfig() *Config

func PrincipalToConfig

func PrincipalToConfig(p Principal) Config

func (*Config) Digest

func (c *Config) Digest() (digest []byte, err error)

produce a digest, for signing

func (*Config) Read

func (c *Config) Read(b []byte) (int, error)

func (*Config) WithDescriptor

func (c *Config) WithDescriptor(f afero.File)

func (*Config) Write

func (c *Config) Write(b []byte) (int, error)

type KV

KV is a key-value store whose keys are ordered, offering deterministic serialization

func NewKV

func NewKV() *KV

type Peer

type Peer struct {
	delphi.Key `msgpack:"pub" json:"pub" yaml:"pub"`
	Properties *KV `msgpack:"props" json:"props" yaml:"yaml"`
}

func (Peer) Art

func (p Peer) Art() string

Art returns ASCII art for a Peer

func (Peer) Equal

func (p Peer) Equal(q Peer) bool

func (Peer) Grip

func (p Peer) Grip() string

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 (p Peer) MarshalBinary() ([]byte, error)

func (Peer) MarshalPEM

func (p Peer) MarshalPEM() ([]byte, error)

MarshalPEM marshals a PEM to a Peer.

func (Peer) UnmarshalBinary

func (p Peer) UnmarshalBinary(b []byte) error

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

func NewPrincipal(randy io.Reader, m map[string]string) Principal

NewPrincipal creates a new Principal.

func PrincipalFrom

func PrincipalFrom(r io.Reader) (*Principal, error)

PrincipalFrom assumes binary format, but maybe it should assume PEM

func (*Principal) AddPeer

func (g *Principal) AddPeer(p Peer) error

AddPeer adds a Peer to a Principal's address book.

func (Principal) Art

func (g Principal) Art() string

Art returns the ASCII art representing a public key. It can be used for easy visual identification.

func (*Principal) AsPeer

func (g *Principal) AsPeer() Peer

AsPeer converts a Principal (public and private key) to a Peer (just public key)

func (Principal) Compose

func (g Principal) Compose(body []byte, headers *KV, recipient Peer) *delphi.Message

Compose creates a message for a recipient. It's syntactic sugar for delphi.NewMessage

func (*Principal) DropPeer

func (g *Principal) DropPeer(p Peer)

DropPeer makes a Principal forget a Peer.

func (*Principal) FromBin

func (g *Principal) FromBin(r io.Reader) error

func (*Principal) FromPem

func (g *Principal) FromPem(r io.Reader) error

func (*Principal) HasPeer

func (g *Principal) HasPeer(p Peer) bool

HasPeer returns true if the Principal has knowlege of that Peer

func (*Principal) LoadConfig

func (g *Principal) LoadConfig() error

load a config file and attach data to a Principal

func (*Principal) MarshalPEM

func (g *Principal) MarshalPEM() ([]byte, error)

MarshalPEM marshals a Principal to PEM format

func (*Principal) Save

func (g *Principal) Save(fd afero.File) error

Save writes the Principal's Peers and custom properties to a config file

func (*Principal) SignConfig

func (g *Principal) SignConfig() error

func (*Principal) UnmarshalPEM

func (g *Principal) UnmarshalPEM(b []byte) error

UnmarshalPEM converts a PEM to a Principal

func (Principal) VerifyConfig

func (g Principal) VerifyConfig() error

func (*Principal) WithConfigFile

func (g *Principal) WithConfigFile(fd afero.File) error

func (*Principal) WithRand

func (g *Principal) WithRand(randy io.Reader)

type Verity

type Verity struct {
	Nonce     []byte `yaml:"nonce" json:"nonce" msgpack:"nonce"`
	Signature []byte `yaml:"sig" json:"sig" msgpack:"sig"`
}

func (*Verity) MarshalJSON

func (v *Verity) MarshalJSON() ([]byte, error)

func (*Verity) UnmarshalJSON

func (v *Verity) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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