Skip to main content

Module crypto

Module crypto 

Source
Expand description

Ratify Protocol v1 — hybrid (Ed25519 + ML-DSA-65) crypto primitives.

Uses:

  • ed25519-dalek — audited Ed25519, pure Rust.
  • fips204 — pure-Rust ML-DSA-65 (FIPS 204), no_std compatible.

Every sign produces BOTH component signatures. Every verify checks BOTH; either failure fails the whole signature.

Functions§

chain_hash
32-byte SHA-256 of the concatenated delegation_sign_bytes of each cert. Used as a stable chain identity inside SessionToken — a cert rotation changes chain_hash, invalidating every token issued against the old chain.
challenge_sign_bytes
Canonical bytes signed to produce ProofBundle.challenge_sig.
challenge_sign_bytes_with_session_context
v1.1 session-bound challenge signable bytes: challenge || big-endian uint64(ts) || session_context.
challenge_sign_bytes_with_stream
v1.1 stream-bound challenge signable bytes. Layout: challenge || big-endian uint64(ts) || [session_context] || stream_id || big-endian int64(stream_seq).
delegation_sign_bytes
Canonical bytes signed to produce DelegationCert.signature.
derive_id
hex(SHA-256(ed25519_pub || ml_dsa_65_pub)[:16]).
generate_agent
Generate a fresh AgentIdentity.
generate_challenge
32 cryptographically random bytes from OS RNG.
generate_human_root
Generate a fresh HumanRoot (public + private).
generate_hybrid_keypair
Fresh hybrid keypair from OS randomness. Two independent seeds.
issue_delegation
issue_key_rotation_statement
issue_revocation_list
issue_revocation_push
issue_session_token
Issue a SessionToken from a previously verified bundle’s result. Callers MUST only invoke this after verify_bundle returned valid=true.
issue_witness_entry
key_rotation_sign_bytes
Canonical bytes signed by both old and new keys in KeyRotationStatement. Keys: new_id, new_pub_key, old_id, old_pub_key, reason, rotated_at, version.
revocation_push_sign_bytes
Canonical bytes signed to produce RevocationPush.signature. Keys: entries, issuer_id, pushed_at, seq_no.
revocation_sign_bytes
Canonical bytes signed to produce RevocationList.signature. Keys: issuer_id, revoked_certs, updated_at.
session_token_sign_bytes
Canonical MAC-input bytes for a SessionToken. The MAC itself is excluded from the signable (a MAC cannot cover itself). Keys: agent_id, agent_pub_key, chain_hash, granted_scope, human_id, issued_at, session_id, valid_until, version.
sign_both
Produce a hybrid signature. Both components over identical msg.
sign_challenge
sign_challenge_with_session_context
sign_challenge_with_stream
sign_transaction_receipt_party
Produce a party’s hybrid signature over the receipt’s canonical signable.
transaction_receipt_sign_bytes
Canonical bytes that every party signs to bind a TransactionReceipt. Parties are sorted lex by party_id; party object keys: agent_id, agent_pub_key, party_id, role. Outer keys: created_at, parties, terms_canonical_json, terms_schema_uri, transaction_id, version.
verify_both
Verify both components. Returns Ok iff both verify; Err with diagnostic.
verify_challenge_signature
verify_challenge_signature_with_session_context
verify_challenge_signature_with_stream
verify_delegation_signature
verify_delegation_signature_e
verify_key_rotation_statement
verify_revocation_list
verify_revocation_push
verify_session_token
verify_session_token_e
Check a SessionToken’s HMAC against session_secret and its validity window against now (unix seconds). Returns Ok on success.
verify_witness_entry
witness_entry_sign_bytes
Canonical bytes signed to produce WitnessEntry.signature. Keys: entry_data, prev_hash, timestamp, witness_id.