[KongchangAI]
· 4 min read· 2,041 words

FLOE: A Lightweight Online Encryption Scheme for Random Access to Large Files

FLOE: A Lightweight Online Encryption Scheme for Random Access to Large Files

FLOE proposes a random-access authenticated encryption scheme that solves the memory bottleneck in large-file decryption while meeting FIPS compliance.

FLOE is a random-access authenticated encryption scheme proposed by Snowflake engineer Greg Rubin and others, aimed at solving the problem that traditional AEAD (such as AES-GCM) memory usage grows linearly with file size when decrypting very large files. FLOE takes random access as a first principle and, through designs such as moving segment position information from the IV to the AAD, adding segment headers and a ciphertext header, and using a key schedule, simultaneously satisfies streaming processing, random access, and FIPS 140-3 compliance requirements. The team also proposed the RAAE scheme and the RAROR security notion, proving it is strictly stronger than the existing NOAE2 model and providing security definitions for commitment and error messages. Benchmarks show FLOE's decryption memory is on par with encryption, random-access multithreaded throughput is network-limited, and encryption overhead is minimal. FLOE has built-in key-misuse security via a key schedule but supports only write-once-read-many; segment rewriting remains an open problem.

In cryptographic engineering practice, a long-standing dilemma for developers is that standard AEAD (such as AES-GCM) requires verifying the integrity of the entire ciphertext before decryption, which causes memory usage to grow linearly with file size when decrypting very large files. FLOE, proposed by Snowflake engineer Greg Rubin and his collaborators, is a random-access authenticated encryption scheme designed to solve exactly this pain point.

The Root Problem: The Lack of Random Access in Streaming Encryption

In his talk, Greg shared a real case: an internal team needed to encrypt a very large file and, due to compliance requirements, had to use AES-GCM. As a result, memory was exhausted during decryption. The reason is that all traditional AEAD schemes must check the integrity of the complete ciphertext before returning the first plaintext byte. For very large files, the memory required for decryption is roughly twice the file size itself, which is completely infeasible in big-data scenarios.

The requirements list the team proposed seemed ordinary but was difficult to satisfy simultaneously: streaming processing (constant memory), random access (the ability to read data at arbitrary offsets), and FIPS 140-3 compliance (using approved KDFs such as AES-GCM with random IVs and HKDF). These requirements are very common in the industry, and many companies face the same problem.

Segment length

The Fatal Flaw of Naive Segmentation

The most intuitive solution is to split a large file into small chunks and encrypt each separately, but this introduces inter-segment attacks. An attacker can swap two encrypted segments, changing the decrypted result from "I like apples but not cake" to "I like cake but not apples"; they can also delete segments or truncate the ciphertext. Segmented AEAD guarantees intra-segment integrity but cannot defend against cross-segment manipulation.

Existing streaming encryption schemes (such as Stream and Tink Streaming) solve inter-segment attacks by encoding the segment number and termination flag in the IV, but this makes the IV non-random and thus violates FIPS compliance requirements. To use non-random IVs under the FIPS framework, one usually needs to go through a specific approved algorithm list, complete construction within a validated module, or submit one's own module for FIPS validation—Greg explicitly stated that he was unwilling to bear the heavy cost of submitting a module for validation.

AEAD (Authenticated Encryption with Associated Data) is a class of encryption schemes that provides both confidentiality and integrity, commonly including AES-GCM and ChaCha20-Poly1305. Its decryption process must verify the authentication tag of the complete ciphertext before outputting plaintext, which guarantees security but also makes it impossible to stream-process very large files with constant memory. FIPS 140-3 is the standard used by the U.S. federal government to validate the security of cryptographic modules; compliance requires the use of approved algorithms and random IVs, among other things. Many enterprises must use AES-GCM due to compliance requirements, and the random IV of AES-GCM means that each encryption requires a large amount of randomness, which becomes a performance bottleneck when encrypting large files in segments.

FLOE's Design: Random Access as a First Principle

The core idea of FLOE is the opposite of previous schemes: rather than first designing streaming encryption and then patching in random access, it rebuilds from random access as the foundational model. Greg wrote the initial version in less than a week; the real difficulty lay in proving its security.

