cadrumo.application.modelo.recipient_encryption module

Application-owned contract for recipient-encrypted review packages.

The review-package use cases need one capability for three operations: minting the bucket’s recipient keypair, sealing bytes for a public key, and opening an envelope with a private key. The capability deliberately exposes only these application DTOs and errors. Its concrete implementation belongs to an outward persistence/crypto adapter and is supplied by an executable composition root.

class RecipientEncryptionKeypair(**data)[source]

Bases: BaseModel

The transient, typed keypair payload owned by the application boundary.

The adapter stores this payload through secure persistence. Private and public key material remain hex strings here so the application contract does not expose a cryptography implementation type.

Parameters:

data (Any)

bucket_id: BucketId
private_key_hex: str
public_key_hex: str
created_at: UtcInstant
class RecipientEncryptedPackage(**data)[source]

Bases: BaseModel

Wire envelope for a review package sealed for one recipient.

Parameters:

data (Any)

envelope_version: int
ephemeral_public_key_hex: str
recipient_public_key_hex: str
ciphertext: bytes
envelope_nonce_hex: str
issued_at: UtcInstant
valid_until: UtcInstant | None
review_only: bool
class RecipientDecryptedPackage(**data)[source]

Bases: BaseModel

Recovered package bytes plus the envelope’s disposition flag.

Parameters:

data (Any)

package_bytes: bytes
review_only: bool
class RecipientEncryptionCapability(*args, **kwargs)[source]

Bases: Protocol

Application-facing recipient-encryption capability.

Implementations may use persistence and cryptography internally, but they must translate those concrete DTOs and failures to this contract before returning or raising across the application boundary.

ensure_keypair(*, bucket_id, generated_at=None)[source]

Return or mint the bucket-scoped recipient keypair.

Return type:

RecipientEncryptionKeypair

Parameters:
encrypt(package_bytes, *, recipient_public_key_hex, review_only=False, valid_for=None, issued_at=None)[source]

Seal package bytes for one recipient public key.

Return type:

RecipientEncryptedPackage

Parameters:
decrypt(envelope, *, recipient_private_key_hex, now=None)[source]

Open one envelope with the recipient’s private key material.

Return type:

RecipientDecryptedPackage

Parameters:
class RecipientEncryptionCapabilityFactory(*args, **kwargs)[source]

Bases: Protocol

Construct a capability bound to one bucket’s secure-object store.