Packages
Signer for the Bounded Authority Protocol: signs holder proofs, grants, boundary anchors, key transitions and content assertions (Ed25519 and ES256) through your key handle, over the protocol's deterministic signing inputs. Keep private keys behind caller-owned key callbacks.
Current section
Files
Jump to
Current section
Files
bounded_authority_report_adapter
usage-rules.md
usage-rules.md
# Usage rules
1. Treat `sign_report/3` output as a cryptographic artifact, not an authorization decision.
The envelope proves the holder signed this request under that grant; whether the action
is allowed depends on the verifying service's authorization policy. Pure verification
returns facts; verification is never authorization ([consumer integration
§8](docs/guides/framework-integration.md)).
2. Keep private bytes in custody. The `{module, term}` handle carries an opaque reference.
`key_snapshot/1` returns the key's id, public key, allowed purposes and immutable
signing reference. In `sign/3`, require both version permission and a matching byte
classification before using the key. The handle owns the timeout for remote calls.
3. `sign_grant/3` requires `:grant` on the version. Keep grant keys in issuer custody and
configure issuer trust at the verifier. To require independent Ed25519 issuer role
evidence, supply `:role_attestation` from an explicitly trusted attestor.
4. Use the key id and public key from one snapshot. Derive a holder thumbprint with
`public_key_thumbprint/1` and sign only with the exact version from that snapshot.
5. Set `:issued_at` (and `:anchored_at`) when the verifier's evaluation time is far from
your wall clock. The default is `System.system_time(:second)`; tests and offline flows
that verify at a fixed `evaluation_time` need the option, or the proof falls outside
`proof_max_age`.
Report signing checks the holder key named by the grant and requires the proof's
issue time to fall within the grant window, including `nbf` and excluding `exp`.
6. `cast_arguments` must be the protocol's tagged `Json.value()` form, produced by
`BoundedAuthorityProtocol.V1.Json.decode/2` from the same raw bytes on both sides. A
raw map is refused (`{:producer_error, :invalid}`). Decoding different bytes on the two
sides, or a re-encoding instead of the bytes sent, is the mismatch this rule prevents
([consumer integration §3 and §4](docs/guides/framework-integration.md)).
7. The verifying service binds the holder thumbprint to the identity it authenticated
and atomically reserves the nonce and invocation identities before any effect. See
[identity binding and replay reservation](docs/guides/framework-integration.md#8-bind-the-envelope-to-the-authenticated-identity-required).
8. Signing errors use closed atoms or the fixed tuple `{:producer_error, :invalid}`,
with no input values; key ids, message bytes and report content never appear in an error. Do not add
them back by logging the inputs on failure ([Errors](docs/guides/errors.md)).
9. A signature that does not verify against the handle's public key is `:signing_failed`;
the check runs on every object. If your handle signs with a different key than
the snapshot names, the adapter refuses the signature.
10. Attach telemetry before the first production signing call if you want the custody
alarm: `[:bounded_authority_report_adapter, :sign, :stop]` with
`result_class: :signing_failed`. Metadata carries no values; never extend it with key
material ([Telemetry](docs/guides/telemetry.md)).
11. Review protocol upgrades. This package declares a range of compatible
`bounded_authority_protocol` releases; your application's `mix.lock` decides which one
you run. Read the protocol's changelog before moving that lock.
12. Production handles never come from this library. The reference handles in the source
repository's `test/support/` hold private keys in memory, are test-only, and are not
shipped in the package.
13. The local-loopback profile is an explicit decision, never an inference.
`sign_local_loopback_report/3` is the only way to produce `ba+loopback-proof` bytes;
there is no profile option on `sign_report/3`, and nothing detects the transport for
you. The nonce is mandatory, only canonical `http://127.0.0.1` and `http://[::1]`
targets sign, and the verifying host owns the nonce, replay control and the expected
target. Loopback HTTP is not equivalent to HTTPS; see
[Recipes](docs/guides/local-loopback.md).
14. A content assertion is not authorization. `sign_content_assertion/3` takes the twelve
fields listed in its documentation, with raw 32-byte digests, and a handle with
`:content_assertion`. The caller provides the content digest and relying party trust. The consumer verifies with
`BoundedAuthorityProtocol.ContentAssertion.V1.verify_assertion/2`, supplying the
expected identifiers, digests, trusted key, time and bounds, and keeps its own state
if it must reject replays or check a lineage.
15. Select the suite explicitly. The `bap-action-approval/1` profile is produced only by
`sign_action_approval/3`. The host selects approval requirements and eligible roles.
See [Getting started](docs/guides/getting-started.md), [Errors](docs/guides/errors.md),
[Telemetry](docs/guides/telemetry.md) and
[Consumer integration](docs/guides/framework-integration.md) for the long forms.