Pseudorandom Error-Correcting Codes
Miranda Christ, Sam Gunn
Introduction
The proliferation of AI-generated content is one of the biggest issues facing the internet today. Recent breakthroughs in large language models have made it increasingly difficult to distinguish this influx of AI-generated content from human-generated content.
A promising solution for detecting AI-generated content is watermarking, where a hidden signal is embedded in the content. Several major companies, including OpenAI and Google, have pledged to embed watermarks in content output by their models [BH23]. Despite this explosion of interest in watermarking, there are very few techniques for building watermarking schemes that do not noticeably alter the generated content. Existing schemes incur trade-offs between the quality of generated content, the robustness of the watermark, and the computational complexity of detection.
In this work, we take a new cryptographic approach to this problem that allows us to avoid some of these trade-offs. Our approach is based on a new cryptographic primitive that we call a pseudorandom error-correcting code, or simply a pseudorandom code (PRC). A PRC is an error-correcting code that is parameterized by a decoding key. The pseudorandomness property states that, without this decoding key, any polynomial number of codewords are pseudorandom.
We find that the problem of building robust, quality-preserving watermarks reduces to the problem of building PRCs. Essentially, the watermarking strategy is to replace some of the randomness used by the generative algorithm with outputs from a PRC.
Building PRCs is challenging: Error-correcting codes are typically highly structured, while pseudorandomness implies a lack of discernible structure. Indeed, a priori it is not clear that such objects should exist. Nonetheless, we construct PRCs from standard (subexponential) cryptographic assumptions. Our constructions are related to low-density parity-check codes, and we base pseudorandomness on the Learning Parity with Noise assumption. We construct PRCs with strong robustness properties, including robustness to any constant rate of substitution and deletion errors.
Applying these PRCs to watermarking for language models, we obtain the first quality-preserving language model watermarking schemes that are robust to cropping and any constant rate of substitution and deletion errors. That is, the watermark detector will work as long as it is provided any sufficiently-long sequence of text, even if that text is subjected to any constant (less than ) rate of random substitutions and any constant (less than ) rate of random deletions.
In this subsection we present a simple, general template for watermarking AI-generated content. The template described here can in principle be used to watermark arbitrary media, but we only present concrete instantiations in certain contexts (Sections 7 and 8).
In all generative AI settings there is a generative algorithm, , that defines the behavior of the AI. A user provides a prompt, and outputs some randomly-generated content. A watermarking scheme modifies so that the generated content contains a hidden pattern, called a watermark. There are two essential requirements that any watermarking scheme should satisfy:
Quality: embedding the watermark should not reduce the quality of generative algorithm; and
Robustness: the watermark should be detectable in generated content, even if this content is corrupted.
Achieving both of these properties simultaneously is the central challenge of watermarking. Quality means that the watermark should not significantly alter the generated content, while robustness seems to require the watermark to change the content a great deal.
In this work, we propose a new strategy for watermarking: replacing the randomness used by with codewords from a pseudorandom error-correcting code. A pseudorandom error-correcting code, or simply pseudorandom code (PRC), is a new cryptographic primitive that we introduce in this work. A PRC is defined by algorithms satisfying two properties:
Pseudorandomness: Any efficient adversary, without knowledge of the decoding key, cannot distinguish between oracle access to and an oracle that always outputs a fresh random string; and
Error correction or robustness: For any message , if and is a “corrupted” version of where the amount of corruption is bounded, then .
For watermarking the message can be simply , indicating the presence of a watermark.By instead encoding a longer message in the PRC, this technique extends to steganography — where messages are secretly communicated in innocent-looking content — as well.
In order to make detection possible, we specify in such a way that the detector can approximate the randomness used to produce any given content. To test for the presence of a watermark, the detector computes this approximation and then applies to the result. If the content is watermarked and the approximation is close enough to the true randomness, then robustness of the PRC ensures that returns 1. This indicates to the detector that the watermark is present. Stronger robustness of the PRC translates to stronger robustness of the watermark.
Pseudorandomness of the PRC guarantees that, without the decoding key, watermarked content is indistinguishable from content produced by the original generative algorithm — even if one is allowed to see many outputs. In particular, the quality of the generative algorithm is not deteriorated by the watermark. In [CGZ23], such a watermark is referred to as undetectable.
Therefore, the problem of building robust, quality-preserving watermarks reduces to building PRCs (and appropriately specifying ). Below, we describe the application of this template to watermarking for language models.
A generative language model is a randomized algorithm that takes as input a prompt, and samples text constituting a response. This text consists of tokens. For simplicity, we assume here that tokens are binary and that the full response is of a fixed length . Neither of these assumptions is important for our results, as discussed in Section 7.
Given any generative language model, it is not difficult to define an algorithm that takes a prompt and a random seed , and samples a response such that
if is uniformly random, then is distributed identically to the original model, and
each bit of is correlated with the corresponding bit of .
See Section 2.5 for an example of such an algorithm. Now it is easy to recover an approximation of the randomness that was used to produce a given text: just use the text itself.
One natural watermarking strategy is to use the same random seed for every call to , storing itself as the watermarking key. This is essentially the strategy used by [KTHL23], and it yields a highly robust watermark because the detector can compute the edit distance between the given text and . The resulting quality guarantee is that a single response from the watermarked model is distributed identically to a single response from the original model.
A PRC is exactly the object needed to avoid this tradeoff between response variability and efficiency. Our watermark detection key will be the decoding key for a PRC, and we will embed the watermark by sampling a fresh pseudorandom seed for each query to . This results in no observable correlations between responses, regardless of the number of queries — i.e., the watermark is undetectable. Since the same hidden structure is present in every sample from , our detector can simply apply to check for this structure. Now, the detector’s runtime has no dependence on the response variability. Using PRCs that we construct in Sections 5 and 6, we also find that our watermarking scheme can be made robust to a constant fraction of random substitution and deletion errors.
A note on undetectability.
Undetectability is a strong quality guarantee for watermarking. Outputs of the watermarked model must be computationally indistinguishable from outputs of the original model, even to a user who is allowed to make many queries. While this is imperative for steganography, its necessity in watermarking is less clear, as some noticeable changes to the model may be permissible as long as the outputs remain “high-quality.”
However, measuring the quality of watermarked content is often challenging or impossible — especially when the content is used in a wide range of applications. Computational indistinguishability is a strong quality guarantee that applies uniformly to every application: it implies that the watermark causes no observable loss in any efficiently-computable quality metric. Without such a guarantee, it is impossible to verify that a watermark is quality-preserving across all applications. We therefore focus on undetectability in this work.
2 Our contributions
Our first contribution is to identify PRCs as an interesting cryptographic primitive, with applications to robustly hiding messages in AI-generated content. Very roughly, the definition is as follows — for more details, see either the technical overview (Section 2.1) or the formal definitions (Section 4.1).
A pseudorandom code (PRC) is an error-correcting code where codewords are pseudorandom to any computationally-bounded adversary who doesn’t hold the decoding key.
We consider both public- and secret-key variants of PRCs. For a public-key PRC, the encoding algorithm can be made public without sacrificing pseudorandomness. When the message space consists of only a single message, we call it a zero-bit PRC. Zero-bit PRCs can also be viewed as robust backdoored (or trapdoor) pseudorandom generators [VV83, DGG+15], and they are sufficient for our applications to watermarking.
We show how to build zero-bit public-key PRCs related to low-density parity-check (LDPC) codes, where pseudorandomness rests on standard (subexponential) cryptographic assumptions. All of the PRCs we construct are over a binary alphabet. Depending on the parameter choices, the pseudorandomness of these LDPC-related codes is based on either of two assumptions, which we state together as 1.
LPN is hard for any -time adversary, or
LPN and planted XOR are both hard for any polynomial-time adversary.
For descriptions of the LPN and planted XOR assumptions, see either Section 2.2 or Section 5. Under 1, we prove that there exist PRCs with robustness to channels that introduce a bounded number of substitution errors. We say that any channel that introduces at most a fraction of substitution errors (and no other types of errors) is -bounded.
Let be any constant. Under 1, there exists a zero-bit public-key PRC that is robust to every -bounded channel.
For some applications it will be useful to have multi-bit PRCs. Any such construction should ideally have a high rate, which is the ratio of the number of message bits to the number of codeword bits. We prove that any zero-bit PRC can be combined with any error correcting code to give a multi-bit PRC.
Suppose that there exists a zero-bit (public-key) PRC and a rate- error-correcting code, that are both robust to every -bounded channel. Then there exists a (public-key) PRC of rate that is robust to every -bounded channel, for every constant .
Applying this theorem with our zero-bit LDPC-based PRCs and the binary error-correcting codes of [ABN+92, NN93, Ta-17], we have the following corollary.
Let be any constant. Under 1, there exists a constant-rate PRC that is robust to every -bounded channel.
None of the PRCs mentioned so far can handle deletions. Deletions are a particularly important type of edit for text watermarks, because an adversary may try to remove the watermark by simply deleting some of the words.
Deletions are notoriously difficult to handle in error correction, and standard techniques involve significant structure — thus violating pseudorandomness. Nonetheless, we show that if a PRC has sufficiently strong robustness to substitutions, then it can be converted to a PRC with robustness to deletions (at the cost of a decreased rate).
Let be the binary symmetric channel with error rate , and be the binary deletion channel with deletion rate . That is, randomly flips each bit with probability and randomly deletes each bit with probability .
For any constants and , there exists such that the following holds. If there exists a zero-bit (public-key) PRC with robustness to every -bounded channel, then there exists a zero-bit (public-key) PRC that is robust to the channel .
Together with our LDPC-based PRCs, we obtain the following result.
Let and be any constants. Under 1, there exists a zero-bit public-key PRC that is robust to the channel .
Watermarking and steganography for language models (Section 7).
We apply our zero-bit PRCs to build the first undetectable watermarking scheme for language models with robustness to a constant rate of random substitutions and deletions. In this section, we assume that text output by the language model is represented as a bitstring. Arbitrary text can be mapped to a bitstring by either randomly assigning a single bit to each token, or by expanding the tokens into a binary representation.
Let be any constant. Under 1, there exists an undetectable watermarking scheme such that the watermark appears in any sufficiently high-entropy text, even if the text is subjected to the channel .
Under an extra assumption about the generated text, which roughly corresponds to the text having few repeated words, we can strengthen this to handle deletions as well.
Let and be any constants. Under 1, there exists an undetectable watermarking scheme such that the watermark appears in any sufficiently high-entropy and “variable” text, even if the text is subjected to the channel .
In all of our theorems the text can be cropped, as long as the remaining text is sufficiently high-entropy.
We also construct undetectable watermarking schemes with unforgeable public attribution and the same robustness as . Public attribution means that there is a public algorithm to identify which portion of a given text was output by the model. Unforgeability means that no efficient user can produce text that the attribution algorithm identifies as model-generated, but that was not output by the model. Interestingly, our schemes retain the standard robust secret-key detector in addition to this public attribution algorithm.
Under 1, there exists a watermarking scheme that retains all properties of from Theorem 5 or Theorem 6, and additionally satisfies unforgeable public attribution.
Finally, using PRCs with constant rate (Theorem 3), we also obtain the first robust language model steganography scheme.Since this scheme doesn’t rely on the decoder having access to the prompt, it can also be seen as an undetectable “multi-bit watermarking scheme.”
Let be any constant. Under 1, there exists a language model steganography scheme with constant information rate, such that the message can be recovered from any sufficiently high-entropy text, even if the text is subjected to the channel .
Universal steganography (Section 8).
In Section 8 we show that PRCs can be used to solve a long-standing open question in steganography: A simple application of PRCs yields the first robust, stateless universal steganography scheme. Universal steganography can be used for language model steganography, but it is more general [vAH04]. We take the rate of the steganography scheme to be the ratio of the number of stegotext symbols to the number of bits in the message being encoded.
Suppose there is a hash function that is unbiased over the covertext channel. If is any PRC, then there exists a stateless, public-key universal steganography scheme with the same rate and robustness as .
Finally, we show that this result can be extended to the setting where an unbiased hash function on the covertext channel is not known, with some loss in robustness.
Suppose there is a hash function that has constant min-entropy over the covertext channel. Then under 1, for any , there exists a constant-rate public-key stateless steganography scheme that is robust to a rate of random substitutions.
3 Related work: short summary
We briefly outline some of the related work here. See Appendix A for a more complete discussion.
Code-based cryptography: Our work bears some similarity to the field of code-based cryptography. However, code-based cryptography is generally focused on building existing primitives from new assumptions — whereas PRCs are a new primitive that we base on existing assumptions.
Trapdoor pseudorandom generators: Our zero-bit PRCs can be equivalently viewed as robust trapdoor (or equivalently, backdoored) pseudorandom generators [VV83, DGG+15]. That is, we require the additional property that the trapdoor (or secret key) can be used to detect even corrupted pseudorandom strings.
Watermarking for language models: We build watermarking schemes for language models satisfying the strongest quality guarantee, undetectability. Undetectability was defined by [CGZ23], where undetectable watermarks for language models were also constructed. In that work and in [Aar22, KGW+23a], it is essential for watermark detection that many sufficiently-long contiguous substrings of the response remain unchanged. Therefore, these watermarks are easily removable by simple attacks (see the “robustness of our watermark” paragraph of Section 2.5). The watermarks of [KTHL23] are more robust — their robustness is more comparable to ours — but they sacrifice undetectability. Instead, their watermarks satisfy the weaker property of distortion-freeness, which is the single-query version of undetectability. [ZALW23] obtain even stronger robustness, at the cost of even further reduced quality.
Impossibility of strong watermarks: [ZEF+23] explore the possibility of watermarking for language models in the presence of motivated adversaries. They argue that sampling a random response is easier when one is provided any response. Since a random response cannot be watermarked (or else there would be a high false-positive rate), they use this to argue that any watermarked language model necessarily provides some assistance in generating un-watermarked text.
Steganography: Steganography is the study of concealing secret messages in innocent-looking content. Whereas encryption is about hiding the message, steganography is about hiding the existence of the message. Ever since steganography was formalized by [HLVA02], robust steganography schemes (that don’t require a shared state) have remained elusive. We resolve this problem using PRCs.
4 Organization
In Section 2, we give a technical overview of the paper, which is self-contained and sufficient to understand the high-level ideas and results of each section. In Section 3, we state relevant preliminaries and notation. In Section 4, we formally define PRCs and provide a heuristic construction. In Section 5, we build PRCs from LDPC codes and prove their pseudorandomness from standard cryptographic assumptions. We then show in Section 6 how to improve the rate and robustness of any PRC, resulting in our constant-rate multi-bit PRCs and PRCs for deletion channels. In Section 7, we present our language model watermarking schemes from PRCs, including both our standard watermarks and our watermarks with unforgeable public attribution. Finally, in Section 8, we show how PRCs can be used to construct robust universal steganography schemes.
Appendix A gives a more comprehensive overview of related work.
We thank Yael Kalai, Vinod Vaikuntanathan, Venkat Guruswami, Rainer Böhme, Or Zamir, Shyamal Patel, and Shivam Nadimpalli for helpful research conversations. We thank Mihalis Yannakakis and Fermi Ma for helpful suggestions about the write-up. We thank Omar Alrabiah for help in proving Lemma 9, as well as general assistance with coding theory.
Technical overview
Pseudorandom codes (PRCs) can be viewed as a combination of two related primitives:
Pseudorandom encryption, where ciphertexts are indistinguishable from random under a chosen plaintext attack [RBB03]. Secret-key pseudorandom encryption is easy to build using a pseudorandom function — just encrypt by sampling a random and outputting . Public-key pseudorandom encryption is also known from standard assumptions [vAH04]. However, none of these constructions have any nontrivial robustness.
Robust encryption, where encryptions of messages are robust to errors. Robust encryption is easy to build by applying an error-correcting code to ciphertexts from any standard encryption scheme. Even if that encryption scheme is pseudorandom, the use of the error-correcting code will in general render the robust encryption scheme not pseudorandom.
A PRC is required to simultaneously satisfy both pseudorandomness and robustness — properties that are in direct tension with each other. Using the secret key, one should be able to discern the redundancy and structure that give ciphertexts their robustness. Without the secret key, ciphertexts must appear completely unstructured.
We define secret-key PRCs below. For public-key PRCs (Definition 2), we further require that the encoding algorithm can be made public without sacrificing pseudorandomness.
Let be an alphabet and be a channel. A secret-key PRC with robustness to is described by algorithms and , parameterized by a secret key , satisfying the following criteria for every security parameter :
(Error correction, or robustness) For any message ,
(Pseudorandomness) For any polynomial-time adversary ,
where means that the adversary has access to an oracle that, on any (even previously queried) input, responds with a freshly drawn uniform value in .
2 Pseudorandom LDPC codes
The LPN assumption immediately implies that an arbitrary polynomial number of samples from are pseudorandom. However, recall that the LPN assumption states that these samples are pseudorandom even given — which means precisely that there does not exist an efficient zero-bit decoder !
While this random linear code construction does not work, it naturally suggests a strategy that does. If we find a sampling procedure that produces a random (or even pseudorandom) generator matrix together with a trapdoor for efficient decoding, then we have a public-key PRC where the generator matrix is the public encoding key and the trapdoor is the secret decoding key. By the LPN assumption, produces pseudorandom vectors even to an adversary who knows , so the construction will satisfy pseudorandomness.
Therefore our zero-bit pseudorandom LDPC code uses the following zero-bit decoding algorithm:
Encoding is exactly the same algorithm as above — but now that is sampled together with the trapdoor , we have an efficient decoding algorithm. Observe that this is a zero-bit scheme, because the decoder only determines whether the input is related to the keys or not. Using belief propagation, it is possible to push this construction beyond a zero-bit PRC, although this results in lower robustness. We ultimately construct a constant-rate multi-bit PRC by other means, which we discuss in Section 6.2.
Let be the zero-bit public-key PRC defined by for . In a moment we will outline our proofs that is a public-key PRC with very strong robustness. First, let us see some restrictions on the sparsity parameter that provide important context for these proofs.
If random noise of rate is applied to , then the probability of each parity check being satisfied for the noisy codeword is . So in order for to output 1 with high probability, we need , i.e., .
Therefore, we will choose in order to rely on the weakest possible cryptographic assumption for pseudorandomness, without sacrificing robustness to a constant noise rate.
The LDPC codes considered in this work differ from the traditional Gallager’s LDPC ensemble in two important ways. First, our LDPC codes will have sparsity as opposed to constant sparsity. Unfortunately, the usual belief propagation decoder does not work for noise rates beyond ; this is the reason why we only perform the simple zero-bit decoding. The second difference is that we use independent parity checks, which results in an irregular Tanner graph.
For appropriate choices of parameters, it turns out that the generator matrix of is pseudorandom under the planted -XOR assumption. The planted -XOR problem (and its generalization, the planted -SUM problem) is a natural and well-studied problem — see e.g. [SSV23] for a more detailed discussion. Formally, the planted XOR problem states that it is computationally hard to distinguish between
Throughout this overview, we consider linear subspaces to be described by a random basis. Recalling the definition of , if the planted XOR assumption immediately implies that is pseudorandom (by identifying with ). But for the more interesting case that , we require a stronger version of the planted XOR assumption with many planted relations. That is, we need to assume that the following distribution is indistinguishable from :
We are not aware of any prior work on this assumption that , so it is not immediately clear how reliable it is. Fortunately, it is implied by the planted XOR assumption.
We prove this with a hybrid argument. Suppose that an efficient adversary distinguishes between and with advantage . By a telescoping argument, must distinguish between and with advantage , for some . For each , the following efficient reduction satisfies and , which implies that (and therefore ) is negligible under the planted XOR assumption.
Let . Notice that . Since and , this is at least .
Output a random -dimensional subspace of .
It remains to see why and . In fact both of these statements are true even for fixed planted relations.
Narrow, statistically random generator matrix (Lemma 9).
Since the planted XOR assumption is not a standard cryptographic assumption, we show in Lemma 9 that the generator matrix of is statistically random for some . This removes the need for the planted XOR assumption, but it comes at the cost of requiring a stronger version of the LPN assumption: When we invoke LPN to see that samples are pseudorandom, the secrets are now only of size . Therefore, for this PRC we will rely on a subexponential version of the LPN assumption which states that LPN is -hard.
For the purposes of this technical overview, we will show that the generator matrix of a closely related code is random. The proof for this version is significantly simpler, but the distribution is less natural and has worse error-correcting properties. The modified distribution on is defined as follows:
Let be the matrix with the extra row appended to the bottom,
Let .
Let be the matrix whose rows are and . Output .
First observe that , because for every .
Recall that we say that any length-preserving channel that introduces at most a fraction of bit-flip errors is -bounded. To prove robustness, we need to show two things:
for any -bounded channel , samples from decode to 1 with high probability.
3 Pseudorandom codes for the deletion channel
So far, we have only considered PRCs for substitution channels. For our applications to watermarking and steganography, it will be useful to have PRCs for the noisy deletion channel as well. The noisy deletion channel randomly introduces both deletions and substitutions.
Unfortunately, existing error-correcting codes for the deletion channel introduce a large amount of structure into codewords that precludes pseudorandomness. For instance, the popular techniques of synchronization symbols or concatenation with constant-sized inner codes are immediately seen to be incompatible with pseudorandomness. Even further limiting the techniques available to us, we want our PRCs for the noisy deletion channel to have a binary alphabet in order to be useful for watermarking.
We therefore turn to alternative techniques. Surprisingly, we find that the repetition code — perhaps the simplest and most-structured error-correcting code — is a useful starting point.
For odd integer , the rate- repetition code works by repeating each bit of the message times. That is, for any message , the encoder is defined by , where denotes bit repeated times. For example, the rate- repetition code encodes as .
Now suppose that the encoding is subjected to the noisy deletion channel, resulting in a string . A natural algorithm for decoding is to partition into equal-length blocks , and compute the majority of each block:
Partition into equal-length blocks .
As long as the deletions are sufficiently balanced across the different blocks, the will align well with the original blocks . Provided further that there are not too many substitutions in any block, we should have . The issue is that is not pseudorandom even for random , because a random string is (extremely) unlikely to consist of repeated bits.
On the other hand, a random string typically does have bias towards 0 or 1.That is, a random string has more 0’s than 1’s, or 1’s than 0’s. This can be seen as a consequence of the fact that a one-dimensional simple random walk of length will usually terminate away from the origin. So if we change or delete a small number of bits of a random string, we expect the majority to stay the same. This observation brings us to the following encoder , which encodes each bit in the majority of a random string. We refer to the code defined by as the majority code.
Now if is random, then is random as well. Furthermore, if we subject to the noisy deletion channel to obtain , then the bits of are positively correlated with the bits of . This is because the deletions are at random locations, and are therefore (roughly) evenly-distributed across the different blocks — meaning that will mostly use the correct locations to decode each bit. Since the bit-flip errors are random, they merely dilute the biases. If and the rates of deletions and bit-flip errors are constants below 1 and respectively, then we show in Lemma 15 that is a constant greater than . Therefore, the majority code has the effect of converting the constant-rate noisy deletion channel into some -bounded channel.
Of course, the majority code is not itself a PRC. The first problem is that codewords for the majority code are only random if the message is random, whereas a PRC needs to allow encoding of any particular message. The second problem is that, even if the message is random, the majority code recovers a string that is only correlated with it.
But these are exactly the problems solved by PRCs for bounded-weight error channels! That is, if is any PRC with robustness to every -bounded channel (e.g. the PRCs from Section 2.2), then the combined code is a PRC with robustness to some constant-rate noisy deletion channel.As approaches , the combined PRC tolerates a noisy deletion channel with rates of deletions and bit-flip errors approaching 1 and . Pseudorandomness follows from the pseudorandomness of : Since is pseudorandom for any message , is as well. Robustness follows from the fact that the majority code has the effect of converting the constant-rate noisy deletion channel into some -bounded channel, which is handled by .
4 Constant-rate pseudorandom codes
So far we have only considered zero-bit PRCs, but for many applications it will be useful to have PRCs that can encode longer messages. There is a simple construction of a multi-bit PRC directly from any zero-bit PRC: Encode each bit of the message with either a zero-bit PRC codeword, or a uniformly random string. That is, if is a zero-bit PRC, we encode a message as where for each , if and if .
Unfortunately this scheme has a very low rate. If the zero-bit PRC has block length , then the resulting multi-bit PRC has rate . However, we show in Section 6.2 that one can use any such low-rate PRC to make any error-correcting code pseudorandom, with no asymptotic loss in rate.
The idea is to encode a seed for a one-time pad in the simple low-rate PRC just described, and then use the one-time pad to hide an error-correcting encoding of the message. More formally, let be any (standard) error-correcting code and be a low-rate PRC. We do not require to have any cryptographic properties. We encode a message asIn order to obtain stronger robustness guarantee, we actually randomly permute the symbols of this encoding. For the purposes of this technical overview we omit this detail.
where is any pseudorandom generator and is a fresh uniformly random string.
By pseudorandomness of , is indistinguishable from a uniformly random string — even for a fixed choice of . By security of , the encoding is therefore indistinguishable from a totally random string.
Decoding works as long as is not too corrupted for to recover , and is not too corrupted for to recover .
5 Watermarks for language models
As defined in [CGZ23], a watermarking scheme for a language model consists of algorithms and , where is the watermarked model and is an algorithm used to detect the presence of the watermark. In this work we are interested in watermarks that are undetectable, sound, and robust, loosely defined as follows.
Undetectability: Any polynomial number of responses from the watermarked model are computationally indistinguishable from those of the original model.
Soundness: Text generated independently of the watermarked model is not falsely detected.
Robustness: Sufficiently high-entropy text output by the model is detected as watermarked, even if it is altered.
We show that the watermarking strategy from Section 1, which replaces some of the model’s randomness with PRC codewords, yields a scheme that satisfies all of the above properties.
Recall that the approach from Section 1 requires an algorithm that takes as input a prompt and a random seed , and samples a response such that
if is uniformly random, then is distributed identically to a response from , and
each bit of is correlated with the corresponding bit of .
We define to sample the bit of the response as follows. It first computes by querying with prompt and the response output thus far, then:
Replacing seeds with PRC codewords.
We use PRC samples , instead of random samples , as the seeds in . That is, if is a zero-bit PRC, we let our watermarking scheme be defined by
Sample and output a sample from .
Compute and output the result.
By Condition (1) and the pseudorandomness property of , the responses from are computationally indistinguishable from those of the original model. By Condition (2) and the robustness property of , the watermark will be detectable as long as the PRC is sufficiently powerful.
Depending on the kind of robustness of the PRC, substituting the entire seed with a single PRC sample results in a watermark that may or may not be detectable from just a subsequence. This is easily fixed by using , where are independent PRC samples that are much shorter than the generated content. As long as the text contains at least one subsequence corresponding to a PRC sample , the watermark will be detected.
PRC error correction and watermark robustness.
To understand how error correction of translates to robustness of , it is helpful to think of ’s sampling process as a noisy embedding channel applied to the seed. That is, for a seed , let be the “embedding channel” describing the noise in . For detection, it is sufficient for to correct against the channel , since watermarked responses are exactly samples from for .
Robustness of is determined by ’s ability to correct from additional errors on top of . Let be a channel modeling the changes an adversary introduces to a watermarked response, so the overall error applied to follows . If is robust to , the watermark is robust to this adversary’s modifications.
In Section 7.2, we show that as long as the text has non-zero entropy, introduces errors at a rate of less than . Therefore, using any PRC with robustness to every -bounded channel, we immediately obtain watermarks that are robust to a constant rate of random substitutions.
Robustness of our watermark.
Hashing-based watermarking schemes — including all existing undetectable schemes — are removable by the simple “emoji attack” [Aar22, KGW+23a]. In this attack, an adversary asks the model to respond to its prompt and insert an emoji between every word of its response. The adversary then deletes the emojis from the response. This attack removes any watermark that relies on the detector seeing contiguous sequences of watermarked text.
It turns out that hashing-based schemes [Aar22, KGW+23a, CGZ23] can easily be made robust to this particular attack.For instance, we could choose to only hash tokens whose index has the same parity as the token being sampled. However, if the adversary instead instructs the model to insert the emojis randomly, then we do not know how to make any hashing-based scheme robust. By constructing PRCs with robustness to random deletion channels, we give the first undetectable watermarking scheme that can resist this kind of attack.
Under this assumption, if is the binary deletion channel for some , then we just need a PRC with robustness to . The binary deletion channel is the channel that deletes each bit of its input independently with probability . Indeed, we saw in Section 2.3 that there exist PRCs with robustness to for any .
6 Watermarks with public attribution
For the “standard” notions of watermarks considered so far, the goal is to determine whether a given text is a possibly-corrupted version of an output generated by a model. Standard watermarks are well-suited for applications such as detecting plagiarism, where one wishes to know if a model was used at all to produce a text, even if that text has been altered by the user.
A different use of watermarks is in attributing content to an LLM that generated it. For example, if harmful content generated by an LLM is found on social media, it would be useful to trace this content back to the model using the watermark. Ideally, anyone holding a public detection key should be able to trace the content. On the other hand, it should only be possible to embed the watermark by using a secret embedding key, in order to avoid falsely attributing text to any model.Note that the roles of the public and secret keys are reversed here. For PRCs, a secret key is necessary for decoding, but anyone can encode with knowledge of a public key. Public-key PRCs are useful for public-key steganography. In other words, to an attacker who does not know the secret key, the watermark should be unforgeable.
In addition to unforgeability, watermarks with public attribution have subtly different detection properties than standard watermarks. Robustness of standard watermarks means that an LLM-generated text will be detected even if small modifications are made. If robust watermarks were used for attribution, an attacker could use a model to generate a benign watermark text, then change a few words to make it offensive. By robustness, the watermark would still be present in this now-offensive content. So whereas robustness is a useful feature for standard watermarking, in the context of attribution it is actually an issue.
We therefore define a watermark with public attribution to have a separate detection algorithm called , which is intentionally designed to not be robust. , given a text and a public detection key, indicates whether the model output verbatim a significant part of that text, and outputs that portion of the text if so.
In order to preserve the benefits of robust watermarking for applications like detecting plagiarism, our publicly attributable watermarks also retain a algorithm (in addition to the algorithm) with the robustness of our standard watermarking schemes. One can choose at detection time whether one wants to use for standard detection, or for attribution.
Our watermarking scheme with public attribution, , is a natural extension of our regular watermarking scheme . Recall that embeds a codeword of a zero-bit PRC into the model’s response; the detector checks whether the given text is close to a codeword. Of course, if we use a PRC that encodes an arbitrary message (rather than only ‘1’ as in a zero-bit PRC), then will embed arbitrary messages in the text. does exactly this, where the message that it encodes is a signature on the response output thus far. decodes the given text to obtain this signature, and checks using the public detection key that it is a valid signature of a portion of the response. If so, this signed portion must have been generated by the model.
Concurrent work [FGJ+23] also constructs a watermark with public detection, although this scheme is designed to have mild robustness (comparable to that of [CGZ23]) and therefore is not appropriate for attribution as-is. Their scheme can easily be modified to satisfy our definition of unforgeable public attribution, but it would then lose all robustness guarantees for standard watermarking. Our scheme simultaneously functions as a highly robust standard watermark via , while also satisfying unforgeable public attribution via .
7 Robust steganography
In steganography, the goal is to send a hidden message such that an observer cannot tell that a message is being sent at all. In the classic presentation, a prisoner wishes to secretly communicate with an outside party even though the warden is filtering their letters. If the warden detects any unusual language then the communication channel will be shut down, so the prisoner cannot simply encrypt the message: The warden should not only be unable to learn anything about the message, but should be unable to even detect that secret communication is occurring at all.
Steganography was formalized in [HLVA02]. In this presentation, there is some underlying steganographic channel,In the steganography literature this is usually just called a “channel”; we call it a “steganographic channel” to differentiate it from the coding-theoretic channels we use in the context of robustness. a distribution with which the sender wishes to conceal a message. The sender is given sample access to this steganographic channel and sends a stegotext to the receiver. Steganographic secrecy requires that the distribution of stegotexts is indistinguishable from the steganographic channel, except to the receiver who can recover the message with a secret key.
[HLVA02] proves the security of a steganography scheme of [AP98] that can be constructed using any encryption scheme with pseudorandom ciphertexts. The key idea behind this scheme is to embed each bit of a pseudorandom encryption of the message by drawing a sample from the steganographic channel such that for some hash function :
[AP98, HLVA02]:
Let
For , sample a random from the channel conditioned on
The decoder simply outputs .
If is uniform over , and is perfectly unbiased for the channel, then is sampled exactly from the channel distribution. Therefore, by pseudorandomness of the ciphertext, an observer cannot distinguish stegotexts from samples from the steganographic channel. The receiver, which knows the decoding key for the encryption scheme, can evaluate on each block of the stegotext to obtain the ciphertext, then decrypt to recover the message.
We observe that PRCs are exactly the primitive needed for robust stateless steganography: Using a PRC as the pseudorandom encryption scheme in the above construction immediately gives us a steganography scheme with the same robustness as the PRC. If we use a public-key PRC, the resulting steganography scheme is also public-key. Furthermore, the robustness of the PRC allows us to relax the assumption that is perfectly unbiased on the steganographic channel.
Our main result of Section 8 is the first stateless steganography scheme with nontrivial robustness to errors. In particular, using our LDPC-based PRCs, we construct stateless steganography schemes that are robust to -bounded channels for any constant , or any constant-rate random deletion channel.
Preliminaries
We use to denote the logarithm base 2 of , and to denote the natural logarithm of .
We let denote the composition of functions, algorithms, or channels; that is, denotes (the function/algorithm/channel) obtained by applying , then .
Let denote the security parameter. A function of is negligible if for every polynomial . We write to mean that is negligible. We let denote computational indistinguishability and denote statistical indistinguishability.
Let be a martingale with respect to . If the differences are all bounded by with probability , then for all ,
Digital signature scheme.
We use the definition of a digital signature from [KL07], with small modifications. A digital signature scheme is defined over a message space and consists of polynomial-time algorithms such that:
takes as input a security parameter and outputs a public-private key pair .
takes as input a private key and a message . It outputs a signature , which we write as .
takes as input a public key , a message , and a signature . It outputs 1 if the signature is valid and 0 otherwise. We write .
It is required that except with negligible over output by , it holds that for every .
A digital signature scheme is existentially unforgeable under an adaptive chosen-message attack, or just secure, if for all polynomial-time adversaries ,
where the experiment is defined in Figure 1.
2 Coding theory preliminaries
A channel is a randomized map . That is, for , is a random sample from . We use channels to model errors introduced by the environment, or by an adversary attempting to e.g. remove a watermark. Two of the most important channels we consider are the binary symmetric channel BSC and the binary deletion channel BDC:
is the binary deletion channel with deletion rate . That is, randomly deletes each bit independently with probability .
For the purposes of this work, an error-correcting code with robustness to the channel is a pair of algorithms where . Error-correction (or robustness) for the channel says that if , then . The block length of an error correcting code is the number of symbols in a codeword required to encode a message of a particular length. We therefore write the block length as a function of the message length . The rate of a code is the function , which may or may not depend on the message length .
Pseudorandom code basics
In this section we define pseudorandom codes (PRCs) and related terminology. A PRC can be viewed as a familyWe remark that if a PRC were a fixed code rather than a family of codes, pseudorandomness against non-uniform adversaries would be impossible since the adversary could have the decoding key hard-coded. of error-correcting codes indexed by encoding and decoding keys. For secret-key PRCs, the encoding and decoding keys are identical; for public-key PRCs, the encoding key is public and the decoding key is secret.
Formally, a PRC is specified by three algorithms. A key generation function samples the keys. An encoding function takes as input the encoding key and a message, and it outputs a codeword. A decoding function takes as input the decoding key and a perturbed codeword, and it outputs the message or .
Our error correction guarantee is defined in terms of a channel. A PRC is robust to a channel if can recover from with overwhelming probability. In addition to requiring that we can recover messages from noisy codewords, we also require that outputs given a string that is unrelated to the code. That is, for any string , outputs with overwhelming probability over the choice of the decoding key. This property is important for applications such as watermarking, where we want the ability to distinguish codewords from uniformly random strings.
Pseudorandomness of the PRC ensures that an adversary without knowledge of the secret key cannot distinguish between an oracle for the algorithm of the scheme, or an oracle that outputs independently drawn uniform strings. If a PRC is viewed as an encryption scheme, pseudorandomness is equivalent to indistinguishability from random bits against a chosen plaintext attack (IND-$CPA security) [RBB03]. For public-key PRCs, pseudorandomness holds even against adversaries holding the encryption key.
Let be a fixed alphabet. A secret-key pseudorandom error-correcting code (abbreviated as secret-key PRC) with robustness to a channel is a triple of polynomial-time randomized algorithms satisfying
(Pseudorandomness) For any polynomial-time adversary ,
where means that the adversary has access to an oracle that, on any (even previously queried) input, responds with a freshly drawn uniform value in .
Let be a fixed alphabet. A public-key pseudorandom error-correcting code (abbreviated as public-key PRC) with robustness to a channel is a triple of polynomial-time randomized algorithms satisfying
(Pseudorandomness) For any polynomial-time adversary ,
where means that the adversary has access to an oracle that, on any (even previously queried) input, responds with a freshly drawn uniform value in .
The block length of a (public-key or secret-key) PRC is and the message length is . The rate is the function . We often drop the dependence on when it is clear from context.
We present our constructions of PRCs for messages of fixed lengths. That is, for a given set of keys, the construction will only work for messages of a fixed length. However, we note that this can be easily remedied using a pseudorandom function (PRF) to select new keys for every message length. We do not include the PRF in our constructions in order to simplify presentation.
2 Heuristic construction from permuted codes
In this section we describe a natural heuristic transformation for building a candidate secret-key PRC from any error-correcting code. In Section 5 we will give provably secure constructions of PRCs from standard (subexponential) cryptographic assumptions.
Our heuristic construction can be applied to any binary error-correcting code, such as the polar code [Ari09]. The secret key will be a random permutation of the indices of the codewords. To encode a message, we encode it using the error-correcting code, then apply the secret permutation, and finally add a small amount of random Bernoulli noise.
There are two drawbacks of this generic permuted code construction relative to our pseudorandom LDPC codes:
In general the pseudorandomness of a permuted code is based on non-standard, ad-hoc conjectures. For certain codes, such as Gallager’s LDPC ensemble [Gal62], the permuted code construction is not pseudorandom.
Permuted codes are inherently secret-key PRCs, whereas our pseudorandom LDPC codes are public-key.
For any error-correcting code and parameter , we formally define the corresponding permuted code as follows. Let be the block length for , as a function of the message length. (Recall that the block length is the number of codeword symbols needed to encode a given message.) will encode messages of length into codewords of length , where is a security parameter.
Let be a security parameter, let be the length of messages we wish to encode, and let .
: Sample a random permutation and output .
for :
Output .
for :
Compute .
Output the last symbols of .
A permuted code has the same robustness to substitutions, and nearly the same rate, as .
A natural choice of error-correcting codes to use in this permuted code construction is polar codes [Ari09]. Since polar codes have linear rate and tolerate a constant rate of adversarial errors, permuted polar codes are a candidate linear-rate secret-key PRC with robustness to a constant rate of adversarial errors. We do not know whether such codes satisfy pseudorandomness.
Constructing pseudorandom codes from cryptographic assumptions
In this section, we introduce a public-key PRC based on LDPC codes. We present the zero-bit version of our scheme, , in Section 5.1; we will see in Section 6 that this immediately implies a many-bit scheme with essentially the same robustness. In Section 5.2 we show that is robust to every error channel of bounded weight, as long as the parity checks have sufficiently low weight. Finally, we prove pseudorandomness of in two different parameter regimes under different cryptographic assumptions: In Section 5.3, we prove pseudorandomness under LPN and a certain planted XOR assumption; in Section 5.4, we prove pseudorandomness under a subexponential-query variant of LPN.
An random LDPC code is a pair of matrices .
The focus of this section will be on the following zero-bit PRC. Recall that a zero-bit PRC is one whose message space is just . We will see in Section 6.2 that a constant-rate PRC can be generically constructed from any zero-bit PRC.
For the remainder of this section, we will identify the security parameter with the dimension of the code . We will therefore write as functions of , with the understanding that .
2 Codeword detection (zero-bit decoding)
For any , there exits such that the following holds. For any , , and , is robust to every -bounded channel.
with probability . Therefore we apply Lemma 5 with . ∎
Let denote the row of . We will show that
and the independence of the rows of will imply the lemma by a Chernoff bound.
Then the bit is distributed as , so
The remainder of the proof is devoted to showing that
For large enough , this will imply Equation 1 by the assumption that .
By the tower property and linearity of expectation,
For all possible assignments of ,
Recall that is chosen to be a uniformly random index from . Since , contains at least and at most indices for which the corresponding bit of is 0. Therefore, .
3 Pseudorandomness from the planted XOR assumption and LPN
In this subsection we prove that the generator matrix (public key) of is pseudorandom under the planted XOR assumption. This is Lemma 8. The number of columns of the generator matrix and the number of rows of the parity check matrix will depend on the particular planted XOR assumption one is willing to make. Then, since the generator matrix is pseudorandom, pseudorandomness of (Theorem 1) follows directly from the standard LPN assumption.
The existence of our LDPC-based PRCs relies on either of two assumptions. We state the two assumptions together as 1.
At least one of the following two statements is true:
There exists a constant such that, for any function , the assumption (2) holds.
There exist constants such that, for any function , both the assumption (2) and the assumption (3) hold.
By a standard hybrid argument, the assumption implies that any polynomial number of samples of the form are indistinguishable from uniformly random samples.
Sample .
If and , then
For larger values of , and are no longer statistically close, but the planted XOR assumption says that they remain computationally indistinguishable.
The proof closely mirrors that in the technical overview (Section 2.1), with the main difference being that here we deal with generator matrices instead of the linear subspaces themselves. For and , let be defined as follows.
:
Sample .
Observe that , and is consistent with the definition given earlier.
For each and , since , the matrix has full rank with probability . Therefore, is -close in statistical distance to the following distribution:
:
Sample .
Since (resp. ) is -close to (resp. ) in statistical distance, the planted XOR assumption implies that , and are computationally indistinguishable.
Now suppose that an efficient adversary distinguishes between and with advantage . By a telescoping argument, must distinguish between and with advantage , for some . For each , the following efficient reduction satisfies and . Therefore, the planted XOR assumption implies that , which will complete the proof.
Let . Since and , we have .
It remains to see why and . In fact both of these statements are true even for fixed planted relations.
Claim 7 and Lemma 8 together imply that the generator matrix from is statistically uniform. In Lemma 9 we improve this to show that the generator matrix from is statistically uniform for any (and some ).
For any constants , there exists a function such that is a zero-bit public-key PRC that is robust to every -bounded channel, where pseudorandomness rests on the assumption (2) and the assumption (3).
By Lemma 4, there exists such that is robust to every -bounded channel.
By Lemma 8, the assumption implies that for , the marginal distribution on is pseudorandom. By the assumption, it follows that is a public-key PRC. ∎
4 Pseudorandomness from subexponential LPN
Before we see Lemma 9, note that we use a different proof strategy here than the technical overview. The reason we use this more involved proof here is that the proof outlined in the technical overview results in a different ensemble of parity-check matrices with a triangular restriction and non-independent rows. By proving Lemma 9, we are able to use the same ensemble as in Section 5.3 — that is, the rows of are still independent and uniform -sparse vectors.
If and , then there is a such that the marginal distribution on for is -close to uniform in statistical distance.
Let . The above two inequalities give us a point-wise approximation to the density of ,
We complete the proof with the following three facts:
Lemma 10 is a general statistical fact, which implies that if
then is -close to uniform in statistical distance. Crucially, Lemma 10 and Equation 5 reduce the problem to reasoning about the uniform distribution over , rather than .
The proof is a simple invocation of Chebyshev’s inequality.
Using Lemmas 11 and 12 with Equation 5, the condition of Lemma 10 is satisfied. This completes the proof of the theorem. ∎
Let be a probability distribution on a finite set . If
then the statistical distance between and the uniform distribution is at most .
Letting denote the th row of the matrix , we define
For any , over the expected number of simple dependencies in is
Together with Lemma 11, we have that for any the expected number of simple dependencies computed in Equation 6 is at most
with probability over . Since
the remainder of the proof is devoted to showing that
So . Thus, it suffices to see that
Applying Claim 13, we have reduced the problem of proving Equation 7 to showing that
Fortunately, the eigenvalues of are simple to compute:
We can rewrite Equation 9 as a moment of a simple random walk:
In either case we have a bound of .
For any , there exists , such that is a zero-bit public-key PRC that is robust to every -bounded channel, where pseudorandomness rests on the assumption.
By Lemma 4, there exists such that for any , is robust to every -bounded channel.
By Lemma 9, there exists a function such that the generator matrix of this code — that is, for — is -close to uniformly random.
Since has dimensions , the assumption implies that is a public-key PRC. ∎
Boosting the rate and robustness of any pseudorandom code
We show how to construct a multi-bit PRC from any zero-bit PRC. The high-level idea is to encode a given message bit-by-bit, where we use codewords from the zero-bit PRC to represent bits of the message that are 1, and uniformly random strings to represent bits of the message that are 0. We say this encoding consists of many blocks, where each block is either a codeword from the zero-bit PRC or a random string. Since our zero-bit PRC allows a decoder with the secret key to distinguish uniform strings from noisy codewords, we can use this decoder to recover each bit of the message from each block.
However, as described so far, there are two issues with this scheme. The first is that this scheme encodes the all-0 string as a uniformly random string, but the error correction property of a PRC requires that the decoder can distinguish encodings (of any message) from random strings. Thus, we modify the above scheme to append a codeword from the zero-bit PRC to the end of every encoding.
The other issue is that this scheme may lose the zero-bit PRC’s robustness. In particular, consider a zero-bit PRC that is robust to all -bounded channels; we would like for our multi-bit PRC to retain this robustness. However, consider the channel that flips each bit in only the first block of the encoding, independently with probability . The decoder will now be unable to recover the first bit of the message, and this channel is -bounded since it changes only a sub-constant fraction of the bits. The issue here is that our -bounded channel was not bounded at all on the first block; we’d like for the channel’s effect on every block of the encoding to be -bounded. We solve this issue by randomly permuting the encoding, which ensures that the errors introduced by the channel cannot be too concentrated in any block. The decoder now inverts the permutation before decoding block-by-block as before.
Although the constructions are essentially the same, we separately present multi-bit secret-key and public-key PRCs as they have slightly different syntax.
which is negligible in . Since , the probability that there are at least errors in our block is at most the probability that there are errors, which we’ve just shown is negligible. By a union bound, the probability that any block has more than errors is negligible.
2 Constant-rate pseudorandom codes
We now show how to build constant-rate PRCs from any multi-bit PRC (as in Section 6.1) and any constant-rate error-correcting code. We state the public-key version of the following construction only; as usual, the secret-key version is similar.
Let be a security parameter and be a -bit public-key PRC with block length . Let be any error-correcting code with block length and messages of length . Let be any pseudorandom generator. We define which is a -bit public-key PRC as follows:
: Sample . Sample a random permutation . Let and ; output .
: Given as input a message , let , and let
Let denote the bits of . The output is .
: Letting denote the bits of , the decoder first computes
The decoder then parses as , where and . It computes and outputs .
The block length of the resulting PRC is , so the rate is . Since is only a function of the security parameter and does not depend on , for large the rate approaches the rate of the underlying error-correcting code .
Let be a -bit public-key PRC with block length , and let be any error-correcting code with block length and messages of length .
Then of Construction 5 is a public-key PRC where
the rate of is ; and
for any constants , if and are robust to channels that introduce at most a fraction of errors at random locations, then is robust to all -bounded channels.
Pseudorandomness. By pseudorandomness of , no polynomial-time adversary can distinguish between and a hybrid where is replaced by a uniformly random . By pseudorandomness of the PRG, this is computationally indistinguishable from a hybrid where is replaced by a uniformly random , making uniform. Therefore, in this hybrid, which is indistinguishable from oracle access to , each query to the oracle outputs an independently drawn uniform string in .
Robustness. We first show that for any -bounded channel , if the decoder receives , then the resulting and are equal to and respectively, where and are both -bounded. Observe that the number of errors introduced by is distributed as a hypergoemetric random variable with a population of size , success elements (representing the errors), and draws. By Lemma 3, the probability that introduces at least errors is at most , which is negligible. Similarly, the number of errors introduced by is distributed as a hypergoemetric random variable with a population of size , success elements (representing the errors), and draws. By Lemma 3, the probability that introduces at least errors is at most , which is negligible as . By a union bound, with overwhelming probability both and introduce errors with at most a rate of , and therefore they are -bounded.
Furthermore, because of the random permutation , the locations of the errors on are random. Therefore by robustness of , we have that with overwhelming probability; and by error correction of , with overwhelming probability as well. ∎
from Construction 4, using the LDPC-based PRCs of Construction 2 as ; and
the error-correcting codes of [ABN+92, NN93, Ta-17],
then we obtain constant-rate PRCs with robustness to every -bounded channel for .
3 Pseudorandom codes for the deletion channel
In this section, our primary goal is to construct a PRC, , that is robust against a constant-rate deletion channel. That is, the message can be recovered from an encoding under when each of its bits is deleted independently with some constant probability . The actual robustness guarantee we obtain is even stronger: we can recover the message even when this constant-rate deletion channel is composed with a constant-rate binary symmetric channel. Our construction makes black-box use of any PRC that is robust against -bounded channels.
Observe that given , one can recover by computing the majority of each length- block . If each bit of is deleted independently with some probability to yield , we can recover an approximate version of as follows. We partition into equal-length blocks , and we compute the majority of each block. Intuitively, we expect most of the new blocks to be subsets of the corresponding original blocks . Since the deletions are random, we expect them to preserve the majority for most blocks. Therefore, the message that we recover should be approximately , with some bounded number of bits flipped. Recalling that itself was a PRC codeword, and our PRC is robust to bounded-weight channels, we can recover the original message from .
It may be tempting to apply this majority code to other encoding schemes such as pseudorandom encryption, and the result would indeed be pseudorandom. However, it would not be robust against a constant-rate deletion channel. Since decoding from the deletion channel introduces bounded-weight errors, the message that the majority code is applied to must be error-correcting against bounded-weight channels. Therefore, our PRC is crucial to this approach.
In Lemma 15, we show that majority encoding a message allows us to recover an approximation of the message with bounded-weight error after a deletion channel is applied. This holds even if this deletion channel is composed with a binary symmetric channel.
Assume . For any constant deletion rate and error rate , there exists a constant such that
Let and let . Let be the set of indices deleted by ; is a random variable where each is included in independently with probability . Let be the function that maps indices of to those of , i.e., .
Let be the partition of into blocks of length . Let be the partition of into almost-equal-sized blocks from the definition of . and define partitions of and , respectively. All of
By a union bound, with probability we have that for every
That is, the number of deletions in every contiguous interval of concentrates and is roughly .
We now argue in Claim 16 that because of this concentration, each in the decoder’s partition corresponds to a subset of the original message that is largely contained in . That is, the symmetric set difference between and is small.
If Equation 10 holds for all , then for all we have (where denotes the symmetric set difference).
Observe that . We will show that . A nearly identical proof shows that as well, so this will complete the proof.
For any , setting in Equation 10 we have that . Applying this fact to for any ,
Together with Equation 11 and the fact that is a constant, we have
So far, we’ve argued that each block in the decoder’s partition consists mostly of bits from block of the encoding. We now argue that with high probability, the bits of that were excluded and the bits from other blocks that were erroneously included do not affect the majority of .
To do so, we define to be the difference of the erroneously excluded bits and the erroneously included bits, converted to values in so we can later reason about this as a random walk. Let
Conditioned on Equation 10 holding for all , Claim 16 implies that is a sum of random variables. Furthermore, these random variables are independent because is uniform over . By Hoeffding’s inequality,
By a union bound, the probability that for all is at least .
where we define to be a random value in .
We can equivalently view as a random variable which is 1 with probability , and a uniformly random value with probability . Let be the set of indices where is deterministically 1. By a Chernoff bound, with probability ; fix such an . We can write
where we have defined and variables . We also write
where we have defined and variables . Observe that are all independent, uniformly random variables. We wish to show that
Let , , and . The above equation we wish to show becomes
If , then . On the other hand,
Therefore, it suffices to show that . We do this by bounding each of the three factors below separately:
Since , the central limit theorem implies that .
Since , Hoeffding’s inequality implies that .
By the triangle inequality, . Since , Hoeffding’s inequality again implies that . ∎
It only remains to show that the conditions of Claim 17 are satisfied with probability . That is, for , we need to show that and with probability . Conditioned on Equation 10 holding for all , we have that and for all . Therefore and . By Equation 12, for all with probability . Therefore, with probability if . ∎
We now show that we can compose this majority code with a PRC for bounded-weight channels to yield a PRC for the deletion channel.
Let be a PRC with block length . is defined as follows:
: Output .
: Output .
: Output .
Error correction. Let be any message, and let for . By pseudorandomness of , is indistinguishable from a random string in . By Lemma 15, there exists such that
Let be a channel, and observe that the above implies that is -bounded.
Since is error-correcting against -bounded channels,
Now, we rewrite this guarantee to be in terms of . Observe that by definition, for all , is distributed identically to . Therefore,
We finally show that unrelated strings decode to under . Let . By the analogous property for ,
Application: watermarking for language models
In this section we show that PRCs can be used to build quality-preserving (undetectable) and robust watermarks. For an overview of our approach, see either the introduction or Section 2.5.
We follow [CGZ23] in our definition of a language model. We will often refer to language models simply as models.
A language model over token set is a deterministic algorithm that takes as input a prompt prompt and tokens previously output by the model , and outputs a probability distribution over .
A language model is used to generate text as a response to a prompt by iteratively sampling from the returned distribution until a special terminating token is drawn.
A language model’s response to prompt is a random variable that is defined algorithmically as follows. We begin with an empty list of tokens . As long as the last token in is not done, we draw a token from the distribution and append it to . Finally, we set .
For a probability distribution over elements of a finite set , we define the Shannon entropy of as
where is the probability of in the distribution . The empirical entropy (also known as Shannon information or surprisal) of in is simply . The expected empirical entropy of is exactly . Intuitively, the empirical entropy of (with respect to ) is the number of random bits that were required to draw out of the distribution .
For a language model , a prompt prompt, and a possible response , we define the empirical entropy of responding with to prompt as
We next generalize the definition of empirical entropy from whole outputs to substrings of a model’s output. This will quantify how much entropy was involved in the generation of a particular contiguous substring of the output.
For convenience, in settings where the model and prompt are clear we simply write to mean . We sometimes write to denote the empirical entropy of a single token .
We formally define a watermarking scheme as follows.
A watermarking scheme for a model over is a tuple of polynomial-time algorithms where:
outputs a secret key, with respect to a security parameter .
is a randomized algorithm that takes as input a prompt prompt and generates a response in .
is an algorithm that takes as input a sequence outputs or .
Ideally, should output if is generated by , and should output if is generated independently of . The former property is called completeness and the latter soundness.
A watermarking scheme is sound if for every security parameter and token sequence of length ,
A watermarking scheme is -complete if for every security parameter and prompt prompt of length ,
A watermarking scheme is -substring-complete if for every prompt prompt and security parameter ,
If the watermarked model is indistinguishable from the un-watermarked model (and therefore perfectly quality-preserving), we say that the watermarking scheme is undetectable.
A watermarking scheme is undetectable if for every security parameter and all polynomial-time distinguishers ,
where the notation means that is allowed to adaptively query both and with arbitrary prompts.
We also define robustness for a watermarking scheme. For robustness, the detector should be able to identify the watermark even if the text has undergone corruption by some channel . Substring robustness says that the watermark should be robust to both cropping as well as .
A watermarking scheme is -substring-robust against a channel if for every security parameter and prompt prompt of length ,
Recall that a language model operates over an arbitrary token alphabet . In constructing our PRC-based watermarks, it will be convenient to take to be , since our pseudorandom LDPC codes have binary codewords. Prior work [CGZ23] suggests a black-box transformation from any model with an arbitrary-token alphabet to a model with a binary-token alphabet, by reinterpreting the probability vectors output by the model. Here, we describe that transformation in more detail.
Let be any model with token alphabet . , when queried with a prompt and token sequence, outputs a probability vector . We construct a model that has token alphabet ; that is, outputs probability vectors . This construction will make only black-box use of and will ensure that there is some decoding function converting binary outputs of into sequences of tokens from , such that the distributions of and are identical.
Let be any prefix-free encoding function, and let be the corresponding decoding function such that for any , . Furthermore, if is given as input an encoded token concatenated with some binary string such that no prefix of is a valid codeword, outputs the token and the string; that is, . We will construct such that the distribution of is identical to that of . That is, will output a binary encoding of a token sequence in . So will compute its distribution over the next binary token by querying for its distribution over , and computing (according to ) the distribution over the next bit of the binary encoding of the next token.
This transformation exactly preserves the empirical entropy of the response, since the distribution of is identical to that of . However, it does reduce the rate of entropy per token, since responses from are longer. This reduction will depend on the length of codewords, and using an efficient encoding such as a Huffman encoding can help mitigate this rate reduction.
For the remainder of this paper, we assume that the token alphabet of the underlying model is binary. In practice, we can embed the watermark in a model with an arbitrary token alphabet by using this transformation to compute , generating a watermarked binary response from , and transforming this response back to tokens in using the decoding function . This transformation preserves the undetectability of our watermark. Recall that by undetectability, the distribution of watermarked (binary) responses from is indistinguishable from the original (binary) distribution of . Let denote the distribution of watermarked responses from . Since our transformation guarantees that , we have that , meaning that our watermarked responses after this transformation are indistinguishable from those of the original model.
In our robustness theorems, we assume that the bit-errors are random. Using the above transformation, this may not be realistic because bit-errors within the representation of a given token may be correlated. We note that an alternative transformation that avoids this issue simply uses the first bit of the above representation.
2 Robust watermarking from PRCs
Watermarking schemes for language models typically embed the watermark by sampling each token with some bias. In this section, we show that using a PRC to determine this bias yields a watermarking scheme that inherits robustness from the PRC. In more detail, our watermark generator first samples a PRC codeword . It then samples each token to be biased toward , yielding a response that is a noisy codeword. By pseudorandomness of PRCs, this biased sampling does not noticeably change the distribution of in expectation over . Yet the detector, which knows the PRC secret key, can check if the given text is a noisy codeword to detect the watermark. Furthermore, one can use our scheme to embed an arbitrary message in the response, by choosing to be under a multi-bit PRC. This yields a language model steganography scheme, since steganographic secrecy is implied by undetectability.
Our watermarking scheme can tolerate additional changes to the response depending on the robustness of the PRC used. In particular, if the PRC is robust to deletions, our scheme evades the emoji attack which succeeds against all existing undetectable watermarking schemes. Here, the attacker asks the model to answer the prompt and randomly insert an emoji in between words, then deletes the emojis. This attack succeeds because the detectors in existing schemes must be given contiguous text from the watermarked model. However, modeling this attack as a random deletion channel, our codes from Section 6.3 give rise to watermarking schemes that are robust to this attack.
Let be a PRC of block length with security parameter . is the watermarking scheme whose algorithms are specified in Figure 3.
In Algorithm 3, we specify the detector to do a brute-force search over index pairs to find the start and end locations of the perturbed codeword, since deletions may change its length. If the perturbed codeword length is known, e.g., when one wants robustness only to substitutions, one can use a more efficient detector that searches only over indices to find the start location of the codeword.
We first show that is sound and undetectable, which follows quickly from pseudorandomness and error correction of PRCs.
is sound.
Setting for each , the probability that returns 1 for any is negligible by a union bound. Consequently, the probability over choice of that outputs true is negligible. ∎
is undetectable.
We prove that if the output of is replaced with uniform randomness, this watermark is undetectable. It then follows from pseudorandomness of the PRC that the actual watermark is undetectable.
so . Now, suppose that Then
Suppose for the sake of contradiction that is not undetectable; that is, there is a polynomial-time distinguisher such that for some constant ,
We’ll construct an adversary that uses to break pseudorandomness of . Recall that in the PRC pseudorandomness experiment, has access to , which is either an oracle for or the uniform distribution , and its goal is to distinguish between these two cases. interacts with and simulates ’s oracle , which is either or . When queries a prompt prompt to , returns a response according to Algorithm 1, with one key modification: It draws each by querying its oracle . If is , the responses returned by are exactly those of . By our earlier observation that if the ’s are uniform, the ’s distributions are unchanged, if is the responses returned by are exactly those of . Therefore, if we set to output 1 if and only if outputs 1, we have that
contradicting pseudorandomness of the PRC. ∎
Robustness of our scheme
We model this process as an embedding channel , where for , (i.e., the bits of the watermarked model’s response to prompt where is embedded). For ease of notation, we write , leaving prompt and the index implicit. We will show that introduces a bounded number of errors when the text has non-zero entropy.
We will show that with probability over ,
By the Cauchy-Schwarz inequality, we have
Combining these two inequalities, it will follow that with probability if then
And since by definition, for every , and as desired.
It remains to show that with overwhelming probability, . For , let and . If , ; if then
By a union bound, .
Let and for let . Observe that is a martingale with respect to . Since the differences are bounded by with probability , Azuma’s inequality (Lemma 1) implies that
Since , it follows that
We show in the following lemma that the embedding channel introduces bounded-weight errors into any contiguous substring of a response with sufficient empirical entropy.
For ease of notation, in this proof we use to denote the probability that the model outputs a bit as the next token given that it has output tokens so far. We also let denote and denote .
For fixed , we have
where for the inequality we have used the fact that for .
Let be any constant. If is a zero-bit PRC with block length and robustness to every -bounded channel, then is -substring-complete.
Let be a watermarked response for some arbitrary prompt prompt, and let be a length- contiguous substring of , where .
The start and end of may be part of incomplete blocks, with some number of full blocks in between. Recall that the truncated empirical entropy of any single-bit distribution is at most 1, so each of these possibly-incomplete blocks contains at most truncated empirical entropy. Consider padding these possibly-incomplete blocks, appending deterministic bits so they are each of length but have the same truncated empirical entropy. It now follows from Lemma 20 that with overwhelming probability in the length of these blocks (which is now ), they each have at most empirical entropy. The full blocks therefore contain at least empirical entropy.
Let be any constants. If is a zero-bit PRC with block length and robustness to every -bounded channel, then is -substring-robust against .
As in the proof of Lemma 22, the decoder receives the output of the composition of the error channel and embedding channel on the sufficiently high-entropy block. The embedding channel is again -bounded on this block by Lemma 21. Therefore, the composition of the error channel with the embedding channel has expected error rate
and is in particular -bounded. Since is robust to such channels, it follows that is -substring-robust against . ∎
We showed above that when a substring of a response has at least empirical entropy, the embedding channel applied to some block in that substring is -bounded. For the following theorem, we need to assume something further about : restricted to that block in the substring, is equal to for some .
There is a function such that for any constant , if a response substring of length has at least empirical entropy, the embedding channel can be modeled as .
In more practical terms, this assumption states that the entropy is spread throughout that substring, and every token of that substring has some variability.
Suppose that 4 holds with function . Let , , and be any constants. If is a zero-bit PRC with block length and robustness to , then is -substring-robust against .
Consider the block of the response over which is equivalent to . The decoder receives the output of the composition of the error channel and embedding channel applied to the codeword used in this block. The composition of these channels is , which is robust to.
Therefore, the detector of will output when it runs on this block of the response. ∎
By applying the PRCs of Theorems 1 and 2 to Lemmas 23 and 24, we obtain the following results.
Let be any constant and be a security parameter. Under 1, there exists a language model watermarking scheme that is -substring-robust against .
Suppose that 4 holds with function , let and be any constants, and let be a security parameter. Under 1, there exists a language model watermarking scheme that is -substring-robust against .
We remark that although we state our theorems for error rates in for convenience, one can easily extend these schemes to error rates for arbitrary constants in .
3 Language model steganography
We have proven completeness, robustness, soundness, and undetectability of , where the random strings used in were computed as . These proofs relied only on our ability to distinguish PRC codewords from unrelated strings, so it sufficed to use a zero-bit PRC. Of course, one could obtain a multi-bit watermarking scheme by replacing with for any message , using which is multi-bit and has the same robustness as . Lemmas 23 and 24 both apply identically in this case. This yields a robust language model steganography scheme, where steganographic secrecy is implied by undetectability of . This steganography scheme has the same robustness as the watermarking scheme.
Applying this observation and using the constant-rate PRCs of Section 6.2, we obtain the following result.
Let be any constant and be a security parameter. Under 1, there exists a language model steganography scheme that is -substring-robust against .
In Section 7.4, we will see how this observation about encoding arbitrary messages can be used to build watermarks with public attribution. Since the proofs of security and robustness of the language model steganography scheme are completely identical to those for the watermarking scheme , we do not formally prove them separately. However, in Section 8 we show that PRCs can be used for universal steganography (which is more general than language model steganography).
4 Watermarks with public attribution
See Section 2.6 for a description of publicly attributable watermarks.
We define public attribution in terms of a function called . Recall that we intentionally design this function to not be robust. , given a text and a public detection key, outputs a pair , where indicates whether contains verbatim a significant prefix of text output by the model, and if so, is that prefix. Although is intentionally not robust, our scheme’s function retains all properties (undetectability, robustness, soundness) of our standard watermarks.
Algorithms 4, 5, 6 and 3, given in Figure 4, comprise a watermarking scheme with unforgeable public attribution from any secret-key PRC and any digital signature scheme.
The watermarked text generator of (Algorithm 5) is exactly the same as that of (Algorithm 1), but is now generated as the output of on specific messages. In particular, the first is sampled as , and every subsequent is the encoding of a signature on the response output thus far.
A watermarking scheme for a model has unforgeable public attribution if there is a function satisfying:
(Syntax): takes in a token sequence and outputs a (token sequence, boolean) pair. indicates that a prefix of was output verbatim by the model; the corresponding that it outputs is this prefix. indicates that no sufficiently long prefix of was output verbatim by the model; in this case .
( public attribution): For every security parameter and prompt prompt of length ,
(Unforgeability): For all polynomial-time adversaries ,
where the experiment is given in Figure 5.
Let be a digital signature scheme with signatures of length , and let be a PRC of block length . is the watermarking scheme whose algorithms are specified in Figure 4. Its detector is the same as that of .
is unforgeable if the underlying signature scheme is unforgeable.
Suppose there exists an adversary that wins with non-negligible probability. We construct that uses to break unforgeability of the underlying signature scheme . acts as the challenger in . It receives the signature public key used in from its own challenger for . generates the other parameters for (that is, the PRC parameters) itself. Let denote the resulting public key of the watermarking scheme; passes as input. When responding to ’s queries to , generates the necessary signature using its signing oracle in . Notice that every query that makes to its signing oracle is a contiguous substring of some response , where is the set of responses returned to by . At the end of , outputs . computes ; if , outputs the corresponding and verifying signature .
Recall that if wins, it outputs such that where and is not a contiguous substring of any response in . Since every query made by to its signing oracle was a substring of some response in , did not query this . However, is able to output a verifying signature for , so wins . ∎
Let be any constant. If has block length and is robust to -bounded channels, then satisfies public attribution.
Let be a response, and let be such that .
By the exact same proof as in Lemma 22, the robustness of implies that there is some block with starting index at least , which is correctly decoded by in Algorithm 6. That is, yields a signature computed on the substring of the response up to the start of block . Since starts at index at least , this signed portion has length at least . ∎
Let be any constant. If the underlying signature scheme is unforgeable, and is a PRC with block length and robustness to every -bounded channel, is unforgeable and -publicly-attributable.
Furthermore, retains the same soundness, undetectability, substring-completeness, and substring-robustness properties as . That is, Lemmas 18, 19, 22, 23 and 24 all apply to .
Unforgeabile public attribution follows from Lemmas 25 and 26.
As noted earlier, the proofs of Lemmas 18, 19, 22, 23 and 24 all hold for any choice of message input to . The only difference between and is the choice of message input to . Therefore, those proofs hold for . ∎
Concurrent work [FGJ+23] constructs a watermark that similarly can be detected with a public key but requires a secret key for generation. Their scheme, like , embeds a digital signature in the response and includes the signature verification key in the public key. However, their scheme has two key differences from :
Their scheme has a single detector, analogous to , which is robust only to cropping. In addition to , our scheme also has , which is robust to deletions and/or the binary symmetric channel, depending on the underlying PRC.
[FGJ+23] also discuss using error-correcting codes to improve robustness. They suggest applying an error-correcting code to the message and signature before embedding them. However, this would make the scheme no longer undetectable or distortion-free.
Application: universal steganography
Our main result in this section is the construction of a robust stateless steganography scheme using PRCs. We first prove that robustness follows immediately from applying a PRC to a non-robust steganography scheme appearing in several prior works [AP98, HLVA02, vAH04]. We then show that the assumptions necessary for this scheme can be weakened, which sacrifices some robustness but still yields the most robust scheme in its regime.
We recall the definition of a symmetric steganography scheme as presented in [KJGR21], which is equivalent to that of [HLVA02].
A symmetric steganography scheme is a triple of possibly probabilistic algorithms parameterized by a covertext channel distribution .
generates the key .
is a (possibly probabilistic) algorithm that takes the key and a plaintext message . Additionally, the algorithm can optionally take in a message history of covertext messages, which have presumably been sent over the channel. It returns a stegotext message .
is a (possibly probabilistic) algorithm that takes as input the key , a stegotext , and optionally an ordered set of covertext messages . It returns a plaintext message on success or the empty string on failure.
A scheme in which the sender and receiver maintain a synchronized state is stateful; a scheme without such a requirement is stateless. The above definition captures statefulness by allowing the decoder to take the history as input.
In a public-key steganography scheme, outputs a public-secret key pair. The encoder takes as input the public key (and not the secret key), and the decoder still takes as input the secret key. We refer the reader to [vAH04] for formal definitions of public-key steganography.
A steganography scheme must satisfy correctness and security. Correctness requires that for any history and any message ,
We note that some other works require this probability to be 1.
Security requires that an adversary cannot distinguish between oracle access to or a sampling oracle for the channel distribution.
is secure against chosen hiddentext attacks if for all polynomial-time adversaries , for all ,
This definition can be modified for public-key steganography by giving the adversary the public key as input.
2 Robust stateless steganography
We first present , a steganography scheme that appeared originally in [AP98]. is parameterized by an encryption scheme and a function .
Let . Let and be defined as in Figure 6.
[HLVA02] and [vAH04] prove security of the secret- and public-key versions of , respectively.
Let be a (public-key) encryption scheme with ciphertexts indistinguishable from random bits under a chosen plaintext attack, and let be a function which is unbiased on . Then is a secure (public-key) steganography scheme.
Our first application of PRCs to steganography will be in showing that is robust to errors when a PRC is used as the encryption scheme. To our knowledge, this gives the first robust stateless steganography scheme.
Here, we define robustness of a steganography scheme against a channel analogously to robustness of a PRC. In particular, may be a deletion channel, rather than just making substitutions.
Let be a steganographic channel with symbol alphabet , and let be an error channel. A steganography scheme for is robust to if for all messages and all histories ,
This definition can be adapted for secret-key schemes by replacing with .
We say that the rate of a steganography scheme is the ratio of the number of message bits to the number of symbols of stegotext that are needed to decode the message.
Let be a (public-key) PRC that is robust to some binary channel . Let be a public function which is unbiased on . Then is a (public-key) steganography scheme, with the same rate as , that is robust to any such that .
We use to denote the channel where is applied individually to each symbol of the input, and then is applied to the resulting bitstring. Similarly, is the channel where is applied, and then is applied individually to each symbol of the resulting -string. The condition that means that acts as in the binary representation. For instance, if is a deletion channel over , then is the corresponding deletion channel over ; if is the channel that independently replaces each symbol with a random symbol with probability , and is a random function, then is approximately .
Steganographic security follows immediately from Claim 27 and the fact that a PRC is a pseudorandom encryption scheme.
For robustness, let be an arbitrary message and an arbitrary history, and let . Recall that each is chosen as , where is the output of . Since is unbiased, each sample from satisfies independently with probability , and therefore with overwhelming probability within draws the sampler will output such that .
Given , decoder first computes . Observe that , which by assumption is equal to , where is the output of . By robustness of the PRC, . ∎
Applying Theorem 9 with our PRCs from Section 6.3, we obtain a stateless public-key steganography scheme that is robust to random deletions and substitutions.
3 Stateless steganography from weaker modeling assumptions
The assumption of the existence of an unbiased function over is quite strong. One way to relax this assumption is to assume instead that meets some min-entropy requirement. However, now may be unbalanced; for example, it could be the case that for all . Now, the encoder in Figure 6 would no longer be secure: Consider sampling each symbol in the stegotext to always satisfy . Then, since each is uniform in , half of the symbols in the stegotext would satisfy . Therefore, one could distinguish between stegotexts and samples from using .
A natural way (used by [HLVA02]) to build a secure stateful steganography scheme under only this min-entropy assumption, is to let be an error-corrected version of the message and use in the encoder a rejection sampler that takes at most two samples, sometimes outputting . This rejection sampler preserves the channel distribution as long as is random, which is not the case for generic error-correcting codes. Therefore, [HLVA02] relies on shared state to let the sender and receiver generate a fresh one-time pad per stegotext, letting be an error-corrected message with this one-time pad applied. This shared state significantly simplifies the problem and is a strong assumption of its own.
Relaxing the assumption of an unbiased function poses more challenges for stateless steganography, where this error-correction approach fails. Although [HvAL08] does construct a stateless steganography scheme under only a min-entropy assumption, this scheme has poor robustness. The idea behind this scheme is that the encoder first samples a symbol sequence that is long enough to have min-entropy, and includes this sequence in the stegotext. Since both the encoder and decoder know , can now act as their shared state, and the remainder of the stegotext is formed using a stateful scheme such as that of [HLVA02]. The min-entropy assumption ensures that the state will never be used twice.
Let be a steganographic channel with alphabet , and let be a function. Suppose that there exists some such that for all histories , . Then for any , there exists such that if is any (public-key) PRC for every -bounded channel, then is a (public-key) stateless steganography scheme for , with the same rate as , that is robust to any channel such that .
We begin by showing that is steganographically secure. As in Figure 6, suppose that we wish to encode a message , let , and let be the symbol output by the steganography scheme. Let denote the first sample from and let denote the second sample (which is irrelevant in the event that ).
By pseudorandomness of , it suffices to show that for any , , and ,
Now we turn to showing that is robust to any channel such that , provided that is robust to every -bounded channel for appropriate choice of .
Again, pseudorandomness of allows us to assume is random. Observe that the bits are correlated with the bits :
with probability . Therefore, if is robust to any -bounded channel for , then is robust to . ∎
References
Appendix A Related work
Our approach to constructing pseudorandom codes is closely related to code-based cryptography, and in particular the McEliece cryptosystem. The McEliece cryptosystem is a public-key encryption scheme in which the public key is a generator matrix for a linear code and the secret key is a trapdoor for efficient decoding. In this sense, our constructions of pseudorandom codes can be viewed as instantiations of the McEliece cryptosystem. However, there are two key differences between our setting and that of code-based cryptography that render code-based cryptography results inapplicable for our purposes.
The first difference is in the source of the errors, or noise. PRCs are required to correct uncontrolled errors introduced by an adversarial channel; in McEliece, all of the errors are introduced by an honest user for the purpose of securely sending the message over a perfect channel. Therefore, the channel itself is specified as part of the cryptosystem and the code only needs to be robust to this channel. In pseudorandom codes, it is crucial that we can correct from an arbitrary constant rate of additional errors introduced by a noisy channel on a binary alphabet. Existing code-based cryptosystems (such as binary Goppa codes, Reed-Solomon codes, Reed-Muller codes, or Algebraic Geometry codes) either do not enjoy such strong robustness or rely on a larger alphabet.
The second difference is that we require noisy codewords to be pseudorandom, rather than just hiding. If every (noisy) codeword satisfies some efficiently-computable property , but a uniformly random string does not satisfy , then the code cannot be a PRC. However, such a code might still define a secure encryption scheme, as long as does not distinguish between codewords for different messages.
Our primary construction of PRCs is based on low-density parity-check (LDPC) codes, with somewhat-higher density than is typically considered. The work of [MTSB13] consider “moderate-density parity-check” codes, with density . While their codes suffice for code-based cryptography, they do not enjoy as strong robustness as ours because of the higher density. In particular, they are not robust to any constant rate of substitutions.
PRC-like cryptographic tools.
Error-correcting codes with some pseudorandomness properties have proven useful in cryptographic applications such as pseudorandom correlation generators [BCG+19] and oblivious linear evaluation (OLE) [ADI+17]. However, in all of these applications, decoding requires new side information for each message, such as the locations of the errors. The fundamental difficulty in constructing our pseudorandom codes is that the only extra information provided to the decoder is a single, unchanging secret key; without this key the messages must be pseudorandom.
Pseudorandom encodings, defined and studied in [ACI+20], are similar in name to PRCs but are very different objects. A pseudorandom encoding for a distribution is a pair of unkeyed algorithms such that is pseudorandom (i.e., appears uniform) for a random , and with overwhelming probability. For pseudorandom encodings there is no robustness requirement. Furthermore, pseudorandomness for PRCs requires that is pseudorandom for any of the adversary’s choice.
Language watermarking schemes.
Classical watermarking considers the problem of embedding a signal into a fixed object, such as a given text, in such a way that the watermark is hard to remove, and the quality of the original object is preserved. In that setting, studied specifically for natural language in [TTDI05, ARC+01, ARH+02], planting the watermark must alter the text, and the goal is to minimize some distance measure between the original text and the watermarked text. In contrast, since generative models are randomized, the quality goal of watermarks for generative models is to preserve certain properties of the distribution of the model’s outputs. Due to this difference, new techniques have been developed for watermarking AI-generated content, particularly text output by language models, which is the focus of our watermarking work in this paper.
A language model takes as input a prompt and randomly samples a response using an iterative process. Given a prompt, it computes a probability distribution for the first token and samples a token from this distribution. At each subsequent step, it takes as input the token sequence output thus far, computes the distribution , and samples the token in the response from . It continues doing so until it samples a special “done” token, at which point it terminates and outputs the response. The randomness in this process is important for the usefulness of the model—a model should produce a wide variety of useful responses given the same prompt—and it is crucial for watermarking.
Recently, there have been several language model watermarking schemes proposed (e.g., [Aar22, KGW+23a, CGZ23, ZALW23, KTHL23, FGJ+23]), which embed the watermark by changing the way that each is sampled from . At a very high level, these watermark embedders give preference to certain tokens in the sampling process. The corresponding detectors check for the presence of more preferred tokens than would be expected in independently generated text.
The simplest of these schemes, [ZALW23], fixes a random partition of tokens into equal-sized green and red lists, and it embeds the watermark by increasing the probabilities of tokens on the green list when it samples its response. The detector computes the fraction of green tokens, which should be appreciably greater than for watermarked text and roughly for all other text. This red-green partition is used for every sampled token across all responses, which results in a significant change to the model’s distribution. For example, if “computer” is on the red list, the model now prefers not to talk about computers.
[Aar22, KGW+23a] mitigate this distributional shift by generating the red-green partitions dynamically. Rather than using the same red-green partition for every token, [Aar22, KGW+23a] select a partition for each token using a PRF evaluated at the previous tokens. That is, these schemes use a PRF with secret key , and add weight to tokens such that . This effectively generates a new red-green partition for each token, assuming that no prefix ever appears twice. The detector computes the fraction of tokens on these green lists, which it can compute by evaluating the PRF, provided that the seeds are intact in the given text. The length of the token sequence used as these seeds can be tuned to trade off between robustness and frequency of seed reuse. Longer seeds result in less frequent seed reuse but make the watermark easier to remove, since the adversary can destroy every seed and prevent the detector from computing the green lists by changing only tokens in a watermarked response.
Although [KGW+23a] and [Aar22] both generate randomness using this seeded PRF, they use this randomness to sample from differently, achieving different quality guarantees as a result. The watermarking algorithm in [Aar22] samples tokens such that, for each token of the response, the expected watermarked distribution (over the randomness of ) is identical to the original model’s distribution. However, while individual tokens’ distributions are preserved, the watermark introduces correlations between tokens’ distributions as seeds can be reused (even within the same response). For example, if the same prompt is queried multiple times, the watermark will result in the same bias for the first token of the response each time. [KGW+23a] achieves a weaker guarantee and changes the distribution of the model’s outputs.
The strongest quality guarantee is undetectability, defined by [CGZ23], which is the quality notion we focus on in this work. Undetectability requires that the watermarked model and original model are computationally indistinguishable to an adversary without knowledge of the detection key, even if the adversary can make an unbounded number of adaptive queries. In contrast, distortion-freeness of [KTHL23] says nothing about multiple responses from the model. In particular, a watermark can be distortion-free but render the response to a given prompt entirely deterministic — even if the original model had a great deal of variability on the same prompt.
Like [KGW+23a, Aar22], the watermark in [CGZ23] uses a PRF seeded with previously output tokens to generate the randomness used to bias the token sampler. A crucial observation used in [CGZ23] to avoid the seed reuse issue of [KGW+23a, Aar22], is that if the tokens constituting the seed contain enough entropy, seed reuse becomes unlikely. Because the watermarking algorithm has access to the token distributions, it can compute the amount of entropy in a token sequence and use it as a seed only once this entropy has exceeded a certain threshold. This allows [CGZ23] to achieve undetectability and a robustness guarantee they call substring-completeness, that any sufficiently high-entropy substring of a response will be detected as watermarked. This is essentially the same robustness guarantee as [KGW+23a, Aar22], but it is weaker than that of [KTHL23, ZALW23], since changing one token in every seed removes the watermark.
[FGJ+23] has similar quality to [CGZ23], and embeds a digital signature in the response to make it detectable by anyone with a public detection key. A separate secret key is required to embed the watermark. Similarly to [CGZ23], their watermark generates the initial portion of the response from the original model. It then uses this portion as a seed for a PRF and encodes each bit of a digital signature by sampling a block of tokens such that the PRF evaluated on that block is equal to that bit. Like [CGZ23], changing any token in the seed removes the watermark.
We compare some of these watermarking schemes in Table 1. We refer the reader to [PSF+23] for a more detailed empirical comparison of some of these schemes, and to [KGW+23b] for an empirical study of the robustness of [KGW+23a].
On removing watermarks.
[CGZ23] describe an attack that removes any undetectable watermark and preserves response quality, but this attack is very impractical because it involves querying the model once for each token in the response. [ZEF+23] describe an attack that can remove any watermark in a way that preserves response quality, assuming that the attacker has access to a quality oracle and that random walks over the graph of responses mix sufficiently quickly. These assumptions are quite strong, and it is not clear whether there are fast, reliable quality oracles that don’t already yield a full language model. Still, in light of these impossibility results, one cannot hope to have a watermarking scheme that is robust against all possible attacks — indeed, an adversary with sufficient knowledge of the language could always write a high-quality text without even consulting the watermarked model. Therefore, we instead define robustness against particular classes of adversaries, including those that delete and substitute tokens.
Other techniques for detecting machine-generated text.
Another approach for detecting AI-generated text is to train a machine learning classifier to distinguish between AI-generated and natural text [ZHR+19, MLK+23, Tia23, KAAL23]. However, these classifiers lack transparency, can be easily evaded, have high false-positive rates, and have unpredictable biases. OpenAI retracted its classifier-based detector due to these issues.
Instead of relying on existing idiosyncrasies of AI-generated text, watermarks embed patterns themselves, making detection more reliable and transparent. See, e.g., [TCH23, PSF+23] for an overview of the various approaches to detecting AI-generated text.
Undetectable backdoors for models.
[GKVZ22] shows how to embed a hidden “backdoor” during training of a model. Using a secret key, one can “activate” the backdoor by slightly perturbing inputs to alter their classification under the backdoored model. These backdoors are undetectable in the sense that, without the secret key, one cannot distinguish between an honestly trained or a backdoored model. While not closely related to our work in technical content, [GKVZ22] is similar in spirit as an application of cryptographic definitions and techniques to machine learning.
Universal steganography.
Steganography was introduced by Simmons [Sim84], who presented it as problem where two prisoners wish to communicate in the presence of a warden, hiding not only the content of their communication but also the fact that this communication is occurring. [HLVA02] first formalized steganography in the computational setting. Here, there is some distribution of covertexts in which the sender wishes to conceal its message. In Section 8, we consider universal steganography, where the covertext distribution is an arbitrary distribution to which the sender has sample access. The sender uses this sample access and a secret key to construct a stegotext that encodes the message, which the receiver decodes using the secret key.
Loosely speaking, steganographic security requires that an outside observer cannot distinguish stegotexts from covertexts, and furthermore cannot learn anything about the message. There are several security variants in the literature, including information-theoretic security [Cac98] and security against active attacks [BC05, Hop05]. We focus on (computational) security against chosen message attacks (CMA) as defined in [HLVA02], which is analogous to CPA security of encryption. There are several constructions of CMA-secure secret-key steganography schemes under certain assumptions, including [HLVA02, HvAL08, DIRR09]. We present a comparison of these schemes’ properties in Table 2. All of these schemes either make the very strong assumption that there is a known hash function that is unbiased on the covertext distribution, or else rely on a synchronized shared state between the sender and receiver.
An additional desirable property of a stegosystem, and one that is challenging to achieve, is robustness: Even if the stegotext is corrupted by an adversary, the receiver should be able to recover the message. To the best of our knowledge, prior to this work there was no provably secure stateless secret-key stegosystem with nontrivial robustness.
Our robustness notion is different from that of [HLVA02], called substitution-robustness. In substitution-robustness, an adversary may make substitutions of some symbols of the stegotext before it is given to the receiver, which should still recover the message. The set of substitutions that their adversary is allowed to make is parameterized by a relation . That is, the adversary can change any symbol to a symbol provided that . This definition breaks down when the alphabet is binary, since if is nontrivial, containing without loss of generality , the adversary can change all stegotexts to the all-one string. Furthermore, it does not capture an adversary that has a bound on the number of symbols it may change, but that can change each symbol to any other symbol. Our definition is thus incomparable to theirs, and our channel may introduce deletions rather than just substitutions.
While [HLVA02] constructs a robust steganography scheme under this relation-based definition, they assume that the sender and receiver can share some state; in their scheme, this state is a synchronized counter of the number of messages sent so far. See Section 2.7 for a discussion on synchronized states in steganography.
As with encryption, steganography has a public-key analogue, which was defined formally by [vAH04]. That is, encoding is possible with a public key, and decoding requires a secret key. While [vAH04] was the first to define and formally prove security of public-key steganography, public-key schemes existed in prior work [AP98, Cra98]. The main steganography construction in this work is public-key as well.
While we focus on steganography with provable security in the models of [HLVA02, vAH04], we note that there is a large body of work that constructs steganography schemes with heuristic guarantees. We refer the interested reader to [Fri09].
Language model steganography.
The formal setting of steganography from [HLVA02] assumes that the sender has sample access to the covertext distribution. It is unclear how to realize this assumption in practice: If the sender wishes to conceal its message in casual conversation, it must be able to sample a random casual conversation. One solution is to use a language model as this sampler for the covertext distribution, and there are several language model steganography schemes tailored to this setting where the sender interacts with a language model to craft its stegotexts [KJGR21, dWSK+22, ZDR19, Zam24]. This is a relaxation of universal steganography, since these language model steganography schemes leverage the sender’s explicit access to the covertext distribution via the model. Therefore, our universal steganography scheme in Section 8 is incomparable to these schemes.
Language model steganography and undetectable watermarks for language models are closely related, as both are concerned with secretly embedding a signal in the output of a language model. Indeed, we note in Section 7.2 that our watermarking scheme yields a language model steganography scheme, since undetectability implies steganographic secrecy. Our resulting steganography scheme has the strongest robustness of any existing scheme, and in particular is the only language model steganography scheme with robustness to a constant rate of random substitutions.
[Zam24] presents a language model steganography scheme derived from the watermarking scheme of [CGZ23]. This scheme is also stateless and relies on a minimal entropy assumption about the text, but it is not public-key or robust.
In Meteor [KJGR21], the sender and receiver share a generative language model, and they maintain a shared history of the prompt and all tokens output thus far by the model. To encode a message, the sender queries the model to obtain the distribution over the next token. It then samples the next token in a way that encodes some information about the message. Because the sender and receiver share the model description and the token history including the prompt, the receiver can compute . Meteor crucially uses the ability of the receiver to compute , in order to decode the message. Any change to the text history at all (even removing the prompt) can destroy the receiver’s ability to compute , and therefore the receiver’s ability to decode the message.
[dWSK+22] constructs a steganography scheme using minimum entropy couplings, in the information theoretic setting of [Cac98]. In their scheme, the decoder also must know the prompt used, as it requires access to an explicit description of the covertext distribution which is determined by the prompt. Furthermore, the adversary is not allowed to tamper with the stegotexts.
Backdoored/trapdoor PRGs.
A trapdoor or backdoored PRG [VV83, DGG+15] is a pseudorandom generator that outputs a sequence of bits that are pseudorandom to an observer, but where a party holding a secret key can distinguish this sequence from random. In the context of backdoored PRGs, the secret key is viewed as a potential vulnerability of the PRG. A PRC is in particular a trapdoor/backdoored PRG, since codewords appear uniformly random to an outside observer but can be detected with a secret key.
However, a PRC comes with the additional property of robustness. This is especially interesting in the context of backdoored PRGs, where an immunizer may be applied to the PRG output in an attempt to thwart the adversary holding the backdoor. For example, one might apply a hash to the PRG output; [DGG+15] show that this immunizer is effective for certain PRGs. In that work they consider three classes of immunizers: public immunizers where the adversary can construct the trapdoor PRG based on knowledge of the seed of the function to be applied, semi-private immunizers where the adversary does not know the seed when constructing the PRG but does know it at attack time, and private immunizers where the adversary does not know the seed at all. Our PRCs show a strong impossibility result for immunizers against an adversary distinguishing PRG outputs from uniform randomness. For any immunizers in the class of channels that the PRC is robust to, the adversary can distinguish a single immunized output from uniform randomness with overwhelming probability. This applies even to private immunizers, since the randomness of the channel is not known to the code detection algorithm.