Skip to main content

ratify_protocol/
lib.rs

1//! Ratify Protocol v1 — Rust reference SDK.
2//!
3//! Delegated-authority proofs for human-agent and agent-agent interactions.
4//! Every signature is hybrid Ed25519 + ML-DSA-65 (FIPS 204): quantum-safe
5//! by design.
6//!
7//! See docs/EXPLAINED.md and docs/AGENT_TO_AGENT.md in the repository for
8//! architecture, threat model, and agent-to-agent patterns.
9//!
10//! # `no_std` support
11//!
12//! Disable the default `std` feature to use this crate without the standard
13//! library. An `alloc` crate is required. I/O, `SystemTime`, and `serde_json`
14//! support are only available with `std`.
15
16#![cfg_attr(not(feature = "std"), no_std)]
17extern crate alloc;
18
19pub mod canonical;
20pub mod challenge_store;
21pub mod constraints;
22pub mod operation_context;
23pub mod crypto;
24pub mod receipts;
25pub mod scope;
26pub mod types;
27pub mod verify;
28
29pub use canonical::{base64_std_decode, base64_std_encode, hex_decode, hex_encode};
30#[cfg(feature = "std")]
31pub use canonical::canonical_json;
32pub use challenge_store::{ChallengeStore, UNKNOWN_CHALLENGE};
33pub use operation_context::{
34    build_session_context, operation_context_bytes, operation_context_hash,
35    session_context_bytes, OperationContext, SessionContextInputs,
36};
37#[cfg(feature = "std")]
38pub use challenge_store::MemoryChallengeStore;
39pub use crypto::{
40    chain_hash, challenge_sign_bytes, challenge_sign_bytes_with_session_context,
41    challenge_sign_bytes_with_stream, delegation_sign_bytes, derive_id, generate_challenge,
42    generate_hybrid_keypair, issue_delegation, issue_key_rotation_statement, issue_revocation_list,
43    issue_revocation_push, issue_session_token, issue_witness_entry, key_rotation_sign_bytes,
44    revocation_push_sign_bytes, revocation_sign_bytes, session_token_sign_bytes, sign_both,
45    sign_challenge, sign_challenge_with_session_context, sign_challenge_with_stream,
46    sign_transaction_receipt_party, transaction_receipt_sign_bytes, verify_both,
47    verify_challenge_signature, verify_challenge_signature_with_session_context,
48    verify_challenge_signature_with_stream, verify_delegation_signature,
49    verify_delegation_signature_e, verify_key_rotation_statement, verify_revocation_list,
50    verify_revocation_push, verify_session_token, verify_session_token_e, verify_witness_entry,
51    witness_entry_sign_bytes,
52};
53#[cfg(feature = "std")]
54pub use crypto::{generate_agent, generate_human_root};
55pub use scope::{
56    expand_scopes, has_scope, intersect_scopes, is_sensitive, scope_wildcards, validate_scopes,
57    vocabulary, CUSTOM_SCOPE_PREFIX,
58    SCOPE_COMMS_CALENDAR_READ, SCOPE_COMMS_CALENDAR_WRITE, SCOPE_COMMS_EMAIL_DELETE,
59    SCOPE_COMMS_EMAIL_READ, SCOPE_COMMS_EMAIL_SEND, SCOPE_COMMS_MESSAGE_DELETE,
60    SCOPE_COMMS_MESSAGE_READ, SCOPE_COMMS_MESSAGE_SEND, SCOPE_CONTRACT_READ, SCOPE_CONTRACT_SIGN,
61    SCOPE_DATA_DELETE, SCOPE_DATA_EXPORT, SCOPE_DATA_READ, SCOPE_DATA_SHARE, SCOPE_DATA_WRITE,
62    SCOPE_EXECUTE_CODE, SCOPE_EXECUTE_TOOL, SCOPE_FILES_READ, SCOPE_FILES_WRITE,
63    SCOPE_GENERATE_CONTENT, SCOPE_GENERATE_DEEPFAKE, SCOPE_IDENTITY_DELEGATE, SCOPE_IDENTITY_PROVE,
64    SCOPE_MEETING_ATTEND, SCOPE_MEETING_CHAT, SCOPE_MEETING_RECORD, SCOPE_MEETING_SHARE_SCREEN,
65    SCOPE_MEETING_SPEAK, SCOPE_MEETING_VIDEO, SCOPE_PAYMENTS_AUTHORIZE, SCOPE_PAYMENTS_RECEIVE,
66    SCOPE_PAYMENTS_SEND, SCOPE_PRESENCE_REPRESENT, SCOPE_TRANSACT_PURCHASE, SCOPE_TRANSACT_SELL,
67};
68pub use receipts::{
69    bundle_hash, issue_policy_verdict, issue_verification_receipt,
70    policy_verdict_sign_bytes_buf, receipt_hash, verification_receipt_sign_bytes_buf,
71    verifier_context_hash, verify_policy_verdict, verify_verification_receipt,
72};
73pub use types::{
74    AgentIdentity, Anchor, AnchorResolver, AuditProvider, Constraint, ConstraintEvaluator,
75    DelegationCert, HumanRoot, HybridPrivateKey, HybridPublicKey, HybridSignature, IdentityStatus,
76    KeyRotationStatement, PolicyProvider, PolicyVerdict, ProofBundle, ReceiptParty,
77    ReceiptPartySignature, RevocationList, RevocationProvider, RevocationPush, SessionToken,
78    StreamContext, TransactionReceipt, TransactionReceiptResult, VerificationReceipt,
79    InvocationCounter, VerifierContext, VerifyOptions, VerifyResult, WitnessEntry,
80    CHALLENGE_WINDOW_SECONDS,
81    ED25519_PUBLIC_KEY_SIZE, ED25519_SIGNATURE_SIZE, MAX_DELEGATION_CHAIN_DEPTH,
82    MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE, NO_EXPIRY_SENTINEL, PROTOCOL_VERSION,
83};
84#[allow(deprecated)]
85pub use verify::verify_streamed_turn;
86pub use verify::{
87    verify_bundle, verify_streamed_turn_with_options, verify_transaction_receipt, StreamedTurn,
88    StreamedVerifyOptions,
89};