securebody

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 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 securebody encrypts sensitive Fort record bodies before they enter the cloud ledger. Routing metadata remains separate and plaintext.

Index

Constants

View Source
const (
	EnvelopeVersion            = 1
	MaximumPlaintextChunkBytes = 2 << 20
	// AEADOverheadBytes is the fixed authentication-tag overhead of the
	// AES-256-GCM envelope used by Fort. It lets the server derive artifact
	// manifest lengths without disclosing a data-encryption key to a worker.
	AEADOverheadBytes = 16
)

Variables

View Source
var (
	ErrInvalid        = errors.New("secure body envelope invalid")
	ErrKeyUnavailable = errors.New("secure body key unavailable")
	ErrAuthentication = errors.New("secure body authentication failed")
	ErrPayloadLimit   = errors.New("secure body payload limit exceeded")
	ErrVersion        = errors.New("secure body envelope version unsupported")
)

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Version    int    `json:"version"`
	KeyID      string `json:"key_id"`
	Nonce      string `json:"nonce"`
	Ciphertext string `json:"ciphertext"`
}

Envelope is the versioned value stored in the ledger. The referenced key is held outside Supabase.

type KeyRing

type KeyRing struct {
	ActiveKeyID string
	Keys        map[string][]byte
	Random      io.Reader
}

KeyRing retains every decryption key still referenced by durable ciphertext and uses ActiveKeyID only for new writes.

func (KeyRing) Decrypt

func (ring KeyRing) Decrypt(scope Scope, envelope Envelope) ([]byte, error)

func (KeyRing) Encrypt

func (ring KeyRing) Encrypt(scope Scope, plaintext []byte) (Envelope, error)

type Scope

type Scope struct {
	AccountID  string `json:"account_id"`
	RecordType string `json:"record_type"`
	RecordID   string `json:"record_id"`
}

Scope is authenticated but not encrypted. It prevents ciphertext from one account or durable record from being replayed as another.

Jump to

Keyboard shortcuts

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