packverify

package
v2.8.44 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 20 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 packverify implements native Go Ed25519 signature generation/verification, SHA-256 payload digest checks, streaming 8 MiB gzip decompression, and dark-gated remote pack loading for signed EdgeFetch adapter packs (`docs/adapters/PACKS-RFC.md`).

Architectural boundary: `cmd/edgefetch-wasm` (`GOOS=wasip1 GOARCH=wasm`) MUST NEVER import `internal/packverify` so zero Go stdlib `crypto/*` packages enter the WASM linear memory image. On Cloudflare Workers, `hub/src/pack-verify.ts` performs the identical Ed25519 + SHA-256 + 8 MiB streaming gzip verification in WebCrypto before passing verified JSON bytes into `internal/extract`.

Index

Constants

View Source
const DefaultRemotePackFetchTimeout = 15 * time.Second

DefaultRemotePackFetchTimeout bounds outbound HTTP requests when remote packs are explicitly opted in.

Variables

This section is empty.

Functions

func BuildCanonicalSigningInput

func BuildCanonicalSigningInput(env extract.PackEnvelope) ([]byte, error)

BuildCanonicalSigningInput constructs the exact ASCII preimage specified in `PACKS-RFC` §3:

edgefetch-adapter-pack-v1\n
packSeq:<uint64>\n
packVersion:<ascii>\n
gitTag:<ascii>\n
issuedAt:<rfc3339>\n
expiresAt:<rfc3339>\n
minEngineVersion:<semver>\n
maxDslVersion:<uint32>\n
requiredFormattersSha256:<hex>\n
approvedHostMatchChangesSha256:<hex>\n
payloadBytes:<uint64>\n
payloadSha256:<hex>\n

func BuildUnsignedPack

func BuildUnsignedPack(rawCompiledJSON []byte, opts BuildOptions) ([]byte, extract.PackEnvelope, string, error)

BuildUnsignedPack validates candidate `rawCompiledJSON` against the baseline (`ValidateDeclarativeManifests`, `VerifyPackDoesNotWidenBaseline`, `ValidatePackTemplates`, `VerifyPackMatchCaptureDiff`), compresses it with deterministic gzip (`<= 8 MiB`), and returns `(gzPayload, unsignedEnvelope, artifactStem, error)`.

func DecodePackEnvelope

func DecodePackEnvelope(rawSigJSON []byte) (extract.PackEnvelope, string, error)

func DecompressPackGzipBounded

func DecompressPackGzipBounded(gzBytes []byte, maxBytes int) ([]byte, string, error)

DecompressPackGzipBounded decompresses a `.json.gz` pack stream using `io.LimitReader(zr, maxBytes+1)` so gzip bombs exceeding `maxBytes` (`8 MiB`) abort immediately without unbounded memory allocation.

func GzipDeterministic

func GzipDeterministic(rawBytes []byte) ([]byte, error)

GzipDeterministic compresses rawBytes with deterministic zero-timestamp gzip headers.

func HashApprovedHostMatchChanges

func HashApprovedHostMatchChanges(list []extract.ApprovedHostMatchChange) (string, error)

HashApprovedHostMatchChanges computes the canonical lowercase SHA-256 hex digest of sorted, deduplicated `(host, oldAdapterId, newAdapterId)` entries formatted as `<host>\t<oldAdapterId>\t<newAdapterId>` joined with `\n`.

func HashRequiredFormatters

func HashRequiredFormatters(list []string) (string, error)

HashRequiredFormatters computes the canonical lowercase SHA-256 hex digest of sorted, deduplicated `requiredFormatters` joined with `\n` (`e3b0c44298...` when empty).

func ParseEd25519PrivateKey

func ParseEd25519PrivateKey(encoded string) (ed25519.PrivateKey, error)

ParseEd25519PrivateKey parses a 32-byte seed or 64-byte Ed25519 private key encoded in base64url, standard base64, or hex.

func SignPackEnvelope

func SignPackEnvelope(env *extract.PackEnvelope, kid string, priv ed25519.PrivateKey) error

SignPackEnvelope appends (or replaces same-kid) an Ed25519 signature over BuildCanonicalSigningInput(env).

func SyncRemoteAdapterPack

func SyncRemoteAdapterPack(ctx context.Context, pointerURL string, client *http.Client, getenv func(string) string, now time.Time) extract.PackLoadResult

SyncRemoteAdapterPack is DARK by default (`PACKS-RFC` §1): unless `EDGEFETCH_ENABLE_REMOTE_PACKS=true` (and `EDGEFETCH_DISABLE_REMOTE_PACKS != "1"`), it performs ZERO network/disk reads and returns `skipped_dark_default`.

func VerifyAndLoadAdapterPack

func VerifyAndLoadAdapterPack(gzPayload, rawSigJSON []byte, now time.Time) extract.PackLoadResult

VerifyAndLoadAdapterPack runs full cryptographic verification (`VerifyPackGzipCryptographic`) followed by all runtime security, narrowing, prompt-injection, match-capture, and atomic swap gates (`extract.LoadVerifiedAdapterPackJSON`).

func VerifyPackEnvelopeSignatures

func VerifyPackEnvelopeSignatures(env extract.PackEnvelope) (matchedKid string, status string, err error)

VerifyPackEnvelopeSignatures verifies that at least one signature in `env.Signatures` resolves to an active, non-revoked, sequence-eligible key in `extract.EffectiveAdapterPackKeys()` and passes Ed25519 verification.

func VerifyPackGzipCryptographic

func VerifyPackGzipCryptographic(gzPayload, rawSigJSON []byte) ([]byte, extract.PackEnvelope, string, error)

VerifyPackGzipCryptographic verifies the `.sig.json` Ed25519 signature, bounded `<= 8 MiB` gzip stream, and `payloadBytes` + `payloadSha256` digest BEFORE any JSON parsing of the decompressed payload.

Types

type BuildOptions

type BuildOptions struct {
	PackVersion              string
	PackSeq                  uint64
	GitTag                   string
	IssuedAt                 time.Time
	ExpiresAt                time.Time
	MinEngineVersion         string
	MaxDSLVersion            uint32
	ApprovedHostMatchChanges []extract.ApprovedHostMatchChange
	BaselineJSON             []byte // defaults to extract.EmbeddedCompiledManifestJSON() when empty
}

BuildOptions configures `BuildUnsignedPack` for `cmd/adapterpack build` and test vector generation.

type RemotePackPointer

type RemotePackPointer struct {
	PackSeq       uint64 `json:"packSeq"`
	PayloadSHA256 string `json:"payloadSha256"`
	PayloadURL    string `json:"payloadUrl"`
	SignatureURL  string `json:"signatureUrl"`
}

RemotePackPointer represents `packs/v1/latest.json` or `packs/v1/canary.json` when remote packs are enabled in the future.

Jump to

Keyboard shortcuts

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