Grid · Section

Encryption

CLE and GLE, two encryption modes

Security model

Encryption.

Grid has two encryption modes. They are orthogonal; each can be used alone or both together. Pick deliberately.

ModeVerbScopeAfter encryption you can see
Cell-Level Encryption (CLE)lock / unlockEach cell's body, if its sensitivity is above publicAddresses, types, written-by, written-at, sensitivity labels
Grid-Level Encryption (GLE)seal / unsealThe entire file as one opaque blobThe grid's coordinate (in the wrapper prefix); nothing else

Both modes use grid-aware key derivation. For the CLI commands, see CLI.


CLE: Cell-Level Encryption

grid lock walks the grid and encrypts the body of every cell whose sensitivity is above public. The cell's address, type, written-by, written-at, and sensitivity label remain in plaintext on disk. Only the body is replaced by ciphertext.

Keys are derived per-level. The team key encrypts team-sensitivity bodies; the private key encrypts private bodies; the sealed key encrypts sealed bodies. Sharing the team key lets a reader see team-level cells without exposing private or sealed bands.

grid unlock reverses the operation using the same passphrase.

CLE is the right mode when you want the grid's structural shape to remain inspectable but the contents of sensitive cells protected at rest.

GLE: Grid-Level Encryption

grid seal encrypts the entire file as one opaque blob. The result is a text wrapper of the form:

GLE:1:[x,y,z]:<base64 payload>

where [x,y,z] is the grid's master coordinate. After sealing, the file is no longer a binary grid; grid status cannot parse it. The coordinate prefix is the only metadata visible from the outside; an observer learns the grid's coordinate but nothing about its contents.

grid unseal decrypts the wrapper and restores the binary grid file.

GLE is the right mode for archival, transport, or any location where you do not trust the host.

Layering

ModeState on disk
NeitherPlaintext grid. Development.
CLE onlyStructure visible; sensitive bodies encrypted.
GLE onlyEntire file opaque except for coordinate.
CLE + GLELock first, then seal. Two passes to recover.

To read a CLE+GLE grid: unseal first, then unlock. Both passphrases are needed.

Grid-aware key derivation

Both CLE and GLE keys are derived as:

passphrase_key = PBKDF2-HMAC-SHA512(
    passphrase, salt, 600,000 iterations, 32-byte intermediate output
)

grid_key = SHA-512( passphrase_key || SHA-512(genesis.body) )[:32]

The 32-byte PBKDF2 result is an intermediate, not the AES key itself. The AES key is grid_key: the final SHA-512 output truncated to 32 bytes. AES-256-GCM is the actual cipher for both CLE and GLE. The hash chain above derives the 32-byte AES key; AES-GCM does the encryption itself, with a fresh random nonce per encrypt operation.

The genesis cell's body hash is mixed into the key material. Two consequences:

  • Same passphrase, different grids → different keys. A leaked passphrase from one grid does not open any other grid, even if both were locked or sealed by the same operator.
  • If the genesis cell is rewritten, the derivation produces a different result. The file becomes unrecoverable. Grid refuses to rewrite genesis after the first write specifically to close this failure mode.

The salt is generated randomly at lock/seal time and stored alongside the ciphertext.

Keychain

~/.grid/keychain.grid is a local registry of grids you have sealed on this machine. It stores per-sealed-grid anchors as cells.

Each entry has:

FieldContent
address@/keys/<short-genesis-gha>
coordinate[x, y, z] master coordinate
genesis-ghaFull 256-character hex GHA of the genesis cell
digestSHA-512 of the genesis body (the input to key derivation)
fileLast-known path of the sealed grid
sealed-atISO timestamp
sealed-byIdentity that performed the seal

The keychain is local to your machine. It is never networked. grid unseal looks up the entry by coordinate to recover the digest needed for grid-aware key derivation.

Recovery

A sealed grid is recoverable if and only if you have:

  1. The passphrase
  2. The grid's coordinate (visible from the GLE prefix on the sealed file)
  3. Either the keychain entry on this machine or an exported copy of the digest (the digest: field from a saved keychain entry)

The recovery code printed at seal time is the genesis GHA hex. Save it somewhere durable. If you lose your keychain, you cannot recover a grid-aware sealed file from the genesis GHA alone; the key derivation uses the SHA-512 of the genesis body, which is stored in the digest: field of the keychain entry. The GHA is the human-readable anchor; the digest: field is the cryptographic input.

A future revision will combine these into a single recovery code that contains both.

What encryption does not protect

  • The fact that the grid exists. A sealed file on your disk is still a file. Encryption hides contents, not existence.
  • The coordinate. The GLE prefix exposes [x, y, z]. This is by design; coordinate is grid identity, used for cross-references.
  • Operational data. File timestamps, file size, the fact that you wrote to this grid at 2 a.m.; none of that is encrypted.
  • Side channels. If you display a sealed grid's contents on screen after unsealing, the screen has the plaintext. Encryption is at rest; cognition during use is your responsibility.
  • History. lock encrypts the live projection of each cell, the version that study: would return. The append-only chain preserves every prior version, including the plaintext that existed before the lock. If a cell carried sensitive content before being locked, that plaintext remains in the chain log. The protection lock provides is "from this point forward, the live read returns ciphertext"; it is not "this body has never been on disk in plaintext". For true erasure of past plaintext, seal the entire grid. GLE encrypts the whole file including history.

Recommended pattern

  • Working grids on your local machine: plaintext.
  • Grids you archive or ship: GLE-sealed. Back up the keychain entry (or the digest: field within it).
  • Grids with mixed-sensitivity content that need structural inspection by some readers (e.g. an auditor seeing types but not bodies): CLE-locked. Share level keys with the readers who need them.
  • Grids that should be both opaque-on-disk and per-level encrypted: lock then seal.

We use cookies to analyze site traffic and improve your experience. By accepting, you consent to the use of cookies for analytics and advertising purposes.