bridgetrust

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 3 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 bridgetrust judges overlay-bridge's SPV trust marker on POST /submit: when to believe that the bridge on this machine has already run the scripts of the exact bytes submitted (overlay-bridge pkg/spv, marker.go, and docs/spv.md "The trust boundary").

The bridge (-verify enforce) verifies every object it delivers with overlay-bridge pkg/spv, the verifier this host runs too, and marks one that passed with X-Overlay-Bridge-Verified: v1=<hex>, an HMAC-SHA256 under a key the two processes share through a file only they can read, over a fixed label and the body. A marker is honored only when ALL of these hold:

  1. OVERLAY_TRUST_BRIDGE_VERIFY is true (default false) and the key loaded;
  2. the request arrived on a loopback address;
  3. exactly one marker header was sent, and its HMAC over the body this host actually read matches, compared in constant time.

Loopback alone is not enough (anything on the machine reaches loopback); the key alone is not enough (a key that leaked off the machine must not let a remote submitter skip verification). The HMAC binds the marker to one body, so a marker seen on the wire cannot be moved to another object: replaying it re-submits bytes that already passed.

A marker that fails any check is IGNORED, never refused: the object is then verified in full, as if it carried no marker. What an honored marker waives is the scripts only (pkg/spv Verifier.SkipScripts); the pipeline still parses the object, checks every merkle path against this host's chain tracker, checks structure, amounts, finality and maturity, and runs the topic managers. Only the /submit route consults this package: GASP catch-up, ordered replay and every other in-process submission go through the pipeline's plain Submit and are verified in full.

Index

Constants

View Source
const Header = spv.MarkerHeader

Header is the request header that carries the marker.

Variables

Results lists every Result, for presetting the counter.

Functions

This section is empty.

Types

type Result

type Result string

Result is how one marker was judged: the result label values of overlay_go_bridge_marker_total, the TypeScript host's overlay_host_bridge_marker_total values.

const (
	Accepted    Result = "accepted"     // every check held: the scripts are skipped
	Disabled    Result = "disabled"     // trust is off on this host
	NotLoopback Result = "not_loopback" // sent from off the machine
	BadMAC      Result = "bad_mac"      // another key, another body, or not one well-formed marker
)

The results.

type Trust

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

Trust holds the marker key. A nil *Trust, or one without a key, is trust disabled.

func Load

func Load(enabled bool, keyFile string) (*Trust, error)

Load returns the trust the configuration asks for: nil with trust off; with it on, the key read from keyFile (pkg/spv LoadKey: at least 32 bytes, not readable by group or others), or an error.

func New

func New(key []byte) *Trust

New returns a Trust over key (tests); a key shorter than pkg/spv's minimum never accepts a marker.

func (*Trust) Check

func (t *Trust) Check(remoteAddr string, values []string, body []byte) Result

Check judges the marker values sent with body from remoteAddr (an http.Request's RemoteAddr). Call it only when the header is present.

func (*Trust) Enabled

func (t *Trust) Enabled() bool

Enabled reports whether markers can be accepted at all.

Jump to

Keyboard shortcuts

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