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.
  • pqcrypto-mldsa — PQClean-based ML-DSA-65 (FIPS 204).

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.
revocation_push_sign_bytes
Canonical bytes signed to produce RevocationPush.signature.
revocation_sign_bytes
Canonical bytes signed to produce RevocationList.signature.
session_token_sign_bytes
Canonical MAC-input bytes for a SessionToken. The MAC itself is excluded from the signable (a MAC cannot cover itself).
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.
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.