amnesia

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinQuestions = 2
	MaxQuestions = 255
)

Variables

View Source
var (
	ErrTooFewQuestions  = fmt.Errorf("too few questions, minimum is %d", MinQuestions)
	ErrTooManyQuestions = fmt.Errorf("too many questions, maximum is %d", MaxQuestions)
)
View Source
var (
	ErrTooFewAnswers  = fmt.Errorf("too few answers, minimum is %d", MinQuestions)
	ErrTooManyAnswers = fmt.Errorf("too many answers, maximum is %d", MaxQuestions)
)

Functions

func DecryptKey added in v0.2.0

func DecryptKey(sealedSecret *SealedSecret, answers Answers) ([]byte, error)

func Encode added in v0.2.0

func Encode(sealedSecret *SealedSecret) ([]byte, error)

func ResealWithKey added in v0.2.0

func ResealWithKey(sealed, secret, key []byte) ([]byte, error)

func Seal

func Seal(
	secret []byte,
	questions Questions,
	threshold int,
) ([]byte, error)

func Unseal

func Unseal(input []byte, answers Answers) ([]byte, error)

func UnsealWithKey added in v0.2.0

func UnsealWithKey(input, key []byte) ([]byte, error)

Types

type Answers

type Answers map[int]string

func NewAnswers

func NewAnswers() Answers

func (Answers) Set

func (a Answers) Set(id int, answer string)

func (Answers) Validate

func (a Answers) Validate() error

type Question

type Question struct {
	Question string
	Answer   string
}

type Questions

type Questions map[int]Question

func NewQuestions

func NewQuestions() Questions

func (Questions) Contains

func (q Questions) Contains(s string) bool

func (Questions) Set

func (q Questions) Set(id int, question Question)

func (Questions) Validate

func (q Questions) Validate() error

type SealedSecret

type SealedSecret struct {
	Version         string  `json:"version"`
	SealedTimestamp string  `json:"sealed_timestamp"`
	Shares          []Share `json:"shares"`
	Encrypted       []byte  `json:"encrypted"`
}

func Decode

func Decode(buf []byte) (*SealedSecret, error)

type Share

type Share struct {
	ID       int    `json:"id"`
	Question string `json:"question"`
	Salt     string `json:"salt"`
	Share    string `json:"share"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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