cadrumo.core.ed25519_signing module¶
Ed25519 signing primitive used by the review-package signing surface.
The review-package signer signs a checksum-manifest digest with Ed25519 and
keeps its profile key in encrypted secure storage. Its custody, envelope
metadata, and error vocabulary stay in
review_package_signing; the cryptography lives
here.
What this module owns is deliberately narrow: key generation, the raw-bytes hex projection the signer persists, and the sign / verify pair over a hex-encoded digest. It knows nothing about manifests, bundles, packages, files, or storage, so it cannot acquire a custody policy by accident.
The digest is passed as HEX and decoded here, because that is the shape both
callers hold – manifest_sha256 is a hex string on the wire and in every
persisted record. Signing the decoded 32 raw bytes (not the 64 ASCII
characters) is the property that must not drift between the two surfaces: a
verifier that decoded differently from the signer would reject every genuine
signature, and the failure would look like key mismatch rather than an
encoding bug.
See also
review_package_signingReview-package signing built on this primitive.
- class Ed25519KeypairHex(private_key_hex, public_key_hex)[source]¶
Bases:
NamedTupleA freshly generated Ed25519 keypair in the raw-bytes hex form callers persist.
Both halves are 32 raw bytes rendered as 64 hex characters. The private half is secret: a caller is responsible for its custody (a permission-hardened file, or encrypted secure storage), and this type carries no persistence policy of its own.
- generate_ed25519_keypair_hex()[source]¶
Mint a fresh Ed25519 keypair and project both halves to raw-bytes hex.
- Return type:
- ed25519_private_key_from_hex(private_key_hex)[source]¶
Reconstruct a live private key from its stored raw-bytes hex.
- Return type:
Ed25519PrivateKey- Parameters:
private_key_hex (str)
- ed25519_public_key_from_hex(public_key_hex)[source]¶
Reconstruct a live public key from its stored raw-bytes hex.
- Return type:
Ed25519PublicKey- Parameters:
public_key_hex (str)
- sign_digest_hex(*, private_key_hex, digest_hex)[source]¶
Sign a hex-encoded digest, returning the signature as hex.
The digest is decoded to raw bytes before signing; see the module docstring for why that decode must be shared with the verifier.
- digest_signature_is_valid(*, public_key_hex, digest_hex, signature_hex)[source]¶
Return whether
signature_hexis a valid signature overdigest_hex.Returns
Falserather than raising on an invalid signature: both callers treat “signed by someone else” and “tampered” as ordinary negative verification outcomes to report, not as exceptional control flow. A malformed hex input still raises, because that is a caller bug rather than a verification verdict.