AgentBlueprintProtocol.Signature (Agent Blueprint Protocol v1.1.0)

Copy Markdown View Source

This module parses signature entries and verifies them with host-supplied public keys.

Use it when checking signature evidence attached to an artifact.

This module does not authorize operations.

Complete setup

Run stages 1 to 3 of the compose and sign guide to obtain the valid entry, public_key_record, and blueprint_digest used below. It constructs and signs both artifacts in memory without a checkout. The examples below continue that setup; keys are not printed.

{:ok, attributes} = AgentBlueprintProtocol.Signature.verify(entry, [public_key_record])
true = attributes.purpose == :blueprint
true = AgentBlueprintProtocol.Digest.to_tagged(attributes.content_digest) == blueprint_digest

Summary

Functions

Parses attributes; it does not verify their signature.

Returns the exact protected-header and detached payload bytes to sign.

Formats the entry as detached compact serialization: protected header, two dots, signature.

Verifies the detached signature using the supplied public keys and returns verified attributes.

Validates an attestation entry against the accepted-kind set. This release has no accepted attestation kinds, so this operation returns a typed denial; it has no successful attestation-verification example in this release.

Functions

attributes(entry)

(since 1.0.0)

Parses attributes; it does not verify their signature.

Continue the complete setup from the module documentation.

{:ok, %AgentBlueprintProtocol.Signature.Attributes{purpose: :blueprint} = attributes} =
  AgentBlueprintProtocol.Signature.attributes(entry)
true = AgentBlueprintProtocol.Digest.to_tagged(attributes.content_digest) == blueprint_digest

signing_input(entry)

(since 1.0.0)
@spec signing_input(AgentBlueprintProtocol.Json.value()) ::
  {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}

Returns the exact protected-header and detached payload bytes to sign.

Continue the complete setup from the module documentation.

{:ok, signing_input} = AgentBlueprintProtocol.Signature.signing_input(entry)
true = is_binary(signing_input)

to_compact(entry)

(since 1.0.0)
@spec to_compact(AgentBlueprintProtocol.Json.value()) ::
  {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}

Formats the entry as detached compact serialization: protected header, two dots, signature.

Continue the complete setup from the module documentation.

{:ok, compact} = AgentBlueprintProtocol.Signature.to_compact(entry)
[header, "", signature] = String.split(compact, ".")
true = byte_size(header) > 0 and byte_size(signature) > 0

verify(entry, keys)

(since 1.0.0)

Verifies the detached signature using the supplied public keys and returns verified attributes.

Continue the complete setup from the module documentation. Compare returned purpose and content_digest with the intended artifact; standalone verification has no expected-artifact argument. Reconciliation separately compares the signed digest with each artifact.

{:ok, %AgentBlueprintProtocol.Signature.Attributes{purpose: :blueprint} = attributes} =
  AgentBlueprintProtocol.Signature.verify(entry, [public_key_record])
true = AgentBlueprintProtocol.Digest.to_tagged(attributes.content_digest) == blueprint_digest

verify_attestation(entry, keys)

(since 1.0.0)

Validates an attestation entry against the accepted-kind set. This release has no accepted attestation kinds, so this operation returns a typed denial; it has no successful attestation-verification example in this release.

Example

match?(
  {:error, %AgentBlueprintProtocol.Error{}},
  AgentBlueprintProtocol.Signature.verify_attestation(nil, [])
)