nativereceipt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 16 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 nativereceipt records file identities observed in a native process's Linux mappings. It does not prove in-memory code integrity or transient loads.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Path   string `json:"path"`
	Major  uint32 `json:"major"`
	Minor  uint32 `json:"minor"`
	Inode  uint64 `json:"inode"`
	Bytes  int64  `json:"bytes"`
	SHA256 string `json:"sha256"`
}

type Mapping

type Mapping struct {
	Begin, End, Offset uint64
	Permissions        string
	Major, Minor       uint32
	Inode              uint64
	Path               string
}

type Process

type Process struct {
	PID              int    `json:"pid"`
	Parent           int    `json:"parent"`
	Group            int    `json:"group"`
	Start            uint64 `json:"start"`
	Executable       string `json:"executable"`
	ExecutableSHA256 string `json:"executable_sha256"`
}

func Identity

func Identity(pid int) (Process, error)

type Receipt

type Receipt struct {
	Process          Process  `json:"process"`
	Stages           []Stage  `json:"stages"`
	Files            []File   `json:"files"`
	DriverObserved   bool     `json:"driver_observed"`
	NVRTCObserved    bool     `json:"nvrtc_observed"`
	BuiltinsObserved bool     `json:"builtins_observed"`
	Unobserved       []string `json:"unobserved,omitempty"`
	HashNanos        int64    `json:"hash_nanos"`
	Limit            string   `json:"limit"`
}

func Read

func Read(path string) (Receipt, error)

Read decodes one bounded exclusive producer receipt. It does not infer child identity; the consumer must Check it against the process it actually started.

func (Receipt) Check

func (r Receipt) Check(expected Process, source, artifact string) error

Check binds a child receipt to its admitted executable/start/group identity, submitted source and actual compilation digest. Empty digests are refused.

func (Receipt) CheckDriver

func (r Receipt) CheckDriver(expected Process, source, artifact string) error

CheckDriver checks a precompiled-image receipt against the actual producer and submitted source/image bytes. Driver and executable mapping proofs are required; optional NVRTC and builtin claims must agree with all descriptors.

Example
// A zero receipt cannot prove a producer or a prepared image.
var receipt Receipt
fmt.Println(receipt.CheckDriver(Process{}, "", ""))
Output:
native receipt: producer process identity disagrees

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session retains descriptors until Close. New and Capture observe this process, never a controller's child. Hashing is deferred to Write and timed separately.

func New

func New() (*Session, error)

New starts a receipt for the current process. Other platforms return an error.

func (*Session) Capture

func (s *Session) Capture(name, source, artifact string) error

Capture retains one bounded maps snapshot and its selected file descriptors. Empty digests are permitted before compilation; populated digests identify source and actual compiled artifact bytes at the consumer call site.

func (*Session) Close

func (s *Session) Close() error

Close releases every retained descriptor, including after capture failure.

func (*Session) Write

func (s *Session) Write(path string) error

Write hashes retained descriptors and writes one exclusive receipt. Driver and NVRTC must actually have been observed; absent builtins remain unobserved. Hash time is reported; it must not be silently removed from process timing.

func (*Session) WriteDriver

func (s *Session) WriteDriver(path string) error

WriteDriver writes a precompiled-image receipt requiring an observed driver and executable. NVRTC and builtins are recorded only when actually observed. Their absence is explicit; this method does not load either library.

Example
// A receipt requires a session created by New in the observed process.
var session *Session
fmt.Println(session.WriteDriver("/receipt.json"))
Output:
native receipt: nil session

type Stage

type Stage struct {
	Name           string    `json:"name"`
	SourceSHA256   string    `json:"source_sha256,omitempty"`
	ArtifactSHA256 string    `json:"artifact_sha256,omitempty"`
	RawMaps        string    `json:"raw_maps"`
	Mappings       []Mapping `json:"mappings"`
	CaptureNanos   int64     `json:"capture_nanos"`
}

Jump to

Keyboard shortcuts

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