bundlesecret

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 8 Imported by: ? 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 bundlesecret is the format of the operator's bundle Secret, which the operator writes and the engines and inkwallctl read (0004 §4.6).

A bundle that fits in one Secret is stored there, gzip-compressed, under BundleKey. A larger one is split into chunk Secrets, and the bundle Secret holds a Manifest under ManifestKey instead. Chunks are written to one of two sets of names, the one the current manifest doesn't use, before the manifest: a reader never sees a manifest whose chunks are not all written, and the hash in the manifest rejects chunks overwritten since.

Index

Constants

View Source
const (
	// BundleKey holds the gzip-compressed, serialized SignedBundle, when it
	// fits in one Secret.
	BundleKey = "bundle.pb.gz"
	// ManifestKey holds the Manifest of a bundle split into chunks.
	ManifestKey = "manifest.json"
	// ChunkKey holds a chunk Secret's part of the compressed bundle.
	ChunkKey = "chunk"
)

Keys of the bundle Secret and its chunks.

View Source
const (
	// ChunkBytes is the most of the compressed bundle one Secret holds:
	// Secrets are limited to 1 MiB.
	ChunkBytes = 900 << 10
	// MaxChunks bounds the chunks of one bundle.
	MaxChunks = 8
	// MaxBytes is the largest compressed bundle.
	MaxBytes = MaxChunks * ChunkBytes
	// MaxBundleBytes is the largest bundle decompressed.
	MaxBundleBytes = 64 << 20
)

Limits of the format.

Variables

View Source
var ErrIncomplete = errors.New("bundle chunks incomplete")

ErrIncomplete is returned when the chunks don't match their manifest: one is missing, or was overwritten by a newer bundle being written.

Functions

func ChunkName

func ChunkName(secret, slot string, i int) string

ChunkName returns the name of chunk i in slot, for the bundle Secret secret.

func ChunkNames

func ChunkNames(secret string) []string

ChunkNames returns every name a chunk of secret can have: what engines need get on, besides the bundle Secret.

func IsChunk

func IsChunk(secret, name string) bool

IsChunk reports whether name is a chunk of secret.

func Join

func Join(m *Manifest, get func(name string) ([]byte, error)) ([]byte, error)

Join reads m's chunks with get, which returns a chunk Secret's ChunkKey, and returns the compressed bundle, checked against the manifest's hash.

func NextSlot

func NextSlot(secret string, current *Manifest) string

NextSlot returns the slot to write the next bundle's chunks to, given the current manifest (nil if there is none).

Types

type Manifest

type Manifest struct {
	// SHA256 is the hash of the whole compressed bundle, in hex.
	SHA256 string `json:"sha256"`
	// Size is its length in bytes.
	Size int `json:"size"`
	// Chunks are the names of the chunk Secrets, in order, in the bundle
	// Secret's namespace.
	Chunks []string `json:"chunks"`
}

Manifest lists the chunks of a bundle.

func ParseManifest

func ParseManifest(secret string, data []byte) (*Manifest, error)

ParseManifest reads the manifest of secret, and checks that its chunks are named as Split names them.

func Split

func Split(secret, slot string, data []byte) (Manifest, [][]byte, error)

Split splits a compressed bundle into chunks named in slot, and returns their manifest.

func (*Manifest) Marshal

func (m *Manifest) Marshal() ([]byte, error)

Marshal encodes m for ManifestKey.

func (*Manifest) Slot

func (m *Manifest) Slot(secret string) string

Slot returns the slot of m's chunks, "" if it has none.

Jump to

Keyboard shortcuts

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