package module
Version: v0.2.1 Latest Latest

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 17 Imported by: 3


Gabby Grove for Go GoDoc status

This strives to be an easier implementation of feeds.

Apart from making it easier to implement this (since the v8 specific JSON quirks go away), the most important improvement over the legacy format is off-chain content. This means only the hash of the content is signed and is committed on the chain.

Replication will stay very similar as well, by grouping metadata and content into the transfer structure, omitting the content if it was delete by the remote.

It will also use the same cryptographic primitives ed25519 and sha256.


See draft-ssb-core-gabbygrove/00/ at the repository for a (hopefully) complete specification.






View Source
const CypherLinkCBORTag = 1050

CypherLinkCBORTag is the CBOR tag for a (ssb) cypherlink from 888 is WIP and currently unused


View Source
var (
	RefAlgoContentGabby refs.RefAlgo = "gabby-v1-content"


func GetCBORHandle

func GetCBORHandle() (h *codec.CborHandle)

GetCBORHandle returns a codec.CborHandle with an extension yet to be registerd for SSB References as CBOR tag XXX


type BinRefExt

type BinRefExt struct{}

func (BinRefExt) ConvertExt

func (x BinRefExt) ConvertExt(v interface{}) interface{}

func (BinRefExt) UpdateExt

func (x BinRefExt) UpdateExt(dst interface{}, src interface{})

type BinaryRef

type BinaryRef struct {
	// contains filtered or unexported fields

BinaryRef defines a binary representation for feed, message, and content references

func NewBinaryRef

func NewBinaryRef(r refs.Ref) (BinaryRef, error)

func (BinaryRef) GetRef

func (ref BinaryRef) GetRef(t RefType) (refs.Ref, error)

func (BinaryRef) MarshalBinary

func (ref BinaryRef) MarshalBinary() ([]byte, error)

func (BinaryRef) MarshalJSON

func (ref BinaryRef) MarshalJSON() ([]byte, error)

func (BinaryRef) MarshalText added in v0.2.1

func (ref BinaryRef) MarshalText() ([]byte, error)

func (BinaryRef) Sigil added in v0.2.1

func (ref BinaryRef) Sigil() string

func (*BinaryRef) Size

func (ref *BinaryRef) Size() int

func (BinaryRef) URI added in v0.2.1

func (ref BinaryRef) URI() string

func (*BinaryRef) UnmarshalBinary

func (ref *BinaryRef) UnmarshalBinary(data []byte) error

func (*BinaryRef) UnmarshalJSON

func (ref *BinaryRef) UnmarshalJSON(data []byte) error

func (*BinaryRef) UnmarshalText added in v0.2.1

func (ref *BinaryRef) UnmarshalText(data []byte) error

type Content

type Content struct {
	Hash BinaryRef
	Size uint16
	Type ContentType

type ContentRef added in v0.2.0

type ContentRef struct {
	// contains filtered or unexported fields

ContentRef defines the hashed content of a message

func NewContentRefFromBytes added in v0.2.0

func NewContentRefFromBytes(b []byte) (ContentRef, error)

func (ContentRef) Algo added in v0.2.0

func (ref ContentRef) Algo() refs.RefAlgo

func (ContentRef) MarshalBinary added in v0.2.0

func (ref ContentRef) MarshalBinary() ([]byte, error)

func (ContentRef) MarshalText added in v0.2.1

func (ref ContentRef) MarshalText() ([]byte, error)

func (ContentRef) ShortRef added in v0.2.0

func (ref ContentRef) ShortRef() string

func (ContentRef) ShortSigil added in v0.2.1

func (ref ContentRef) ShortSigil() string

func (ContentRef) Sigil added in v0.2.1

func (ref ContentRef) Sigil() string

func (ContentRef) String added in v0.2.1

func (ref ContentRef) String() string

func (ContentRef) URI added in v0.2.1

func (ref ContentRef) URI() string

func (*ContentRef) UnmarshalBinary added in v0.2.0

func (ref *ContentRef) UnmarshalBinary(data []byte) error

type ContentType

type ContentType uint
const (
	ContentTypeArbitrary ContentType = iota

type Encoder

type Encoder struct {
	// contains filtered or unexported fields

func NewEncoder

func NewEncoder(author ed25519.PrivateKey) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(sequence uint64, prev BinaryRef, val interface{}) (*Transfer, refs.MessageRef, error)

func (*Encoder) WithHMAC

func (e *Encoder) WithHMAC(in []byte) error

func (*Encoder) WithNowTimestamps added in v0.1.1

func (e *Encoder) WithNowTimestamps(yes bool)

type Event

type Event struct {
	Previous  *BinaryRef // %... Metadata hashsha
	Author    BinaryRef
	Sequence  uint64
	Timestamp int64
	Content   Content

func (Event) MarshalCBOR

func (evt Event) MarshalCBOR() ([]byte, error)

func (*Event) UnmarshalCBOR

func (evt *Event) UnmarshalCBOR(data []byte) error

type RefType

type RefType uint
const (
	RefTypeUndefined RefType = iota

type Transfer

type Transfer struct {
	Event []byte

	Signature []byte
	Content   []byte
	// contains filtered or unexported fields

func (*Transfer) Author

func (tr *Transfer) Author() refs.FeedRef

func (*Transfer) Claimed added in v0.1.1

func (tr *Transfer) Claimed() time.Time

func (*Transfer) ContentBytes

func (tr *Transfer) ContentBytes() []byte

func (Transfer) Key

func (tr Transfer) Key() refs.MessageRef

func (Transfer) MarshalCBOR

func (tr Transfer) MarshalCBOR() ([]byte, error)

func (*Transfer) Previous

func (tr *Transfer) Previous() *refs.MessageRef

func (*Transfer) Received added in v0.1.1

func (tr *Transfer) Received() time.Time

func (*Transfer) Seq

func (tr *Transfer) Seq() int64

func (*Transfer) UnmarshalCBOR

func (tr *Transfer) UnmarshalCBOR(data []byte) error

func (*Transfer) UnmarshaledEvent

func (tr *Transfer) UnmarshaledEvent() (*Event, error)

func (*Transfer) ValueContent

func (tr *Transfer) ValueContent() *ssb.Value

ValueContent returns a ssb.Value that can be represented as JSON. Note that it's signature is useless for verification in this form. Get the whole transfer message and use tr.Verify()

func (*Transfer) ValueContentJSON

func (tr *Transfer) ValueContentJSON() json.RawMessage

func (*Transfer) Verify

func (tr *Transfer) Verify(hmacKey *[32]byte) bool

Verify returns true if the Message was signed by the author specified by the meta portion of the message

Jump to

Keyboard shortcuts

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