Local-loopback HTTP proofs
Download this .livemd file, open it in Livebook, and choose
Open → Import from file, then Run all. Use Elixir 1.18 or later and OTP 27 or later
with access to public Hex. No secrets or external services are needed.
Select the local HTTP application profile, sign a request to a literal loopback address, and refuse a wrong nonce, the standard proof profile, and a hostname target.
The host derives the target from its listener and requires its exact server nonce. Loopback HTTP provides neither TLS nor isolation between local processes. Verification grants no execution authority. This notebook makes no HTTP calls and creates no listener or files.
Open this 1.1.0 release notebook. The launch opens this journey at its immutable release tag.
Setup
Install the exact published package. Fixed evaluation times keep the results reproducible; only safe semantic values are persisted, never keys, signatures, tokens, or nonces.
Mix.install([{:bounded_authority_protocol, "== 1.1.0"}])
:ok
Generate issuer and holder keys
The application profile uses Ed25519 keys and a contract-major 1 grant. Generate only the keys needed for that grant and its local proof.
{issuer_public, issuer_private} = :crypto.generate_key(:eddsa, :ed25519)
{holder_public, holder_private} = :crypto.generate_key(:eddsa, :ed25519)
{:ok, holder_thumbprint} =
BoundedAuthorityProtocol.V1.Jwk.public_key_thumbprint_raw(holder_public, %{})
:keys_ready
:keys_ready
Build and sign a local-tool grant
Use a host-pinned audience and a local-tool operation. The grant is standard contract-major 1; only the application proof uses the local-loopback profile.
alias BoundedAuthorityProtocol.V1.{Grant, Operation}
grant = %Grant{
key_id: "issuer-1",
issuer: "https://issuer.example",
grant_id: "grant-2026-001",
audiences: ["urn:example:local-tools"],
issued_at: 1_800_000_000,
not_before: 1_800_000_000,
expires_at: 1_800_003_600,
holder_thumbprint: holder_thumbprint,
operations: [
%Operation{
name: "run_local_tool",
selectors: [:all]
}
]
}
{:ok, signing_input} = BoundedAuthorityProtocol.V1.grant_signing_input(grant, %{})
issuer_signature = :crypto.sign(:eddsa, :none, signing_input.message, [issuer_private, :ed25519])
{:ok, grant_compact} =
BoundedAuthorityProtocol.V1.assemble_compact(signing_input, issuer_signature)
:grant_signed
:grant_signed
Normalize the target and sign the local proof
The profile accepts a canonical literal-loopback HTTP target and requires a nonce. The standard HTTPS proof producer does not serve this listener.
alias BoundedAuthorityProtocol.ApplicationProfile.LocalLoopbackHttp.V1, as: LocalLoopback
alias BoundedAuthorityProtocol.V1.{Proof, Credentials, ExpectedRequest, TrustedIssuer}
now = 1_800_001_000
loopback_target = "http://127.0.0.1:4000/invoke"
loopback_nonce = "challenge-loopback-001"
{:ok, ^loopback_target} = LocalLoopback.normalize_uri(loopback_target, %{})
loopback_proof = %Proof{
holder_public_key: holder_public,
proof_id: "proof-loopback-2026-001",
method: "POST",
target_uri: loopback_target,
issued_at: now,
nonce: loopback_nonce,
invocation_id: "7d444840-9dc0-11ed-a8fc-0242ac120003",
operation: "run_local_tool",
grant_compact: grant_compact,
cast_arguments: {:object, [{"tool", {:string, "index_workspace"}}]}
}
{:ok, loopback_input} = LocalLoopback.proof_signing_input(loopback_proof, %{})
loopback_signature =
:crypto.sign(:eddsa, :none, loopback_input.message, [holder_private, :ed25519])
{:ok, loopback_compact} =
LocalLoopback.assemble_compact(loopback_input, loopback_signature)
:local_proof_signed
:local_proof_signed
Verify the local envelope
Choose the application-profile verifier explicitly. Require the exact listener-derived target and server-issued challenge, then show only the operation and non-authorization marker.
trusted = %TrustedIssuer{key_id: "issuer-1", public_key: issuer_public}
loopback_credentials = %Credentials{grant: grant_compact, proof: loopback_compact}
loopback_expected = %ExpectedRequest{
trusted_issuer: trusted,
issuer: "https://issuer.example",
audience: "urn:example:local-tools",
method: "POST",
target_uri: loopback_target,
invocation_id: "7d444840-9dc0-11ed-a8fc-0242ac120003",
operation: "run_local_tool",
cast_arguments: loopback_proof.cast_arguments,
evaluation_time: now,
clock_skew: 60,
proof_max_age: 300,
nonce: {:required, loopback_nonce},
bounds: %{}
}
{:ok, loopback_facts} =
LocalLoopback.check_envelope(loopback_credentials, loopback_expected)
Map.take(loopback_facts, [:target_uri, :operation, :authorization])
%{target_uri: "http://127.0.0.1:4000/invoke", operation: "run_local_tool", authorization: :not_evaluated}
Refuse a different server nonce
A proof carrying a nonce is insufficient: it must match the challenge the host expected.
{:error, :invalid} =
LocalLoopback.check_envelope(loopback_credentials, %{
loopback_expected
| nonce: {:required, "wrong-nonce"}
})
{:error, :invalid}
Refuse profile fallback and hostname targets
Standard envelope verification refuses the local proof. localhost is also refused without
DNS lookup; a listener must supply its literal loopback address.
{:error, :invalid} =
BoundedAuthorityProtocol.V1.check_envelope(loopback_credentials, loopback_expected)
{:error, :invalid} = LocalLoopback.normalize_uri("http://localhost:4000/invoke", %{})
[:standard_profile, :hostname]
[:standard_profile, :hostname]
See framework and runtime integration for host request boundaries and nonce policy for challenge ownership.