v1.7.0 Latest Latest

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 12



Package primitiveset provides a container for a set of cryptographic primitives.

It provides also additional properties for the primitives it holds. In particular, one of the primitives in the set can be distinguished as "the primary" one.



This section is empty.


This section is empty.


This section is empty.


type Entry

type Entry struct {
	KeyID      uint32
	Primitive  interface{}
	Prefix     string
	PrefixType tinkpb.OutputPrefixType
	Status     tinkpb.KeyStatusType
	TypeURL    string

Entry represents a single entry in the keyset. In addition to the actual primitive, it holds the identifier and status of the primitive.

type PrimitiveSet

type PrimitiveSet struct {
	// Primary entry.
	Primary *Entry

	// The primitives are stored in a map of (ciphertext prefix, list of
	// primitives sharing the prefix). This allows quickly retrieving the
	// primitives sharing some particular prefix.
	Entries map[string][]*Entry

PrimitiveSet is used for supporting key rotation: primitives in a set correspond to keys in a keyset. Users will usually work with primitive instances, which essentially wrap primitive sets. For example an instance of an AEAD-primitive for a given keyset holds a set of AEAD-primitives corresponding to the keys in the keyset, and uses the set members to do the actual crypto operations: to encrypt data the primary AEAD-primitive from the set is used, and upon decryption the ciphertext's prefix determines the id of the primitive from the set.

PrimitiveSet is a public to allow its use in implementations of custom primitives.

func New

func New() *PrimitiveSet

New returns an empty instance of PrimitiveSet.

func (*PrimitiveSet) Add

func (ps *PrimitiveSet) Add(p interface{}, key *tinkpb.Keyset_Key) (*Entry, error)

Add creates a new entry in the primitive set and returns the added entry.

func (*PrimitiveSet) EntriesForPrefix

func (ps *PrimitiveSet) EntriesForPrefix(prefix string) ([]*Entry, error)

EntriesForPrefix returns all primitives in the set that have the given prefix.

func (*PrimitiveSet) RawEntries

func (ps *PrimitiveSet) RawEntries() ([]*Entry, error)

RawEntries returns all primitives in the set that have RAW prefix.

Jump to

Keyboard shortcuts

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