tag

package
v0.0.0-...-43ed5bc Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResolverServer

func NewResolverServer(resolver Resolver[object.Namespace]) tag_pb.ResolverServer

NewResolverServer creates a gRPC server that is capable of resolving tags to an object.

func NewUpdaterServer

func NewUpdaterServer(updater Updater[object.Namespace, []byte]) tag.UpdaterServer

NewUpdaterServer creates a gRPC server that is capable of creating or updating existing tags contained in the tag store.

Types

type Key

type Key struct {
	SignaturePublicKey [ed25519.PublicKeySize]byte
	Hash               [sha256.Size]byte
}

Key of tags stored in Tag Store.

Keys contain a hash. The method for computing the hash is specific to the use case. Even though the protocol does not place restrictions on the size of the hash, this implementation only supports hashes that are 256 bits in size (e.g., SHA-256).

In order to prevent collisions between different use cases, keys also contain an signature public key. The value of the tag needs to be signed using the corresponding private key. This permits consumers of tags to verify the tag's value. Even though the protocol does not place restrictions on which algorithm is used, this implementation requires keys to be of type Ed25519.

func NewKeyFromProto

func NewKeyFromProto(m *tag_pb.Key) (Key, error)

NewKeyFromProto creates a tag key based on its equivalent Protobuf message.

func (*Key) ToProto

func (k *Key) ToProto() (*tag_pb.Key, error)

ToProto converts a tag key to an equivalent Protobuf message.

func (Key) VerifySignature

func (k Key) VerifySignature(value Value, signature *[ed25519.SignatureSize]byte) (SignedValue, error)

VerifySignature verifies that a signature corresponds to a given tag key and value. Upon success, it upgrades the provided value to a signed value.

type Resolver

type Resolver[TNamespace any] interface {
	ResolveTag(ctx context.Context, namespace TNamespace, key Key, minimumTimestamp *time.Time) (value SignedValue, complete bool, err error)
}

Resolver of tags.

type ResolverForTesting

type ResolverForTesting Resolver[object.Namespace]

ResolverForTesting is an instantiated version of Resolver, which may be used to generate mocks for tests.

type SignedValue

type SignedValue struct {
	Value     Value
	Signature [ed25519.SignatureSize]byte
}

SignedValue contains the value of a tag and its signature. Instances of SignedValue should only be created in contexts where the signature of the tag has been validated.

func NewSignedValueFromProto

func NewSignedValueFromProto(m *tag_pb.SignedValue, referenceFormat object.ReferenceFormat, key Key) (SignedValue, error)

NewSignedValueFromProto creates a signed value from a Protobuf message. It also validates the value's signature.

func ResolveCompleteTag

func ResolveCompleteTag[TNamespace any](
	ctx context.Context,
	resolver Resolver[TNamespace],
	namespace TNamespace,
	key Key,
	minimumTimestamp *time.Time,
) (SignedValue, error)

ResolveCompleteTag resolves a tag, and only returns the tag's value if the graph it references is complete.

func (*SignedValue) Equal

func (sv *SignedValue) Equal(other SignedValue) bool

Equal returns whether two signed tag values are equal, namely if they refer to the same object, were created at the same time, and have the same signature.

func (*SignedValue) ToProto

func (sv *SignedValue) ToProto() *tag_pb.SignedValue

ToProto converts the signed value from the native type to a Protobuf message.

type Store

type Store[TNamespace any, TLease any] interface {
	Resolver[TNamespace]
	Updater[TNamespace, TLease]
}

Store for tags, which is both accessible for reading (resolving) and writing (updating).

func NewStore

func NewStore[TNamespace, TLease any](resolver Resolver[TNamespace], updater Updater[TNamespace, TLease]) Store[TNamespace, TLease]

NewStore is a helper function for creating a Store that is backed by separate instances of Resolver and Updater.

type Updater

type Updater[TNamespace any, TLease any] interface {
	UpdateTag(ctx context.Context, namespace TNamespace, key Key, value SignedValue, lease TLease) error
}

Updater of tags in storage. Tags can be used to assign a stable identifier to an object.

type UpdaterForTesting

type UpdaterForTesting Updater[object.Namespace, any]

UpdaterForTesting is an instantiated version of Updater, which may be used for generating mocks to be used by tests.

type Value

type Value struct {
	Reference object.LocalReference
	Timestamp time.Time
}

Value of a tag. Tags can refer to a single root object, and they also keep track of a timestamp at which the tag's value was created. The timestamp is used to support overwriting tags reliably, as it may be used to determine which value is the newest.

func NewValueFromProto

func NewValueFromProto(m *tag_pb.Value, referenceFormat object.ReferenceFormat) (Value, error)

NewValueFromProto converts the value of a tag stored in a Protobuf message to a native type.

func (*Value) Equal

func (v *Value) Equal(other Value) bool

Equal returns whether two tag values are equal, namely if they refer to the same object and were created at the same point in time.

func (*Value) Sign

func (v *Value) Sign(privateKey ed25519.PrivateKey, keyHash [sha256.Size]byte) (SignedValue, error)

Sign the value of a tag. This allows consumers to validate that the value actually corresponds to a given key.

func (*Value) ToProto

func (v *Value) ToProto() *tag_pb.Value

ToProto converts the value of a tag from the native type to a Protobuf message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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