Skip to main content

Crate aph_core

Crate aph_core 

Source
Expand description

APH (Agent per Human) protocol v0.1 core types.

Trust model, stated up front. The human principal signs; the notary countersigns. An envelope is in one of two modes, and which one decides what a successful verification actually proves:

  • PrincipalSigned — proof is a two-element chain whose head was made by the human’s own key. Verifying it proves this human authorized this.
  • NotaryAttested — a single notary proof, and what an ABSENT attestationMode means. Verifying it proves only a notary asserts this human authorized this, which is strictly weaker. The human’s own authorization, if present at all, lives in the principalSignature of the Delegation Mandate embedded at policy.delegation_mandate.

Callers must never report the weaker claim as the stronger one. Use verification::require_mode to refuse a downgrade rather than inspecting the shape by hand, and verification::verify_proof_structure to learn which mode an envelope is really in — the declared label is bound to the proof structure precisely so a notary key alone cannot forge the stronger claim (spec §7.1.11).

Standalone implementation of the APH protocol: party roles, mandate types, notarization flow state machines, the W3C VC 2.0-shaped NotarizationEnvelope on-wire credential, the agent-credential-access envelope variant, the A2A extension descriptor, SD-JWT-VC profile pinning, and the JCS / detached-JWS / ECDSA signing helpers used to sign and verify envelopes.

The normative protocol specification lives at ../../spec/aph-0.1.md in this repository.

Wire compatibility is this crate’s primary invariant: every serde attribute on the wire types is load-bearing. Envelopes already signed by existing notaries MUST keep parsing and re-canonicalizing identically across releases.

Registered optional extensions (spec §7.5): this implementation accepts and can emit credentialSubject.appleAurAcceptance (§7.5.1), linkedMandate.ap2SignedPayloadB64 (§7.5.2), and linkedMandate.vaultMutation (§7.5.3). All are omitted when absent, so extension-free envelopes round-trip byte-identically. The CredentialAccessNotarizationEnvelope variant remains a spec v0.2 candidate.

Top-level credentialStatus (§6.3.3.1) is a CORE optional field rather than a registered extension, and it follows the same omit-when-absent rule for the same reason: an envelope with no status reference is byte-identical to one written before revocation had a transport, so every existing signature stays valid. credential_status holds the type, the derived-endpoint and same-origin rules, and the §6.3.3.4 trichotomy a recipient applies at §8.3 step 8a — all of it EXCEPT the status list’s own §6.3.3.3 proof check, which needs a §8.4-resolved notary key this crate must not hold and is therefore the caller’s step (that module’s preamble and check_envelope_status state the obligation).

Re-exports§

