feedchain

package
v0.0.0-...-4d98663 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AuthBlockSize = 236
View Source
const HeaderSize = 170
View Source
const HeaderVersion = 1

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key []byte, buf []byte) ([]byte, error)

func Encrypt

func Encrypt(key []byte, buf []byte) ([]byte, error)

func KeyFromPassphrase

func KeyFromPassphrase(passphrase []byte) ([]byte, []byte)

func KeyFromPassphraseWithSalt

func KeyFromPassphraseWithSalt(passphrase []byte, salt []byte) []byte

func SecretFromPassphrase

func SecretFromPassphrase(passphrase []byte) []byte

Types

type Auth

type Auth struct {
	Salt      [16]byte
	Secret    [32]byte
	Private   [124]byte
	Signature [64]byte
}

func NewAuth

func NewAuth(Salt []byte, Secret []byte, Private []byte, Signature []byte) *Auth

func NewAuthFromBytes

func NewAuthFromBytes(buffer [236]byte) *Auth

func (*Auth) ToBytes

func (auth *Auth) ToBytes() [236]byte

type Block

type Block struct {
	CreationTime time.Time
	Message      string
	Payload      []Payload
	Thread       []byte
	Parent       []byte
}

func NewBlockFromBytes

func NewBlockFromBytes(buffer []byte) *Block

func (*Block) ID

func (block *Block) ID() string

func (*Block) ToBytes

func (block *Block) ToBytes() []byte

type HTTPReader

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

func NewHTTPReader

func NewHTTPReader(url string) (*HTTPReader, error)

func (*HTTPReader) Close

func (hr *HTTPReader) Close() error

func (*HTTPReader) Read

func (hr *HTTPReader) Read(buf []byte) (int, error)

func (*HTTPReader) Seek

func (hr *HTTPReader) Seek(offset int64, whence int) (int64, error)
type Header struct {
	Name           [16]byte
	Version        uint16
	GenerationTime uint64
	IndexOffset    uint64
	IndexLength    uint64
	IndexChecksum  [32]byte
	IndexSignature [64]byte
	PublicKey      ed25519.PublicKey
}

func NewHeader

func NewHeader(stream *StreamWriter) *Header

func NewHeaderFromBytes

func NewHeaderFromBytes(buffer [170]byte) *Header

func (*Header) ToBytes

func (hdr *Header) ToBytes() [170]byte

type Index

type Index struct {
	Records    []indexRecord
	Hashtags   map[string][][]byte
	Mentions   map[string][][]byte
	References map[string][][]byte
	Threads    map[string][][]byte
}

func NewIndex

func NewIndex() *Index

func NewIndexFromBytes

func NewIndexFromBytes(buffer []byte) *Index

func (*Index) Mention

func (index *Index) Mention(mention string, blockChecksum [32]byte)

func (*Index) Record

func (index *Index) Record(blockLen uint64, blockChecksum [32]byte, blockSignature [64]byte)

func (*Index) Reference

func (index *Index) Reference(ref string, blockChecksum [32]byte)

func (*Index) Search

func (index *Index) Search(term string) [][]byte

func (*Index) Tag

func (index *Index) Tag(hashtag string, blockChecksum [32]byte)

func (*Index) Thread

func (index *Index) Thread(thread string, blockChecksum [32]byte)

func (*Index) ToBytes

func (index *Index) ToBytes() []byte

type Payload

type Payload struct {
	Name        string
	ContentType string
	Data        []byte
}

type StreamReader

type StreamReader struct {
	Blocks    []*Block
	Index     *Index
	PublicKey *ed25519.PublicKey
	Signature []byte
	// contains filtered or unexported fields
}

func NewReader

func NewReader(rd io.ReadSeekCloser) (*StreamReader, error)

func NewReaderFromFile

func NewReaderFromFile(pathname string) (*StreamReader, error)

func NewReaderFromURL

func NewReaderFromURL(url string) (*StreamReader, error)

func (*StreamReader) Close

func (stream *StreamReader) Close() error

func (*StreamReader) ID

func (stream *StreamReader) ID() string

func (*StreamReader) Name

func (stream *StreamReader) Name() string

func (*StreamReader) Offset

func (stream *StreamReader) Offset(offset uint64) (*Block, error)

func (*StreamReader) Size

func (stream *StreamReader) Size() uint64

func (*StreamReader) Verify

func (stream *StreamReader) Verify(block *Block) bool

type StreamWriter

type StreamWriter struct {
	Blocks    []*Block
	Index     *Index
	PublicKey *ed25519.PublicKey
	Signature []byte
	// contains filtered or unexported fields
}

func Init

func Init(passphrase []byte, name string) (*StreamWriter, error)

func NewWriter

func NewWriter(passphrase []byte, pathname string) (*StreamWriter, error)

func (*StreamWriter) Append

func (stream *StreamWriter) Append(title string, name string, contentType string, data []byte) error

func (*StreamWriter) Commit

func (stream *StreamWriter) Commit(pathname string) error

func (*StreamWriter) ID

func (stream *StreamWriter) ID() string

func (*StreamWriter) Name

func (stream *StreamWriter) Name() string

func (*StreamWriter) Verify

func (stream *StreamWriter) Verify(block *Block) bool

func (*StreamWriter) Writeable

func (stream *StreamWriter) Writeable() bool

Jump to

Keyboard shortcuts

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