knownkeys

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package knownkeys is bfinger's pin store: the library's grammar and store (package knownkeys of github.com/lightwebinc/bcommon) at bfinger's path and under bfinger's header.

The library takes the header on every Save and has no default path. This package supplies both and keeps the API bfinger's callers were built on, so every store bfinger writes opens with the line it has always opened with.

testdata/known_keys.sample is the cross-repository contract for the file's grammar: docs/known-keys.md names it, and the verification oracle vendors the same bytes and parses them with its own code. It stays here, beside the test that parses it, rather than moving with the grammar.

Index

Constants

View Source
const (
	Active      = bcknownkeys.Active
	RotatedFrom = bcknownkeys.RotatedFrom
	Retired     = bcknownkeys.Retired
)

The record forms, the library's values.

View Source
const Header = "# bfinger known_keys v1"

Header is the first line of every store bfinger writes, and the first line of the contract sample. TestSaveBytesAreFrozen pins it byte for byte.

Variables

View Source
var ErrPermissions = bcknownkeys.ErrPermissions

ErrPermissions is the library's sentinel, the same value, so errors.Is matches either name.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is where the pin store lives.

func Fingerprint

func Fingerprint(compressed []byte) string

Fingerprint is SHA256: plus unpadded base64 over the 33-byte compressed key.

func Save

func Save(path string, recs []Record) error

Save writes the store atomically under Header.

Types

type Kind

type Kind = bcknownkeys.Kind

Kind distinguishes the three record forms.

type Record

type Record = bcknownkeys.Record

Record is one line.

func ActiveFor

func ActiveFor(recs []Record, address string) (Record, bool)

ActiveFor returns the pin in force for an address.

func Forget

func Forget(recs []Record, address string, all bool) []Record

Forget removes the pin in force for address; with all, its history too.

func Load

func Load(path string) ([]Record, error)

Load reads the store at path.

func Parse

func Parse(r io.Reader) ([]Record, error)

Parse reads a known_keys file.

func Pin

func Pin(recs []Record, address, keyHex string, seq uint64, fp string, now time.Time) ([]Record, error)

Pin records a first contact or an advance of an existing pin.

func Retire

func Retire(recs []Record, address string, now time.Time) []Record

Retire marks address retired.

func Rotate

func Rotate(recs []Record, address, newKeyHex string, seq uint64, fp string, now time.Time) ([]Record, error)

Rotate replaces the active key for address after a verified rotation.

Jump to

Keyboard shortcuts

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