pub use a2a_extension::APH_EXTENSION_URI;
pub use a2a_extension::aph_a2a_extension;
pub use aph_config::ALG_EDDSA;
pub use aph_config::ALG_ES256;
pub use aph_config::APH_CONTEXT_V1;
pub use aph_config::APH_CREDENTIAL_TYPE;
pub use aph_config::APH_DI_CRYPTOSUITE;
pub use aph_config::APH_VERSION;
pub use aph_config::DEFAULT_MANDATE_TTL_SECONDS;
pub use aph_config::MAX_BODY_PREVIEW_BYTES;
pub use aph_config::MAX_PREVIEW_LINES;
pub use aph_config::W3C_VC_CONTEXT_V2;
pub use communication_mandate::CommunicationMandate;
pub use credential_status::CredentialStatusEntry;
pub use credential_status::StatusCheck;
pub use credential_status::StatusEntryType;
pub use credential_status::StatusListCredential;
pub use credential_status::StatusListSubject;
pub use credential_status::StatusPurpose;
pub use credential_status::check_credential_status;
pub use credential_status::check_envelope_status;
pub use credential_status::decode_encoded_list;
pub use credential_status::parse_status_list_credential;
pub use credential_status::revocation_bit;
pub use credential_status::status_list_signing_base;
pub use delegation_mandate::DelegationMandate;
pub use envelope::ActClassification;
pub use envelope::ActLabel;
pub use envelope::AgentRef;
pub use envelope::AttestationMode;
pub use envelope::ChannelDescriptor;
pub use envelope::ChannelKind;
pub use envelope::CommunicationDescriptor;
pub use envelope::ContentClass;
pub use envelope::CredentialSubject;
pub use envelope::EnvelopeProof;
pub use envelope::EnvelopeProofs;
pub use envelope::HumanPrincipalRef;
pub use envelope::LinkedMandate;
pub use envelope::NotarizationEnvelope;
pub use envelope::NotarizationMetadata;
pub use envelope::NotaryServiceRef;
pub use envelope::Audience;
pub use envelope::AudienceChannelBinding;
pub use envelope::PolicyDecision;
pub use envelope::PolicyDescriptor;
pub use envelope::RecipientClass;
pub use envelope::SealedPayload;
pub use envelope::SealedReader;
pub use envelope::VocabularyRef;
pub use envelope::parse_envelope_json;
pub use envelope::sealed_payload_is_declared;
pub use errors::AphError;
pub use rotation::DID_DOC_ROTATION_PROPERTY;
pub use rotation::ROTATION_ATTESTATION_TYPE;
pub use rotation::RotationAttestation;
pub use rotation::RotationSuccessor;
pub use rotation::sign_rotation_attestation;
pub use rotation::verify_rotation_attestation;
pub use human_not_present_flow::HumanNotPresentNotarizationFlow;
pub use human_not_present_flow::HumanNotPresentNotarizationState;
pub use human_present_flow::HumanPresentNotarizationFlow;
pub use human_present_flow::HumanPresentNotarizationState;
pub use roles::AphOperation;
pub use roles::AphPartyRole;
pub use sd_jwt_profile::APH_SD_JWT_TYP;
pub use sd_jwt_profile::SD_JWT_BASE_DRAFT_PIN;
pub use sd_jwt_profile::SD_JWT_VC_DRAFT_PIN;
pub use sd_jwt_profile::SdJwtVcProfile;
pub use sd_jwt_profile::current_profile;
pub use vault_mutation::VaultMutationKind;
pub use vault_mutation::VaultMutationMandate;
pub use crate::discovery::DidUrl;
pub use crate::discovery::KeyAlgorithm;
pub use crate::discovery::NotaryPublicKey;
pub use crate::discovery::https_origin;
pub use crate::discovery::same_origin;
pub use crate::crypto::did_key::DecodedDidKey;
pub use crate::crypto::did_key::decode as decode_did_key;
pub use crate::crypto::did_key::encode_ed25519 as did_key_from_ed25519;
pub use crate::crypto::eddsa_jcs::countersign_as_notary;
pub use crate::crypto::eddsa_jcs::sign_as_principal;
pub use crate::crypto::eddsa_jcs::sign_envelope;
pub use crate::crypto::eddsa_jcs::signing_input;
pub use crate::crypto::eddsa_jcs::verify_envelope;
pub use crate::crypto::eddsa_jcs::verify_envelope_did_key;
pub use crate::crypto::eddsa_jcs::verify_proof;
pub use crate::crypto::jcs::canonicalize_rfc8785;
pub use crate::crypto::jws_detached::create_detached_jws;
pub use crate::crypto::jws_detached::verify_detached_jws;
pub use crate::crypto::signing::sign_mandate;
pub use crate::crypto::signing::verify_mandate;
pub use crate::crypto::proof_base::ProofRole;
pub use crate::crypto::proof_base::mandate_signing_base;
pub use crate::crypto::proof_base::signing_base;
pub use crate::verification::require_mode;
pub use crate::verification::verify_embedded_mandate_binding;
pub use crate::verification::verify_proof_structure;
pub use crate::verification::verify_timestamp_order;

Modules§

a2a_extension
A2A Agent Card extension descriptor for APH.
aph_config
APH configuration constants — version pins, default TTLs, JCS profile.
communication_mandate
CommunicationMandate — per-message authorization. References a parent DelegationMandate and binds to a specific outbound payload by hash.
credential_access_envelope
CredentialAccessNotarizationEnvelope — APH envelope variant for agent-credential-access authorization.
credential_status
Revocation status transport — the parsing and decision half (spec §6.3.3).
crypto
Cryptographic helpers for APH envelopes.
delegation_mandate
DelegationMandate — human → agent ongoing authorization to send on specific channels under bounded scope. Issued ONCE; referenced by N CommunicationMandates.
discovery
Notary key discovery — the parsing half.
envelope
NotarizationEnvelope — the W3C VC 2.0-shaped credential carrying an APH notarization. This is the canonical on-wire shape.
errors
APH error taxonomy.
human_not_present_flow
Human-not-present notarization flow state machine.
human_present_flow
Human-present notarization flow state machine.
roles
APH party roles + permitted operations.
rotation
RFC 0001 — the signed key-rotation attestation (spec/aph-0.2.md).
sd_jwt_profile
SD-JWT-VC draft version pinning for the APH profile.
vault_mutation
Vendored cross-vault wire types carried by LinkedMandate.vault_mutation.
verification
Structural verification of an envelope’s proof block — spec §7.1.11, §7.1.7.1, §7.2.1 and §8.3.1 steps 1a, 1d, 1e.