Skip to main content

Crate qhermes_kernel

Crate qhermes_kernel 

Source
Expand description

Cryptographic and authorization primitives for QHermes delegation chains.

§Layers

Crypto     — key derivation and ML-DSA-65 signing/verification
Policy     — permission encoding, scope subset enforcement, caveat evaluation
Delegation — credential issuance and chain verification
Wire       — credential chain serialization and deserialization

§Permission format

[res_len: u8][resource bytes][verb_len: u8][verb bytes]

§Wire format

[version: u8 = 0x01][count: u32 LE][credentials...]
[issuer_pk: PK_SIZE][signature: SIG_SIZE][payload_len: u32 LE][payload bytes]

§Timestamps

All Timestamp values are seconds since the Unix epoch. Passing milliseconds or nanoseconds produces incorrect caveat evaluation.

§Domain separation

IdentityIsland::derive folds deployment and context into the HKDF info parameter. Different deployment values yield independent key material even when sharing the same master.

Structs§

BoundedCaveats
Validated sequence of fixed-size caveat records.
BoundedScope
Validated, non-empty TLV sequence of permissions.
Credential
One link in a serialized credential chain as it appears on the wire.
DelegationManifest
Parameters for issuing a credential in a delegation chain.
Depth
Sequential position of a credential within its delegation chain. The first credential issued by the root has depth 1.
IdentityIsland
ML-DSA-65 identity deterministically derived from a master seed via HKDF-SHA3-512.
PublicKey
Reference to a PK_SIZE-byte ML-DSA-65 public key.
ScopeIter
Signature
Reference to a SIG_SIZE-byte ML-DSA-65 signature.
Timestamp
Timestamp in seconds since the Unix epoch.

Enums§

KernelError
Errors returned by QHermes kernel operations.
Role
Role encoded in a credential payload.

Constants§

CAVEAT_SIZE
Byte length of one serialized caveat record: 1-byte tag + 8-byte timestamp.
CREDENTIAL_FIXED_SIZE
Fixed bytes per credential record, excluding the payload: PK_SIZE + SIG_SIZE + 4 (payload_len field).
MAX_CAVEATS
Maximum number of caveats in a credential.
MAX_DEPTH
Maximum depth of a delegation chain. Longer chains are rejected at issuance, verification, and deserialization.
MAX_PAYLOAD_SIZE
Maximum byte length of a payload, assuming all permissions at maximum TLV size and all caveat slots occupied.
MAX_SCOPE_PERMS
Maximum number of permissions in a credential scope.
PERM_TLV_MAX
Maximum byte length of the TLV encoding of one permission: 1 (res_len) + RESOURCE_LEN + 1 (verb_len) + VERB_LEN.
PK_SIZE
Byte length of an ML-DSA-65 public key (verifying key).
RESOURCE_LEN
Maximum byte length of the resource field in a permission. Fits a u8-typed TLV length prefix.
SEED_SIZE
Byte length of the HKDF seed and derived key material.
SIG_SIZE
Byte length of an ML-DSA-65 signature.
VERB_LEN
Maximum byte length of the verb field in a permission. Fits a u8-typed TLV length prefix.

Traits§

IdentitySigner
Signing interface for any ML-DSA-65 identity: in-memory keys, HSM, TPM, or enclave.

Functions§

enforce_scope_subset
Checks that every permission in child is covered by at least one permission in parent.
evaluate_caveats
Evaluates all caveats in caveats against now.
issue_credential
Serializes manifest into payload_out and signs it into sig_out.
not_after
Constructs a not-after caveat record.
not_before
Constructs a not-before caveat record.
perm_tlv
Encodes a (resource, verb) permission into out using TLV format.
read_credential_chain
Deserializes wire into chain. All slices point into wire. Returns the credential count.
verify_delegation
Verifies a credential chain rooted at root_pk against timestamp.
verify_signature
Verifies an ML-DSA-65 signature over payload under pk.
write_credential_chain
Serializes chain into out. Returns bytes written, or WireTruncated if out is too small.