gork

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 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 = errors.New("bad hex")
View Source
var ErrBadPem = errors.New("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 {
	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 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) Hydrate

func (c *Config) Hydrate(p *Principal)

Hydrate fills a Config with information from a Principal

func (*Config) Read

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

func (Config) Verify added in v0.0.2

func (c Config) Verify(p Principal) (bool, error)

func (*Config) Write

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

type IPeer added in v0.0.2

type IPeer interface {
	Serde
	Id() []byte
	Key() delphi.Key
	Equal(IPeer) bool
}

type IPeerList added in v0.0.2

type IPeerList interface {
	Serde
	MarshalJSON() ([]byte, error)
	Get(k delphi.Key) (Peer, bool)
	Set(p Peer) bool
	Len() int
}

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 NewPeer

func NewPeer(b []byte) Peer

func (Peer) Art

func (p Peer) Art() string

Art returns ASCII art for a Peer

func (Peer) Config

func (p Peer) Config() (string, map[string]string)

func (Peer) Contract

func (p Peer) Contract()

Contract deletes inferred keys

func (Peer) Equal

func (p Peer) Equal(q Peer) bool

func (Peer) Expand

func (p Peer) Expand()

Expand sets inferred properties

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) Nickname

func (p Peer) Nickname() string

func (Peer) UnmarshalBinary

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

type PeerList

type PeerList []Peer

func (PeerList) MarshalJSON

func (pl PeerList) MarshalJSON() ([]byte, error)

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

func NewPrincipal(randy io.Reader, m map[string]string, f afero.File) 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 *delphi.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) Export

func (p *Principal) Export() *Config

Export produces a *Config from a *Principal

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(c *Config) 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) Nickname added in v0.0.3

func (g *Principal) Nickname() string

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(conf *Config) error

SignConfig signs a config calculating a digest, adding a nonce, and producing a signature

func (*Principal) ToBin

func (g *Principal) ToBin() []byte

func (*Principal) UnmarshalPEM

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

UnmarshalPEM converts a PEM to a Principal

func (*Principal) VerifyConfig

func (g *Principal) VerifyConfig(c *Config) error

func (*Principal) WithConfigFile

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

func (*Principal) WithRand

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

type Serde added in v0.0.2

type Serde interface {
	Serialize() []byte
	Deserialize(b []byte) error
}

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.

func (*Verity) MarshalJSON

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

func (*Verity) UnmarshalJSON

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

Directories

Path Synopsis
cmd
goracle command
goracled command
shunt command

Jump to

Keyboard shortcuts

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