cadrumo.core.hex module¶
Shared lowercase-hex field patterns for cryptographic material.
One canonical home for the two hex shapes the signing and encryption
boundaries validate at, consumed by
application.modelo.review_package_signing.SignedReviewPackage and
application.modelo.review_package_counter_sign.CounterSignedReceipt. Keeping the patterns in
core lets the review-package signing and receipt-encryption boundaries
share one declaration without either importing the other.
The patterns are the structural gate only: they fix the encoding (lowercase
hex) and the exact decoded length. They say nothing about whether the decoded
bytes are a well-formed key, digest, or signature – that is the
cryptography primitive’s job at use time.
Every name counts HEX CHARACTERS, not decoded bytes: HEX_PATTERN_64
admits 32 decoded bytes and HEX_PATTERN_128 admits 64.
HEX_PATTERN_16 is not cryptographic material at all – it is the
shape of a TRUNCATED digest used as a short content address, and it lives
here so the truncated form is declared once beside the full one rather than
as an inline constraint at each carrier.
- HEX_PATTERN_64¶
Exactly 64 lowercase hex characters, i.e. 32 decoded bytes.
The shape of a SHA-256 digest and of a raw Ed25519 or X25519 key.
- HEX_PATTERN_16¶
a SHA-256 digest truncated to 8 bytes.
The shape of a short CONTENT ADDRESS rather than a full digest – notably
domain.filing.schema.compute_modelo_draft_id(), which content-addresses a filing draft by the first 16 hex characters of its payload hash. A truncated digest is a weaker collision claim than the full 64 and must never be used where a cryptographic digest is required; it exists so a human-quotable identifier can still be re-derived and compared.- Type:
Exactly 16 lowercase hex characters
- HEX_PATTERN_128¶
Exactly 128 lowercase hex characters, i.e. 64 decoded bytes.
The shape of a raw Ed25519 signature, whose 64-byte size is fixed by RFC 8032. Because the pattern pins the length exactly, a value that matches it is already guaranteed to decode to a correctly-sized signature; no separate length check is needed at the pydantic boundary.