tfk

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 4 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
	FormatFeedBamboo
	FormatFeedBendyButt
	FormatFeedFusionIdentity
)

These are the type-format-key feed format values

View Source
const (
	FormatMessageSHA256 uint8 = iota
	FormatMessageGabbyGrove
	FormatMessageCloaked
	FormatMessageBamboo
	FormatMessageMetaFeed
)

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

func IsValidFeedFormat added in v0.4.0

func IsValidFeedFormat(f uint8) bool

IsValidFeedFormat returns true if the passed format is a valid feed format

func IsValidMessageFormat added in v0.4.0

func IsValidMessageFormat(f uint8) bool

IsValidMessageFormat returns true if the passed format is a valid message format

Types

type Feed

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

Feed represents a reference to a feed

func FeedFromRef

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

FeedFromRef creates a new tfk reference for serialization from a plain reference

func (Feed) Feed

func (f Feed) Feed() (refs.FeedRef, error)

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
}

Message represents a reference to a message

func MessageFromRef

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

MessageFromRef creates a new tfk reference for serialization from a plain reference

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, error)

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