tfk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tfk implements the type-format-key encoding for SSB references.

See https://github.com/ssbc/envelope-spec/ ... encoding/tfk.md

Index

Constants

View Source
const (
	TypeFeed uint8 = iota
	TypeMessage
	TypeBlob
	TypeDiffieHellmanKey
)

Type are the type-format-key type values

View Source
const (
	FormatFeedEd25519 uint8 = iota
	FormatFeedGabbyGrove
)

These are the type-format-key feed format values

View Source
const (
	FormatMessageSHA256 uint8 = iota
	FormatMessageGabbyGrove
)

These are the type-format-key message format values

Variables

View Source
var (
	ErrTooShort        = errors.New("ssb/tfk: data too short")
	ErrWrongType       = errors.New("ssb/tfk: unexpected type value")
	ErrUnhandledFormat = errors.New("ssb/tfk: unhandled format value")
)

Common errors

Functions

func Encode

func Encode(r refs.Ref) ([]byte, error)

Encode returns type-format-key bytes for supported references. Currently only *refs.MessageRef and *refs.FeedRef

Types

type Feed

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

func FeedFromRef

func FeedFromRef(r *refs.FeedRef) (*Feed, error)

func (Feed) Feed

func (f Feed) Feed() *refs.FeedRef

Feed retruns the ssb-ref type after a successfull unmarshal. It returns a new copy to discourage tampering with the internal values of this reference.

func (*Feed) MarshalBinary

func (f *Feed) MarshalBinary() ([]byte, error)

MarshalBinary returns the type-format-key encoding for a feed.

func (*Feed) UnmarshalBinary

func (f *Feed) UnmarshalBinary(data []byte) error

UnmarshalBinary takes some data, unboxes the t-f-k and does some validity checks to make sure it's an understood feed reference.

type Message

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

func MessageFromRef

func MessageFromRef(r *refs.MessageRef) (*Message, error)

func (*Message) MarshalBinary

func (msg *Message) MarshalBinary() ([]byte, error)

MarshalBinary returns the type-format-key encoding for a message.

func (Message) Message

func (msg Message) Message() *refs.MessageRef

Message retruns the ssb-ref type after a successfull unmarshal. It returns a new copy to discourage tampering with the internal values of this reference.

func (*Message) UnmarshalBinary

func (msg *Message) UnmarshalBinary(data []byte) error

UnmarshalBinary takes some data, unboxes the t-f-k and does some validity checks to make sure it's an understood message reference.

Jump to

Keyboard shortcuts

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