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:
- OVERLAY_TRUST_BRIDGE_VERIFY is true (default false) and the key loaded;
- the request arrived on a loopback address;
- 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 ¶
const Header = spv.MarkerHeader
Header is the request header that carries the marker.
Variables ¶
var Results = []Result{Accepted, Disabled, NotLoopback, BadMAC}
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 ¶
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 ¶
New returns a Trust over key (tests); a key shorter than pkg/spv's minimum never accepts a marker.