GitHub

event_log_encryption

API reference for event_log_encryption.

End-to-end encryption of the entries an event log sends to a remote (Effect's eventlog/EventLogEncryption).

Entries go in batches of at most 100 entries or 256 KiB of payload (a larger entry is a batch alone), each encrypted with AES-256-GCM under the key derived from the identity's root secret. The additional data binds a batch to its store and entry ids, so a server cannot move it to another store or relabel it. layer runs on the pyfect.crypto services in context; layer_subtle (Effect's name, for WebCrypto's crypto.subtle) on their Web Crypto layers. Both need the extra pyfect-dev[eventlog].

Values

AttributeTypeDescription
makeEffect[EventLogEncryptionService, Never, aead.Aead | digest.Digest | secure_random.SecureRandom]

An EventLogEncryptionService from the pyfect.crypto services. Each identity's AES-256-GCM key is derived from its root secret with Digest and cached per identity; batches are encrypted with Aead under a random 12-byte nonce from SecureRandom, which also generates identities. A batch that fails authentication, or whose entries are not its entry ids, is a defect.

layerLayer[EventLogEncryption, Never, aead.Aead | digest.Digest | secure_random.SecureRandom]

EventLogEncryption from the Aead, Digest and SecureRandom services: choose the crypto layers yourself, such as pyfect.crypto.native's.

layer_subtleLayer[EventLogEncryption]

EventLogEncryption on the Web Crypto layers of Aead, Digest and SecureRandom, which run on the WebCrypto reference.

Classes

Functions

remote_batch

remote_batch(sequence, batch) -> EncryptedRemoteBatch
ParameterTypeDescription
sequenceint
batchEncryptedBatch

Returns EncryptedRemoteBatch

def remote_batch(sequence: int, batch: EncryptedBatch) -> EncryptedRemoteBatch:
    return EncryptedRemoteBatch(
        sequence=sequence,
        entry_ids=batch.entry_ids,
        iv=batch.iv,
        encrypted_batch=batch.encrypted_batch,
    )

make_encryption_subtle

make_encryption_subtle(crypto) -> Effect[EventLogEncryptionService]

make on the Web Crypto layers of Aead, Digest and SecureRandom, running on crypto.

ParameterTypeDescription
cryptoweb.Crypto

Returns Effect[EventLogEncryptionService]

def make_encryption_subtle(crypto: web.Crypto) -> Effect[EventLogEncryptionService]:
    """``make`` on the Web Crypto layers of ``Aead``, ``Digest`` and
    ``SecureRandom``, running on ``crypto``."""
    # ``local`` keeps enclosing Web Crypto layers, built on another
    # ``Crypto``, from being reused.
    return make.pipe(
        provide_layer(_layer_web_crypto.pipe(provide_layer(web.layer(crypto))), local=True)
    )