Key Structural Changes

FLOE retains the segmented structure but makes several important adjustments:

  • Segment position information is moved from the IV to the AAD: This allows the IV to use random values again, satisfying FIPS requirements.
  • Added segment headers: They encode the random IV, the segment length, and a flag indicating whether it is the last segment, making streaming decryption simpler to implement and memory management more efficient.
  • Ciphertext header: It contains the ciphertext-level IV, encryption parameters (segment length, IV length, AAD/KDF identifiers), and a tag that guarantees header integrity; this tag also provides the commitment property.
  • Key schedule: A new key is derived every 2^20 segments, allowing a single top-level key to encrypt exabyte-scale data. The KDF uses HKDF-Expand and mixes in all parameters, the ciphertext-level IV, and developer-provided AAD, preventing tampering and supporting secure in-band signaling of parameters.

we'd have more than four in a row

Security Model: Redefining Random-Access Authenticated Encryption

Greg admitted that he is not a theoretical cryptographer but rather a "plumber"-style cryptographic engineer. However, the security proof work for FLOE was completed by collaborator Andres Fabrega and others, and it introduces new formal definitions.

RAAE and RAROR Security

Existing models (such as NOAE and its successor NOAE2 proposed by Huang et al.) have three problems: they do not cover the security of random-access encryption, they lack a commitment definition, and their proofs are complex and unintuitive. The FLOE team proposed the RAAE (Random-Access Authenticated Encryption) scheme, which takes segment position as an explicit input and requires only one sub-algorithm each for encryption and decryption. The accompanying RAROR security notion applies the standard AEAD real-or-random definition at the per-segment level, allowing the adversary to make encryption and decryption queries in any order and across multiple messages.

The team proved that RAROR is strictly stronger than NOAE2: every RAROR-secure scheme is NOAE2-secure, but not vice versa. They constructed a scheme that is NOAE2-secure under sequential encryption but broken when out-of-order encryption is allowed, as a separation proof. At the same time, existing schemes remain secure under RAROR.

NOAE (Nonce-based Authenticated Encryption) is a security model for streaming encryption proposed by Huang et al., later extended to NOAE2. These models mainly focus on security under sequential encryption and do not consider scenarios in random-access settings where an adversary may request decryption out of order. RAROR (Random-Access Real-or-Random) is a new security notion proposed by the FLOE team; it generalizes the standard real-or-random indistinguishability definition to per-segment encryption and allows the adversary to make encryption and decryption queries in any order across multiple messages. RAROR is strictly stronger than NOAE2, meaning that schemes satisfying RAROR automatically satisfy NOAE2, but not vice versa. This stronger model better fits the actual usage scenarios of random access.

Commitment Property and Error-Message Security

The FLOE ciphertext header provides contextual commitment: a single ciphertext can be decrypted only under one key, nonce, and AAD triple. This differs from Stream and Tink—their commitment security relies on the commitment property of the underlying AEAD, whereas AES-GCM and ChaCha20-Poly1305 do not have the commitment property. FLOE's position-free commitment relies only on the collision resistance of the KDF, and is therefore independent of the AEAD choice. However, FLOE does not provide positional commitment; the team believes that in practical scenarios it is difficult for attackers to control the segment position indicator, so the additional byte overhead is not worthwhile.

Error messages are FLOE's most controversial feature. Greg mentioned that a Reddit user strongly opposed providing detailed error messages in cryptography. But FLOE incorporated error messages into its security definition from the outset, introducing the RAROR-error notion and proving—by equipping the ideal world with an error simulator that does not know the key—that returning correctly distinguishing error messages does not give attackers any additional advantage. These error messages are consistent with the distinguishing errors that many platform APIs already return before calling the underlying cryptographic implementation; the difference is that there is now a security proof.

What is a bit more subtle are those concrete security bounds.

