Expand description
Load, verify and apply decision certificates: decision-certificate.v1
(spec/decision-certificate.v1.md), decision-certificate.v1.1 (spec/decision-certificate.v1.1.md)
decision-certificate.v1.2 (spec/decision-certificate.v1.2.md), decision-certificate.v1.3
(spec/decision-certificate.v1.3.md), decision-certificate.v1.4 (spec/decision-certificate.v1.4.md)
decision-certificate.v1.5 (spec/decision-certificate.v1.5.md) and decision-certificate.v1.6
(spec/decision-certificate.v1.6.md).
Verification canonicalises the JSON value exactly as received (RFC 8785, JCS), never a
re-serialised struct, so number formatting can’t drift from the issuer’s. The typed
Certificate is read from the same value afterwards, rejecting unknown fields.
A v1.2 certificate also stores the confidence histogram of its threshold split, so a consumer can
monitor without labels: Histogram::of bins a window of use-time confidences and
shift_score compares it with the stored one. The score is descriptive, a prompt to measure
again; it never shows that the bound holds or has failed.
probabilities applies a certificate’s calibration map to a case’s raw scores, for the map
kinds v1.2 defines (temperature and dr, MAP_KINDS).
A v1.3 certificate also names the options a consumer automates (automate_options) and reports,
per test, the share and error of the answered cases whose answer is one of them (Automated).
A v1.5 certificate also names its tenant and who signed it (Signer: the tenant as operator,
or a hosting service for the tenant), and its signature covers the tenant. It is verified with
the tenant the consumer expects and that tenant’s moded keys: verify_for_tenant. verify
keeps its meaning for v1 to v1.4 and refuses a v1.5 certificate.
A v1.6 certificate is a sequential, anytime-valid measurement over the records of a
pre-registered attempt in one flow and environment (sequential). It is verified only on
request, with the expected tenant, flow and environment: verify_sequential.
verify_for_tenant refuses it, so a consumer that only upgrades the crate never accepts one.
inclusion checks decision-cert-inclusion.v1
(spec/decision-cert-inclusion.v1.md) offline: a bundle showing that a tenant’s
transparency log recorded a leaf in a checkpoint its witnesses cosigned
(inclusion::verify_bundle), a consistency proof between two checkpoints
(inclusion::verify_consistency), and the consumer’s policy for a certificate without a bundle
(inclusion::apply_policy).
Re-exports§
pub use challenger::AttemptRole;pub use sequential::explore_bucket;pub use sequential::salt_commitment;pub use sequential::tail_trips;pub use sequential::Sequential;
Modules§
- challenger
decision-certificate.v1.7(spec/decision-certificate.v1.7.md): the attempt’s role, the champion a challenger runs beside and what it changes (§1.1 to §1.4), the delta budget (§1.5), the checks beyond the schema (§2.5) and promotion (§4.2).- inclusion
decision-cert-inclusion.v1: a tenant’s transparency log, checked offline (spec/decision-cert-inclusion.v1.md).- sequential
decision-certificate.v1.6(spec/decision-certificate.v1.6.md): thesequentialblock, the anytime-valid crossing of each class (§1.3), the exploration draw (§1.7) and the checks beyond the schema (§2.7).
Structs§
- Audit
- Automated
- A test’s answered cases whose answer is one of
automate_options(v1.3): their share of the test’sncases, anducbandrealized_bandof their error, as the test’s own (descriptive, spec v1.2 §1.2). Null exactly where the test’s are. - Band
- Calibration
Map - Certificate
- Every field is required;
Optionfields must be present (as null): a missing field is an error. - Cost
- A v1.4
selective_costcertificate’s costs:matrix[label][answered option], in the options’ order, whole numbers in the consumer’sunit(informational), and its largest entryc_max. - Document
Verdict - The separate results of
verify_document. They are never folded into one yes or no: a consumer reads each. - Expiry
- A verified certificate’s expiry at the caller’s
now(Verified::is_expired). - Histogram
- A test’s threshold-split cases per bin of
confidence_bins, and the cases the rule abstains on whatever the threshold (unscored, or above thecannot_tellcut). v1.2. - Issuer
- Rule
- Segment
- Shift
Score - Pearson’s chi-square test of homogeneity between the stored histogram and a window’s.
- Signer
- Who signed a v1.5 certificate:
modeoperator(the tenant, with its own key; nohost), orhosted(a hosting service for the tenant;hostis the hosting service’s own key id,ed25519:<16 lowercase hex>). - Split
- Trusted
Key - A trusted certificate-signing key of one tenant: the base64url raw Ed25519 public key, and the mode it may sign in.
- UtcDate
Time - The UTC time type of
timestamp,Verified::expires_atandVerified::is_expired, re-exported so a caller need not depend ontimeto name it. APlainDateTimethat is known to be UTC. - Verified
- A certificate whose signature verified against a trusted key.
- Window
Enums§
- Cert
Error - KeyMode
- The mode a trusted key may sign in (spec v1.5 §4):
Operator(the tenant’s own key, as every key in v1 to v1.4), orHostedby the hosting service whose own key id ishost.
Constants§
- ABSTAIN_
ALL abstain_belowthat abstains on every case (asdk calibratewrites it).- CONTEXT_
V1_ 5 - The context string a v1.5 signature’s bytes start with (spec v1.5 §3).
- CONTEXT_
V1_ 6 - The context string a v1.6 signature’s bytes start with (spec v1.6 §3).
- CONTEXT_
V1_ 7 - The context string a v1.7 signature’s bytes start with (spec v1.7 §3).
- MAP_
KINDS - The kinds of calibration map v1.2 defines. A certificate may name another kind; it still verifies, and a consumer that does not apply that kind refuses it (spec v1.2 §4).
- MAX_
BINS - Most bins a
confidence_binsmay define. - MAX_C
- v1.4’s checks beyond the schema (spec v1.4 §2):
costandpvaluepair withrisk; the cost matrix is options x options with a zero diagonal, whole-number entries in [0, c_max],c_maxits largest entry, above 0 and at most 10^6, and its off-diagonal entries not all equal;loss_sumandrealized_costare null for the error risks, for an inherited segment and wherever their test answered no case, and otherwiseloss_sumis at most c_max * k andrealized_costis exactlyloss_sum / (c_max * k), k = floor(coverage * n + 1/2) the answered cases. v1.4: the largestc_max. - MAX_
TENANT - The longest
tenant(spec v1.5 §2). - SPEC
- The
specof a certificate produced by the v1 procedure. - SPECS
- Every
specthis verifier accepts. v1 and v1.1 have the same fields; v1.2 adds some, v1.3 more, v1.4 more again, v1.5 more again. - SPEC_
V1_ 1 - The
specof a certificate produced by the v1.1 procedure (the per-test grid start). - SPEC_
V1_ 2 - The
specof a v1.2 certificate: v1.1’s procedure, plus the stored confidence histogram. - SPEC_
V1_ 3 - The
specof a v1.3 certificate: v1.2, plus the automated options and their answered share and error per test. - SPEC_
V1_ 4 - The
specof a v1.4 certificate: v1.3, plus the cost riskselective_cost. - SPEC_
V1_ 5 - The
specof a v1.5 certificate: v1.4, plustenantandsigner, signed over bytes that bind the tenant. - SPEC_
V1_ 6 - The
specof a v1.6 certificate: v1.5’s fields, with fixed values for the calibration split, and thesequentialblock; methodconfidence_sequence, riskautomated_error. - SPEC_
V1_ 7 - The
specof a v1.7 certificate: v1.6, plus the attempt’s role (standalone or challenger, with the champion it runs beside) and its delta budget, insequential.
Functions§
- bin_of
- The bin of
confidence:iwithbins[i] <= confidence < bins[i + 1]; the last bin also holds - canonical
- The JCS bytes of a JSON value.
- certificate_
id - chi2_sf
- P(X >= x) for X ~ chi-square with
dfdegrees of freedom: the regularised upper incomplete gamma Q(df/2, x/2), by its series below a + 1 and its continued fraction above. 1 for df 0. - confidence
- A case’s confidence under
map: the largest of itsprobabilities. None when those are. - key_id
ed25519:+ the first 16 hex chars of SHA-256 of the raw public key.- probabilities
- The probabilities
mapgives a case’s raw scores, one per option in score order (spec v1.2 §1): - shift_
score - Compare a window’s histogram with the certificate’s (spec §4). The columns are the bins and the unscored count; columns empty in both are dropped. With an empty side or one column left there is nothing to compare: statistic 0, df 0, p-value 1. None when the bin counts differ.
- tenant_
keys_ from_ json - Read a tenant’s trusted keys from a JSON object of key id → entry. An entry is a bare base64url
string (an
operatorkey, as in a v1 to v1.4 key map),{"key": ..., "mode": "operator"}, or{"key": ..., "mode": "hosted", "host": "ed25519:<16 lowercase hex>"}(spec v1.5 §4). Any other entry, an unknown field, or ahostnot in that form is refused asCertError::BadKey. The key is checked against its id when a certificate is verified, as inverify. - timestamp
- Parse the spec’s timestamp form,
YYYY-MM-DDTHH:MM:SSZ, and nothing else. - verify
- Verify
vagainstkeys(key id → base64url raw public key) and read it. - verify_
attempt - Verify
v, adecision-certificate.v1.7, for the expectedtenant,flowandenv(spec v1.7 §4.1), and read it. - verify_
attempt_ document verify_documentfor a v1.7 certificate:verify_attemptwith the expectedflowandenv, the expiry at the caller’snow, and the recomputed id, as separate results.- verify_
document - Verify
vfor the expectedtenantexactly asverify_for_tenantdoes, check its expiry at the caller’snow, and recompute its id, returning the three as separate results. - verify_
for_ tenant - Verify
vfor the tenant the consumer expects, against that tenant’s moded keys, and read it (spec v1.5 §4). - verify_
promotion - Verify that
challengermay replacechampionas the certificate a domain automates under (spec v1.7 §4.2), for the expectedtenant,flowandenvat the caller’snow, and read the challenger. - verify_
promotion_ document verify_promotionas separate results: the promotion’s verdict, the challenger’s expiry atnowand the challenger’s recomputed id.- verify_
sequential - Verify
v, adecision-certificate.v1.6, for the expectedtenant,flowandenv(spec v1.6 §4), and read it. - verify_
sequential_ document verify_documentfor a v1.6 certificate:verify_sequentialwith the expectedflowandenv, the expiry at the caller’snow, and the recomputed id, as separate results.
Type Aliases§
- Tenant
Keys - One tenant’s trusted keys: key id →
TrustedKey.