types

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: AGPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = false
)
View Source
var (
	ErrRowsNotFound = errors.New("No rows found")
)
View Source
var (
	ErrTagPairNotFound = errors.New("TagPair(s) not found")
)

Functions

This section is empty.

Types

type Row

type Row struct {
	// Populated by server
	Encrypted  []byte   `json:"data"`
	RandomTags []string `json:"tags"`

	Nonce *[24]byte `json:"nonce"`
	// contains filtered or unexported fields
}

Row represents one piece of data and the tags it has been tagged with.

The (untrusted) machine storing a Row can only see its ciphertext, nonce, and random strings (RandomTags), where each RandomTag (e.g., "sqmgxo6xg") is a string that CrypTag randomly generates and pairs with each plainTag, where a plainTag is a human-readable string (e.g., "programming" or "type:file") that is either human-generated (like "programming"), auto-generated by CrypTag (like "type:file", "id:a91d46c7-45bb-48e4-43d1-642196df15b2", or "created:20160710072200"), or auto-generated by a CrypTag app (like "type:chatmessage" or "app:cryptagnotes"). (To learn more about CrypTag's tagging conventions, see <https://github.com/cryptag/cryptag/wiki/Advice,-Conventions,-and-Constraints>)

Each of these mappings from plainTag to RandomTag is stored in a TagPair -- the other core CrypTag type.

func NewRow

func NewRow(decrypted []byte, plainTags []string) (*Row, error)

NewRow returns a *Row containing/tagged with the passed-in plainTags, in addition to a unique ID tag ("id:..."), a timestamp tag ("created:created:20170105092731"), and the "all" tag. The *Row returned also contains and a new, random, cryptographic nonce.

func NewRowFromBytes

func NewRowFromBytes(b []byte) (*Row, error)

NewRowFromBytes unmarshals b into a new *Row.

func NewRowSimple

func NewRowSimple(decrypted []byte, plainTags []string) (*Row, error)

func (*Row) Decrypt

func (row *Row) Decrypt(key *[32]byte) error

Decrypt sets row.decrypted, row.nonce based upon row.Encrypted, nonce. The passed-in `decrypt` function will typically be bkend.Decrypt, where `bkend` is the backend storing this Row.

func (*Row) Decrypted

func (row *Row) Decrypted() []byte

Decrypted returns row.decrypted, row's (unexported) decrypted data (if any).

func (*Row) HasPlainTag

func (row *Row) HasPlainTag(plain string) bool

HasPlainTag answers the question, "does row have the plain tag plain?"

func (*Row) HasRandomTag

func (row *Row) HasRandomTag(randtag string) bool

HasRandomTag answers the question, "does row have the random tag randtag?"

func (*Row) PlainTags

func (row *Row) PlainTags() []string

PlainTags returns row.plaintags, row's (unexported) plain (human-entered, human-readable) tags.

func (*Row) Populate

func (row *Row) Populate(key *[32]byte, pairs TagPairs) error

Populate sets row.decrypted based on row.Encrypted and row.plainTags based on row.RandomTags, thereby populating row with plaintext data.

func (*Row) SetPlainTags

func (row *Row) SetPlainTags(pairs TagPairs) error

SetPlainTags uses row.RandomTags and pairs to set row.plainTags

type RowSorter

type RowSorter func(r1, r2 *Row) bool

type Rows

type Rows []*Row

func (Rows) Populate

func (rows Rows) Populate(key *[32]byte, pairs TagPairs) error

func (Rows) Sort

func (rows Rows) Sort(less func(r1, r2 *Row) bool)

func (Rows) String

func (rows Rows) String() string

func (Rows) WithAllRandomTags

func (rows Rows) WithAllRandomTags(random []string) Rows

WithAllRandomTags returns the Rows within rows that has all the random strings in random

type TagPair

type TagPair struct {
	PlainEncrypted []byte    `json:"plain_encrypted"`
	Random         string    `json:"random"`
	Nonce          *[24]byte `json:"nonce"`
	// contains filtered or unexported fields
}

func NewTagPair

func NewTagPair(plainEnc []byte, random string, nonce *[24]byte, plaintag string) *TagPair

func (*TagPair) Decrypt

func (pair *TagPair) Decrypt(key *[32]byte) error

Decrypt sets pair.plain based off of pair.PlainEncrypted

func (*TagPair) Plain

func (pair *TagPair) Plain() string

type TagPairs

type TagPairs []*TagPair

func (TagPairs) AllPlain

func (pairs TagPairs) AllPlain() []string

func (TagPairs) AllRandom

func (pairs TagPairs) AllRandom() []string

func (TagPairs) String

func (pairs TagPairs) String() string

func (TagPairs) WithAllPlainTags

func (pairs TagPairs) WithAllPlainTags(plaintags []string) (TagPairs, error)

func (TagPairs) WithAllRandomTags

func (pairs TagPairs) WithAllRandomTags(randomtags []string) (TagPairs, error)

Jump to

Keyboard shortcuts

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