Commitment means that a ciphertext can be decrypted only under one specific combination of key, nonce, and AAD, preventing attackers from reusing the same ciphertext in different contexts. AES-GCM and ChaCha20-Poly1305 do not have the commitment property, meaning an attacker may construct ciphertexts that decrypt successfully in different contexts. FLOE provides contextual commitment through a tag in the ciphertext header, and its security relies only on the collision resistance of HKDF, so it is independent of the choice of underlying AEAD. Error-message security concerns whether the error information returned when decryption fails leaks sensitive information. The traditional view is that a uniform error should be returned, but FLOE shows through a formal proof that returning distinguishing errors (such as "invalid segment length" or "invalid tag") does not give attackers any additional advantage, as long as the error simulator does not know the key.

Engineering Trade-offs and Performance

then the ideal function just always return

Parameter Choices and Trade-offs

FLOE allows developers to control only the segment length, because segment length does not break security (it only affects memory and throughput). Shorter segments reduce memory requirements and increase the security margin, but they increase RNG throughput pressure—in benchmarks, random nonce generation became the bottleneck when encrypting with small segments. AES key scheduling overhead is not noticeable with larger segments, but it becomes apparent with extremely small segments. Specific parameters and recommended values are given in the paper and public specification.

Real Benchmark Tests

Greg did a rough comparison using Java streaming on a laptop. When encrypting a GB-scale file, AES-GCM and FLOE took comparable time, with FLOE using slightly more memory to load additional libraries. But during decryption the gap was stark: AES-GCM took significantly longer and its memory usage reached more than ten times the file size, with time mainly spent on memory management; FLOE's decryption time and memory usage were basically on par with encryption.

The advantage of random access is even more obvious in multithreaded scenarios. For a ten-GB-scale file, a program that sequentially encrypts, uploads, downloads, and decrypts took about several minutes, limited by CPU; when using random access and multithreading to process random-sized chunks, the time was roughly halved, with throughput reaching about one gigabit per second, making the network the bottleneck, while FLOE's own overhead was too small to measure.

Key-Misuse Security and Open Problems

FLOE has a built-in key schedule, so that using the same key for both FLOE and other algorithms does not affect FLOE's own security (provided that the other algorithm has no key-recovery attacks and does not include FLOE's KDF). Greg emphasized that this part of the proof was not included in the paper due to space constraints and has not yet undergone peer review, but the team is confident in the proof. He used this to call on the cryptography community to take key misuse as seriously as nonce misuse: since developers will inevitably reuse keys, algorithm design should tolerate such mistakes as much as possible.

FLOE currently supports only write-once-read-many (WORM). Allowing segment rewriting would introduce rollback attacks: an attacker could replace an old segment into a new ciphertext, constructing a valid ciphertext that was never produced by the encryptor. Greg said this is a more fundamental open problem than construction, and existing approaches (a single global tag, Merkle trees, etc.) all have significant practical costs; he hopes to collaborate with interested researchers to advance it.

FLOE's public specification has been published on GitHub, with reference implementations in four languages; third parties have contributed concise Zig and Rust implementations, and it has been incorporated into a community cryptographic specification project. For teams that need compliant, large-file, random-access encryption, this is a new option worth evaluating.

One-line Summary

FLOE proposes a random-access authenticated encryption scheme that solves the memory bottleneck in large-file decryption while meeting FIPS compliance.

Paragraph Summary

FLOE is a random-access authenticated encryption scheme proposed by Snowflake engineer Greg Rubin and others, aimed at solving the problem that traditional AEAD (such as AES-GCM) memory usage grows linearly with file size when decrypting very large files. FLOE takes random access as a first principle and, through designs such as moving segment position information from the IV to the AAD, adding segment headers and a ciphertext header, and using a key schedule, simultaneously satisfies streaming processing, random access, and FIPS 140-3 compliance requirements. The team also proposed the RAAE scheme and the RAROR security notion, proved that it is strictly stronger than the existing NOAE2 model, and gave security definitions for commitment and error messages. Benchmarks show that FLOE's decryption memory usage is on par with encryption, throughput in random-access multithreaded scenarios is network-limited, and encryption overhead is minimal. FLOE has a built-in key schedule for key-misuse security, but it supports only write-once-read-many; segment rewriting is an open problem to be solved.

#FLOE#random-access authenticated encryption#FIPS 140-3#AES-GCM#streaming encryption#RAROR#Snowflake
Share:

Related articles