vault

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound         = errors.New("no records could be found")
	ErrInvalidKey          = errors.New("invalid key")
	ErrInvalidPrefixLength = errors.New("invalid prefix length")
)

Functions

func Decrypt

func Decrypt(ciphertext, nonce string) (plaintext string, err error)

Decrypt takes a ciphertext and decrypts it using the given secret key and nonce.

func Encrypt

func Encrypt(plaintext, nonce string) (string, error)

Encrypt takes a plaintext and encrypts it using the given secret key and nonce.

func GetSecret

func GetSecret() string

Types

type Record

type Record struct {
	Id uint64

	PublicKey  string
	PrivateKey string

	State State

	CreatedAt time.Time
}

func CreateKey

func CreateKey() (*Record, error)

func GrindKey

func GrindKey(prefix string) (*Record, error)

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) GetPrivateKey

func (r *Record) GetPrivateKey() (ed25519.PrivateKey, error)

func (*Record) GetPublicKey

func (r *Record) GetPublicKey() (ed25519.PublicKey, error)

func (*Record) IsAvailable

func (r *Record) IsAvailable() bool

func (*Record) IsDeprecated

func (r *Record) IsDeprecated() bool

func (*Record) IsReserved

func (r *Record) IsReserved() bool

func (*Record) IsRevoked

func (r *Record) IsRevoked() bool

func (*Record) Validate

func (r *Record) Validate() error

type State

type State uint
const (
	StateUnknown State = iota
	StateAvailable
	StateReserved
	StateDeprecated
	StateRevoked
)

type Store

type Store interface {
	// Count returns the total count of keys.
	Count(ctx context.Context) (uint64, error)

	// CountByState returns the total count of keys by state
	CountByState(ctx context.Context, state State) (uint64, error)

	// Save creates or updates the record in the store.
	Save(ctx context.Context, record *Record) error

	// Get finds the record for a given public key.
	Get(ctx context.Context, pubkey string) (*Record, error)

	// GetAllByState returns all records for a given state.
	//
	// Returns ErrKeyNotFound if no records are found.
	GetAllByState(ctx context.Context, state State, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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