Encryptor.Ecto

CIHex.pm VersionHex DownloadsHex DocsLicense

Encrypted Ecto types for the Encryptor vault - cloak_ecto-shaped field encryption, where a schema field is declared encrypted once and every read and write in the application goes through the vault without the calling code knowing.

Status: design phase. Nothing is implemented yet. The package holds a skeleton and a set of records. The contracts are being decided in ADRs first, on purpose: a blind-index construction, an encryption-context field, or a ciphertext layout chosen inline in an implementation commit is a defect here even when the choice happens to be a good one, because the record is what makes it reviewable.

RecordStatusSubject
ADR-0001accepted, with amendmentsThe types, the closed option set, the encryption context, tenant resolution
ADR-0002acceptedThe migrator: plan-driven, probe-first, compare-and-swap, live traffic
ADR-0003accepted, with one amendmentKeyed blind indexes, per-tenant by default, equality only
ADR-0004proposedAdoption: the migration runbook, the task family, the mixed window

The implementation graph derived from them is docs/plans/260827-ece-wdm-c3-implementation-graph.md.

Everything below describes what the accepted records decide, not a shipped API. Nothing here is a compatibility promise until it exists and is released.

The charter

Encryptor answers the key-management questions: where key material comes from, which key a given record's data belongs to, and how that key rotates. What it does not do is put any of that behind a schema field. Hand-rolling that glue is where application-level encryption usually goes wrong - the cast, load, and dump arms disagree about nil, the ciphertext lands in a column nobody remembered to widen, and the tenant a value belongs to gets resolved a slightly different way at every call site.

This package is that glue, in the shape Ecto already expects:

The vault stays Encryptor. This package wraps it for the Ecto layer only; it adds no key management of its own, and no dependency beyond Ecto, the vault, and a JSON serializer for the map type. It issues no DDL, and its task list contains no verb that operates on a key: rotating the key-encrypting key and crypto-shredding a tenant are the vault's operations, not this package's.

Installation

def deps do
[
{:encryptor_ecto, "~> 0.1"}
]
end

Not yet published to Hex. encryptor is not published yet either, so during bootstrap the vault dependency is pinned to a git SHA rather than a Hex version.

License

Apache-2.0 - see LICENSE.