diff --git "a/abs_29K_G/test_abstract_long_2405.02696v1.json" "b/abs_29K_G/test_abstract_long_2405.02696v1.json" new file mode 100644--- /dev/null +++ "b/abs_29K_G/test_abstract_long_2405.02696v1.json" @@ -0,0 +1,72 @@ +{ + "url": "http://arxiv.org/abs/2405.02696v1", + "title": "DiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model", + "abstract": "Latent Diffusion Models (LDMs) enable a wide range of applications but raise\nethical concerns regarding illegal utilization.Adding watermarks to generative\nmodel outputs is a vital technique employed for copyright tracking and\nmitigating potential risks associated with AI-generated content. However,\npost-hoc watermarking techniques are susceptible to evasion. Existing\nwatermarking methods for LDMs can only embed fixed messages. Watermark message\nalteration requires model retraining. The stability of the watermark is\ninfluenced by model updates and iterations. Furthermore, the current\nreconstruction-based watermark removal techniques utilizing variational\nautoencoders (VAE) and diffusion models have the capability to remove a\nsignificant portion of watermarks. Therefore, we propose a novel technique\ncalled DiffuseTrace. The goal is to embed invisible watermarks in all generated\nimages for future detection semantically. The method establishes a unified\nrepresentation of the initial latent variables and the watermark information\nthrough training an encoder-decoder model. The watermark information is\nembedded into the initial latent variables through the encoder and integrated\ninto the sampling process. The watermark information is extracted by reversing\nthe diffusion process and utilizing the decoder. DiffuseTrace does not rely on\nfine-tuning of the diffusion model components. The watermark is embedded into\nthe image space semantically without compromising image quality. The\nencoder-decoder can be utilized as a plug-in in arbitrary diffusion models. We\nvalidate through experiments the effectiveness and flexibility of DiffuseTrace.\nDiffuseTrace holds an unprecedented advantage in combating the latest attacks\nbased on variational autoencoders and Diffusion Models.", + "authors": "Liangqi Lei, Keke Gai, Jing Yu, Liehuang Zhu", + "published": "2024-05-04", + "updated": "2024-05-04", + "primary_cat": "cs.CR", + "cats": [ + "cs.CR", + "cs.AI" + ], + "label": "Original Paper", + "paper_cat": "Diffusion AND Model", + "gt": "Latent Diffusion Models (LDMs) enable a wide range of applications but raise\nethical concerns regarding illegal utilization.Adding watermarks to generative\nmodel outputs is a vital technique employed for copyright tracking and\nmitigating potential risks associated with AI-generated content. However,\npost-hoc watermarking techniques are susceptible to evasion. Existing\nwatermarking methods for LDMs can only embed fixed messages. Watermark message\nalteration requires model retraining. The stability of the watermark is\ninfluenced by model updates and iterations. Furthermore, the current\nreconstruction-based watermark removal techniques utilizing variational\nautoencoders (VAE) and diffusion models have the capability to remove a\nsignificant portion of watermarks. Therefore, we propose a novel technique\ncalled DiffuseTrace. The goal is to embed invisible watermarks in all generated\nimages for future detection semantically. The method establishes a unified\nrepresentation of the initial latent variables and the watermark information\nthrough training an encoder-decoder model. The watermark information is\nembedded into the initial latent variables through the encoder and integrated\ninto the sampling process. The watermark information is extracted by reversing\nthe diffusion process and utilizing the decoder. DiffuseTrace does not rely on\nfine-tuning of the diffusion model components. The watermark is embedded into\nthe image space semantically without compromising image quality. The\nencoder-decoder can be utilized as a plug-in in arbitrary diffusion models. We\nvalidate through experiments the effectiveness and flexibility of DiffuseTrace.\nDiffuseTrace holds an unprecedented advantage in combating the latest attacks\nbased on variational autoencoders and Diffusion Models.", + "main_content": "INTRODUCTION The strides made in latent diffusion models [10, 17, 28, 35] have substantially elevated the capacity for synthesizing photorealistic content in image generation and profoundly impact text-to-image [32, 46], image editing [5, 24], in-painting [21, 31], super-resolution [12, 33], content creation [26, 27] and video synthesis [4, 16]. Relevant commercial applications are becoming mainstream creative tools for designers, artists, and the general public. However, contemporary text-to-image generation models, such as Stable Diffusion and Midjourney, can generate a multitude of novel images as well as convincing depictions of fabricated events for malicious purposes. Criminals might utilize LDMs to produce insulting or offensive images, which shall be disseminated to spread rumors and pose a substantial threat to societal security. The hazards of deepfakes, impersonation and copyright infringement are also prevalent issues associated with current generative models. The potential illicit use of text-to-image models has spurred research for embedding watermarks in model outputs. Watermarked images contain signals imperceptible to humans but are marked as machine-generated. Copyright information of the model and the identity information of the model users will be embedded into images. Extracting watermarks from AI-generated images enables the detection of model copyrights and tracing unauthorized users. False and harmful images can be promptly identified and removed from platforms and unauthorized users of the model can be traced through the extraction of image information, which mitigates the potential harm caused by AI-generated content. Existing research on image watermarking tended towards postprocessing solutions. The core concept involves embedding the watermark into the image with minimal adjustments, emphasizing subtlety and intricacy. For instance, the watermark implemented arXiv:2405.02696v1 [cs.CR] 4 May 2024 \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu in Stable Diffusion [8] operates by altering a particular Fourier frequency within the generated image. This type of watermark faces a key trade-off between watermark robustness and image quality. For diffusion model watermarks, Some researchers have proposed embedding fixed messages into generated images by fine-tuning diffusion models like U-Net [30] or variational autoencoders. However, this approach only allows embedding fixed information into the generated images, requiring re-finetuning of the diffusion model when the embedding information needs to be changed. Moreover, if the model owner distributes the diffusion model to a large number of users, each distributed model must be fine-tuned separately, resulting in significant consumption of computational resources and time. Additionally, when the model requires iterative updates, the stability of the watermark becomes unreliable due to adjustments in model parameters. Recent studies [48] have demonstrated that methods involving the random addition of noise to images to disrupt watermarks, followed by image reconstruction using diffusion models, can effectively remove a significant portion of post-processing watermarking schemes. This poses new challenges to the robustness of watermarking. To address the aforementioned challenges and achieve high extraction accuracy, robustness and image quality, we propose a new watermarking scheme called DiffuseTrace. DiffuseTrace differs fundamentally from previous watermarking methods. DiffuseTrace embeds the watermark into the latent variables of the model, subtly influencing the sampling phase of the model. The watermark is embedded at the semantic level prior to image generation, without any post-processing of the generated images. We specialize in a watermarking scheme that can be seamlessly integrated into a wide range of latent diffusion models. DiffuseTrace can serve as a plug-and-play solution across various diffusion models. Taking practical application scenarios into account, we categorize the roles involved in model usage into two types: model producers and model users. Model producers train and possess all pre-trained models, including diffusion models, watermark encoders, watermark decoders. Model producers assign specific binary identity information to each user. By providing APIs, model producers offer generative model services to users. When malicious images resembling model-generated content or images suspected of copyright infringement appear on art platforms, news outlets or other sharing platforms, model producers can trace illegal usage or infringement-involved users by extracting watermark information from the generated images. For watermark modules, we control the distribution of the watermark through an encoder and dynamically allocate a watermark close to the standard normal distribution for each user. Since the data distribution and sampling process remain consistent with the original model, the generated images can achieve transparent watermark embedding with semantic consistency. Human inspection cannot distinguish watermark samples from random samples. Through transforming images into latent variables and inversely diffusing them to obtain the initial latent variables, the watermark can be decoded through a decoder. Considering the diverse processing stages in the flow of image data as well as the potential bias introduced by the inverse diffusion of the diffusion model, we employ adversarial training and fine-tuned the watermark decoder to enhance the robustness of watermark extraction. The primary contributions of this work are outlined as follows: (1) Among diffusion watermarking schemes based on initial hidden variables, DiffuseTrace is the first scheme that embeds robust multi-bit watermarks. DiffuseTrace is embedded at the semantic level of diffusion-model-generated images without relying on the trade-off between image quality and watermark robustness. It exhibits evident advantages over post-processing methods in terms of image quality. (2) Compared to the state-of-the-art post-processing watermarking and diffusion model watermarking schemes, DiffuseTrace not only exhibits significant performance in common image processing but also shows remarkable robustness against attacks based on variational autoencoders and diffusion models. The paper provides a thorough analysis at the theoretical level regarding the superior watermark robustness of DiffuseTrace. (3) The proposed universal watermark module for latent diffusion models can be seamlessly integrated across different versions of diffusion models. The watermark message of DiffuseTrace can be flexibly modified without being affected by model fine-tuning or model update iterations. Our code is open source: https://anonymous.4open.science/r/DiffuseTrace6DED. Paper Organization. The overview of this paper is organized as follows: The basic introduction of DiffuseTrace is shown in Section 1. The background of DiffuseTrace are summarized in Section 2. In Section 3, we introduce the problem formulation for DiffuseTrace. In Section 4, we demonstrate DiffuseTrace in detail. In Section 5, We have provided a detailed theoretical exposition and security analysis of the proposed scheme. In Section 6, we summarize and analyze the experimental results. In Section 7, we present the realted work of watermarking for LDMs. In Section 8, we summarize the DiffuseTrace watermarking scheme. 2 BACKGROUND 2.1 Diffusion Model based Image Generation Diffusion models progressively transitions the sample x from the true data distribution \ud835\udc5d(\ud835\udc65) to stochastic noise and adeptly reverses this process through iterative denoising of the noisy data [17]. A typical diffusion model framework involves a forward process that progressively diffuses the data distribution \ud835\udc5d(\ud835\udc65,\ud835\udc50) towards the noise distribution \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61,\ud835\udc50) for \ud835\udc61\u2208(0,\ud835\udc47], where c denotes the conditional context. The conditional gaussian distribution of the diffusion process can be formulated as: \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61|\ud835\udc65) = \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61|\ud835\udefc\ud835\udc61\ud835\udc65, \ud835\udf0e2 \ud835\udc61\ud835\udc3c), (1) where \ud835\udefc\ud835\udc61, \ud835\udf0e\ud835\udc61\u2208R+. \ud835\udefc\ud835\udc61and \ud835\udf0e\ud835\udc61are the strengths of signal and noise respectively decided by a noise scheduler. \ud835\udc67\ud835\udc61= \ud835\udefc\ud835\udc61\ud835\udc65+ \ud835\udf0e\ud835\udc61\ud835\udf16is the noisy data. It has been proved that there exists a denoising process with the same marginal distribution as the forward process [35]. The estimation of the only variable can be derived as: \u25bd\ud835\udc67\ud835\udc61log\ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61,\ud835\udc50) \u2248 \ud835\udefc\ud835\udc61\ud835\udc65\ud835\udc61 \ud835\udf03(\ud835\udc67\ud835\udc61,\ud835\udc50) \u2212\ud835\udc67\ud835\udc61 \ud835\udf0e2 \ud835\udc61 . (2) Specifically, given a noise-predicting diffusion model parameterized by \ud835\udf03, which is typically structured as a U-Net [30], training can be \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY T T M Step1: DiffuseTrace Enc./Dec. Pretraining M\u2019 Step2: DiffuseTrace Decoder Finetuning \u201c a cute cat \u201d Step3: Sematic Watermarked Image Generation Initial Latents Distribute Sample Watermark Region M Sample Distribute Initial Latents Attack ... Iterative Denoising \ufffd0 VAE Reconstruct T Locate M\u2019 Watermark Region W Sample Distribute Initial Latents \u201c a cute cat \u201d Diffusion Model Step4: Watermark Message Extraction Diffusion Inversion Reconstruct Locate Watermark Region W Diffusion Model DiffuseTrace Enc./Dec. U-Net of Diffusion Model Variational Autoencoder VAE Rec. Loss Distri. Loss Figure 1: Methods of DiffuseTrace. (Step1) Train the DiffuseTrace Encoder through resampling methods to generate latent variables approximate to a standard normal distribution and jointly train the decoder to decode the information. M: Random n-bit messages. (Step2) Keep the encoder fixed and train the decoder. Randomly select prompts for the diffusion model denoising process to generate images. Decode the images after passing through the attack layer to obtain latent variables and execute diffusion inversion to extract the initial latent variables. Compare the decoded message from the initial latent variables with the initial message to build a reconstruction loss for fine-tuning the decoder. (Step3) Assign watermark message w and generate initial watermarked latent variables by the encoder to generate images. (Step4) Extract watermark message after inverting the images and trace the source through statistical testing. formulated as the following noise prediction problem: \ud835\udc5a\ud835\udc56\ud835\udc5b \ud835\udf03 E\ud835\udc65,\ud835\udc61,\ud835\udf0e|| \u02c6 \ud835\udf16\ud835\udf03(\ud835\udefc\ud835\udc61\ud835\udc65+ \ud835\udf0e\ud835\udc61\ud835\udf16,\ud835\udc61) \u2212\ud835\udf16||2 2, (3) where \ud835\udc61refers to the time step; \ud835\udf16is the ground-truth noise; the noise \ud835\udf16\u223cN (\ud835\udf16|0, \ud835\udc3c) is a standard Gaussian. Recently, LDMs [28] streamlines inference processes by incorporating denoising process within the encoded latent space derived from a pre-trained variational autoencoder (VAE) [6]. Diffusion models reconstructs images through the latent state. During the inference phase, stable diffusion models take both a latent seed and a text prompt as an input. The U-Net progressively removes noise from random latent image representations guided by text embeddings. The noise residual from the U-Net is utilized in conjunction with a scheduler algorithm to generate a denoised latent. When synthesizing images, a crucial technique, classifierfree guidance is adopted to enhance the quality of generated images. \u02dc \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udc50) = \ud835\udc64\u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udc50) + (\ud835\udc64\u22121) \u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udf19) (4) where The guidance scale \ud835\udc64can be modified to regulate the influence of conditional information on the produced images, aiming to strike a balance between quality and diversity. \u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udf19) denotes the unconditional diffusion obtained by empty prompt. 2.2 Diffusion Denoising and Inversion The well-trained diffusion model leverages a diverse range of samplers to generate samples from noise and execute denoising procedures. A notable denoising method is the Denoising Diffusion Implicit Model (DDIM) [34] which stands out for its efficiency and deterministic output. DDIM accomplishes denoising with significantly fewer steps. The image \ud835\udc650 will be reproduced with 50 inference steps to the standard 1000-step process. Formally, for each denoising step \ud835\udc61, DDIM utilizes a learned noise predictor \ud835\udf16\ud835\udf03to estimate the noise \ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) added to \ud835\udc650, which leads to the estimation of \ud835\udc650 as follows: \u02c6 \ud835\udc650 = \ud835\udc65\ud835\udc61\u2212\u221a1 \u2212\u00af \ud835\udefc\ud835\udc61\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) \u221a\u00af \ud835\udefc\ud835\udc61 . (5) the estimated noise \ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) is recombined with the approximated \u02c6 \ud835\udc650 to compute \ud835\udc65\ud835\udc61\u22121: \ud835\udc65\ud835\udc61\u22121 = \u221a\u00af \ud835\udefc\ud835\udc61\u22121 \u02c6 \ud835\udc650 + \u221a1 \u2212\u00af \ud835\udefc\ud835\udc61\u22121\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) . (6) DDIM also incorporates an inversion mechanism [10], which facilitates the reconstruction of the noise representation \ud835\udc65\ud835\udc47from an image \ud835\udc650. The recovered \ud835\udc65\ud835\udc47should be mappable to an image approximate to \ud835\udc650. Based on the assumption that \ud835\udc65\ud835\udc61\u22121 \u2212\ud835\udc65\ud835\udc61\u2248\ud835\udc65\ud835\udc61+1 \u2212\ud835\udc65\ud835\udc61, The DDIM inversion shall be formulated as: \u02c6 \ud835\udc65\ud835\udc61+1 = \u221a\u00af \ud835\udefc\ud835\udc61+1\ud835\udc650 + \u221a1 \u2212\u00af \ud835\udefc\ud835\udc61+1\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) (7) Essentially, this process follows the forward diffusion process as described in Equation 6. Diffusion inversion, even in zero-text inversion within conditional diffusion, can still achieve decent accuracy. Meanwhile, the method is applicable to deterministic sampling methods like DPM++ [20]. Our watermarking scheme leverages this property of diffusion inversion. \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 3 PROBLEM FORMULATION 3.1 Threat Model In this paper, we consider two parties: the defender and the adversary. The defender is the owner of the generative model. Latent diffusion model is deployed as an online service. The core objectives are protecting the copyright of the model and tracing the illegal usage through model outputs. Conversely, the adversary\u2019s objective is to disrupt the watermark information in the model output and circumvent the copyright protection and tracing mechanisms of the model. Adversary\u2019s Motivation. The adversary\u2019s motivation stems from two aspects: Firstly, training a latent diffusion model requires gathering a significant amount of data, expertise in architecture or algorithms and numerous failed experiments, all of which are expensive. As a result, the model parameters are considered proprietary information for businesses. Generative model services are deployed as online services. Adversaries may manipulate images to destroy watermark information and redistribute the outputs of online services to cloud platforms, effectively becoming commercial competitors. Secondly, Attackers may exploit online generative services to generate insulting or offensive images for malicious purposes such as fabricating fake news or spreading rumors and remove watermarks from the images to evade tracing. Adversary\u2019s Background Knowledge. We assume that adversaries can access the victim\u2019s latent diffusion model in a black-box manner. Attackers can query the victim\u2019s latent diffusion model with data samples and obtain corresponding responses. Specifically, we categorize adversary background knowledge into two dimensions: the architecture of the victim\u2019s diffusion model and the watermark removal capability. For the architecture of the diffusion model, we assume adversaries can access it since such information is typically publicly accessible. Regarding watermark removal capability, we assume adversaries can manipulate images using techniques such as Gaussian blur, color jittering and image compression. Meanwhile, we consider adversaries who possess the capability to perform state-of-the-art watermark removal attacks using variational autoencoders and diffusion models. 3.2 Image Watermarking and Verification Formally, the validation scheme for generative image watermarking in Diffusers is defined as follows: The generative image watermarking verification scheme is a tuple Verification = \u27e8\ud835\udc47\ud835\udc5f\ud835\udc5b, \ud835\udc38\ud835\udc5a\ud835\udc4f, \ud835\udc38\ud835\udc63\ud835\udc4e,\ud835\udc49\ud835\udc5f\ud835\udc53\u27e9of processes: A Train process \ud835\udc47\ud835\udc5f\ud835\udc5b(\ud835\udc37,\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7], \ud835\udc3f) = {\ud835\udc38\ud835\udc5b\ud835\udc50[\ud835\udc4a], \ud835\udc37\ud835\udc52\ud835\udc50[\ud835\udc4a]}, is a fine-tuning or training process that takes training data \ud835\udc37= {\ud835\udc65\ud835\udc51,\ud835\udc66\ud835\udc51} as inputs and outputs the models \ud835\udc38\ud835\udc5b\ud835\udc50[\ud835\udc4a] and \ud835\udc37\ud835\udc52\ud835\udc50[\ud835\udc4a] by minimizeing a given loss L. An embedding process \ud835\udc38\ud835\udc5a\ud835\udc4f(\ud835\udc5d\ud835\udc5f\ud835\udc5a,\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7], \ud835\udc3f\ud835\udc4e\ud835\udc61,\ud835\udc46\ud835\udc56\ud835\udc54) = \ud835\udc43\ud835\udc56\ud835\udc50 [\ud835\udc46\ud835\udc56\ud835\udc54] is an inference process that embeds the signature \ud835\udc46\ud835\udc56\ud835\udc54into latent variables through an encoder and performs inference through the model \ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7] to output the watermarked image \ud835\udc43\ud835\udc56\ud835\udc50[\ud835\udc46\ud835\udc56\ud835\udc54]. An quality evaluation process \ud835\udc38\ud835\udc63\ud835\udc4e\ud835\udc59(\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc40, \ud835\udc3f\ud835\udc4e\ud835\udc61,\ud835\udf16) = {\ud835\udc47\ud835\udc5f\ud835\udc62\ud835\udc52, \ud835\udc39\ud835\udc4e\ud835\udc59\ud835\udc60\ud835\udc52} is to evaluate whether or not the discrepency is less than a predefined threshold i.e. |\ud835\udc40(\ud835\udc34\ud835\udc5f\ud835\udc50[\ud835\udc4a,\ud835\udc46\ud835\udc56\ud835\udc54], \ud835\udc3f\ud835\udc4e\ud835\udc61, \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7]) \u2212\ud835\udc40| \u2264\ud835\udf16, where \ud835\udc40(\ud835\udc34\ud835\udc5f\ud835\udc50[\ud835\udc4a,\ud835\udc46\ud835\udc56\ud835\udc54], \ud835\udc3f\ud835\udc4e\ud835\udc61, \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7]) denotes the image fidelity or semantic consistency tested against a set of watermarked latents. \ud835\udc40is the target generation performance. A verification process \ud835\udc38\ud835\udc63\ud835\udc4e(\ud835\udc3c\ud835\udc5a\ud835\udc54, \ud835\udc46\ud835\udc56\ud835\udc54, \ud835\udc34\ud835\udc61\ud835\udc58, \ud835\udc37\ud835\udc52\ud835\udc50[\u00b7],\ud835\udf16) = {\ud835\udc47\ud835\udc5f\ud835\udc62\ud835\udc52, \ud835\udc39\ud835\udc4e\ud835\udc59\ud835\udc60\ud835\udc52} checks whether the expected signature \ud835\udc46\ud835\udc56\ud835\udc54of a given generative image can be successfully verified by Decoder \ud835\udc37\ud835\udc52\ud835\udc50[\u00b7] when facing image attacks. Watermark Detaction. DiffuseTrace embed a k-bit secret message \ud835\udc5a\u2208{0, 1}\ud835\udc58into the watermark image. The watermark detection algorithm includes an extractor that can extract the hidden signal \ud835\udc5a\u2032 from the watermarked image. It uses statistical testing to set a threshold \ud835\udf0f\u2208{0, 1, 2...\ud835\udc58} for the extracted bits . If the number of matching bits \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) \u2265\ud835\udf0f, the image is marked as watermarked. Formally, We establish the hypothesis H1: The image pic is generated by DiffuseTrace against the null hypothesis H0: The image is not generated by DiffuseTrace. Under \ud835\udc3b0, we assume that the extracted bits \ud835\udc5a\u2032 1,\ud835\udc5a\u2032 2...\ud835\udc5a\u2032 \ud835\udc58are independent and identically distributed Bernoulli random variables with a probability of 0.5. \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) follows a binomial distribution \ud835\udc35(\ud835\udc58, 0.5). Type I error (false positive rate (FPR) , \ud835\udf0e) equals the probability of \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) exceeding \ud835\udf0f, derived from the binomial cumulative distribution function. It has a closed form using the regularized incomplete beta function \ud835\udc3c\ud835\udc65(\ud835\udc4e;\ud835\udc4f). \ud835\udf161(\ud835\udf0f) = P(\ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) > \ud835\udf0f| \ud835\udc3b0) = 1 2\ud835\udc58 \ud835\udc58 \u2211\ufe01 \ud835\udc56=\ud835\udf0f+1 ( \ud835\udc58 \ud835\udc56 ) = \ud835\udc3c1/2(\ud835\udf0f+ 1,\ud835\udc58\u2212\ud835\udf0f). (8) If we reject the null hypothesis \ud835\udc3b0 with a p-value less than 0.01, we consider the image to be without a watermark. In practice, for a watermark of 48 bits (\ud835\udc58= 48), at least 34 bits should be extracted to confirm the presence of the watermark. This provides a reasonable balance between detecting genuine watermarks and avoiding false positives. 3.3 Objective for Watermarking DiffuseTrace should have the following propeties: Robust against Watermarking Attacking: Images with watermarks may undergo various image processing operations. Even after post-processing, the watermark can still be fully recovered. DiffuseTrace should withstand watermark removal attacks, such as Gaussian noise, color jittering, Gaussian blur and others. Meanwhile, DiffuseTrace should be able to defend against the latest watermark attacks based on the state-of-the-art variational autoencoder and diffusion model techniques. Generalizability: Considering the cost of embedding fixed information into fine-tuned models, DiffuseTrace can adjust embedded message flexibly and should be compatible with various versions of diffusion models and remain unaffected by model fine-tuning or model update iterations. Fidelity: Minimizing the impact on the model\u2019s output before and after watermarking to the greatest extent possible. The images generated by the DiffuseTrace maintain consistency with the original model in terms of semantic consistency and image quality. The watermark samples generated by DiffuseTrace should exhibit no significant differences in visual and semantic quality compared to normal samples. \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY The goal is to design a watermark that is flexible, robust to postprocessing, generalizable and does not compromise the quality or semantic consistency of the image. Additionally, it should remain unaffected by model fine-tuning or update iterations. 4 PROPOSED WATERMARKING SCHEME 4.1 Overview The overview of our method is in figure 1. As described in the first section, we have three objectives: \u2022 The watermark is embedded into the initial latent variables at the semantic level without altering semantic consistency and image quality. \u2022 Watermark messages can be modified flexibly without retraining or fine-tuning the model. \u2022 The watermark is robust against various image processing techniques and state-of-art watermark removal methods. The core idea of DiffuseTrace is to embed the watermark into latent variables. The initial latent variables of the latent space are divided into multiple watermark regions, with each region corresponding to a portion of the watermark information. To ensure both lossless quality and semantic consistency of the image, the embedded watermark should approximate a standard normal distribution and be extractable by the decoder. Specifically, DiffuseTrace consists of a watermark encoder and watermark decoder. The model owner encodes the initial latent variables through the watermark encoder. The latent variables are then processed through a scheduler guided by prompts and denoised through a U-Net. Afterward, latent variables are decoded by a variational autoencoder into watermarked images. The watermarked images are subjected to an attack layer and decoded back into the latent space. Through diffusion inversion, the original latent variables are restored. The watermark is then extracted from the decoded latent variables through the decoder. 4.2 Pre-training Watermark Encoder-Decoder The paper pretrains the encoder-decoder structure for watermark embedding and extraction. The training objective of the encoder is to construct a unified representation of watermark information and latent variables under a standard Gaussian distribution based on the watermark information and the embedded watermark region. Specifically, when binary identity information of the user is inputted into the encoder, it will produce watermark-embedded latent variables which adhere to a standard Gaussian distribution. The following explains the reason for latent variables with watermark conforming to a standard normal distribution. When the latent generator of the LDM samples latent variables \ud835\udc4dfrom noise, the function of the U-Net is to iteratively denoise Gaussian noise matrices within the diffusion cycle guided by text and timesteps. By subtracting the predicted noise from random Gaussian noise matrices, the random Gaussian noise matrices are eventually transformed into the latent variables of the image. Since the noise introduced during the training process of the U-Net follows a normal distribution, the initial latent variables of the LDM inference process should ideally approximate a standard normal distribution. When training a variational autoencoder to encode images into latent variables, one of the training objectives is to approximate the latent variables to adhere roughly to a standard normal distribution. More precisely, the training set for U-net involves repeatedly adding noise from a standard normal distribution to images. With a sufficient number of iterations, the original images will converge close to a standard normal distribution. Hence, during the denoising image generation phase, the initial noise is selected to conform to a standard normal distribution. If there is a significant deviation of the initial noise from the standard normal distribution, it may lead to inconsistencies between image quality and semantics. Watermarked latent variables that are closer to a standard normal distribution better conform to the standard denoising process. Due to the non-differentiability and gradient descent limitations of distributions, the encoder\u2019s model architecture employs the reparameterization technique to generate watermark-embedded latent variables. Considering the difficulty of explicitly distributing watermark regions at the trillion level, we have adopted an implicit partitioning of the watermark regions. Sampled latent variables are constrained by Kullback-Leibler divergence to approximate a standard normal distribution. Each watermark information independently maps to a portion of the probability distribution. The specific principles are detailed in our theoretical analysis 5. The decoder network is the inverse of the encoder. The training objective of the decoder is to extract watermark information from the initial latent variables. The encoder and decoder are jointly trained to ultimately produce watermark-embedded latent variables that conform to a standard normal distribution. The decoder then outputs the corresponding watermark information based on these latent variables. According to the analysis of 5.2, the reconstruction of watermark refers to maximizing the expected probability distribution of the watermark \ud835\udc64given the latent variable. The loss for reconstructing the message L\ud835\udc64is calculated as the Mean Square Error (MSE) loss between the original watermark message and the decoded message: L\ud835\udc64= \ud835\udc40\ud835\udc46\ud835\udc38(\ud835\udc5a\ud835\udc52\ud835\udc60\ud835\udc60\ud835\udc4e\ud835\udc54\ud835\udc52,\ud835\udc51\ud835\udc52\ud835\udc50(\ud835\udc5a\ud835\udc52\ud835\udc60\ud835\udc60\ud835\udc4e\ud835\udc54\ud835\udc52\u2032)) (9) For the loss of the initial latent variable distribution, We compute the Kullback-Leibler (KL) divergence between the distribution of the latent variables and the standard normal distribution as the distribution loss. KL divergence is a measure of how one probability distribution diverges from the expected probability distribution. Suppose we have two probability distributions P and Q for a random variable \ud835\udf09. If \ud835\udf09is a discrete random variable, the KL divergence from P to Q is defined as: DKL(\ud835\udc43\u2225\ud835\udc44) = \u2211\ufe01 \ud835\udc56 \ud835\udc43(\ud835\udc56) ln \u0012 \ud835\udc43(\ud835\udc56) \ud835\udc44(\ud835\udc56) \u0013 (10) According to the analysis of 5.1, we assume that the output follows a normal distribution, denoted as \ud835\udc5d1 \u223cN (\ud835\udf071, \ud835\udf0e2 1) and the standard normal distribution is denoted as \ud835\udc5d2 \u223cN (0, 1). The distribution loss L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61used in this paper is as follows: L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61= \ud835\udc3e\ud835\udc3f(\ud835\udc5d1\u2225\ud835\udc5d2) = \u22121 2 \u00d7 [2 log\ud835\udf0e1 + 1 \u2212\ud835\udf0e2 1 \u2212\ud835\udf072 1] (11) In the above two loss functions, L\ud835\udc64ensures the correct decoding of watermark information, while L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61guarantees the initial distribution of latent variables, thereby ensuring the quality and semantic \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu consistency of the images. The encoder and decoder are jointly trained by minimizing the following loss function: L = \ud835\udf061L\ud835\udc64+ \ud835\udf062L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61 (12) \ud835\udf061 and \ud835\udf062 represent the proportion constant parameter. Therefore, the trained encoder is capable of embedding information into latent variables that approximately adhere to a standard normal distribution, while the decoder can be seen as the inverse process of the encoder to extract the watermark. 4.3 Decoder Fine-Tuning According to the analysis of 5.3, throughout the entire watermark embedding-extraction process, following factors contribute to decoding imprecision: (1) The diffusion inversion process approximates the differences between adjacent step latent variables; (2) Since the prompt is not available in the practical scenarios during the decoding stage, we utilize zero-text inversion; (3) Potential alterations and manipulations to the image occur through various image processing techniques. These factors contribute to inevitable deviations in the inferred initial latent variables. In essence, these processes result in a global shift of the initial latent variables in the semantic space of the images. The decoder can accurately extract most of the watermark information, but samples located at the edges of the watermark region exhibit significant inaccuracies. During the fine-tuning phase of the decoder, the objectives are to adapt to the shift occurring in the watermark region and accurately extract the watermark from the attacked samples. Specifically, we fix the encoder of the watermark model and diffusion model. To simulate the image processing procedures in real-world scenarios, the attack layer employs an image perturbation technique after generating various images with randomly prompted words. The perturbation layer includes randomly adding Gaussian noise, applying Gaussian blur, color jittering and image compression to the images. Adversarial training will enhance the robustness of watermark detectors against image processing. After inverting the images subjected to image processing, we obtain the modified initial latent variables. We fine-tune the decoder by computing the mean squared error between the decoded messages and the original watermark messages as the loss function. 4.4 Error correction mechanism The scheme clearly delineates the watermark region, but during watermark detection, the effects of inversion and image processing due to adversarial training on the decoder can lead to overlap in watermark detection areas. This results in bit errors for samples at the edges of the watermark region where overlap occurs during adversarial training. We have provided detailed reasons and explanations in the security analysis 5.4 and elucidated the reasons and necessity for employing error correction codes. Recursive Systematic Convolutional (RSC) Codes: RSC codes provide a systematic approach to encoding and decoding bitstreams, allowing for error correction of data and adaptive recovery of the original message from corrupted data. Concretely, Given an input bitstream m, the RSC encoder transforms it into another bitstream \ud835\udc5a+\ud835\udc501 +\ud835\udc502...\ud835\udc50\ud835\udc58. where each \ud835\udc50\ud835\udc56is a bitstream that has the same length as the bitstream \ud835\udc5aand the symbol + indicates the concatenation of bitstreams. A higher encoding ratio can withstand a greater proportion of errors but results in a lengthier encoded bitstream. When decoding, if the modified bit string \ud835\udc5a\u2032 +\ud835\udc501...\ud835\udc50\ud835\udc56is input to the RSC decoder and the error rate of the encoded stream is less than a certain threshold, the original information m can be recovered. We can utilize this property to make corrections to watermark encoding. Turbo Codes [3]: Turbo codes can tolerate more bit errors compared to other codes at the same bit rate. A typical Turbo code consists of two convolutional codes and an interleaver. The primary function of the interleaver is to shuffle the outputs of the two convolutional codes, increasing the independence of each code and thus enhancing error correction performance. During the decoding process, an iterative algorithm is utilized to estimate and rectify errors iteratively, thereby enhancing the error correction performance. In our experiments, we utilize Turbo codes as error correction codes to further enhance the stability of watermark extraction. The specific process involves the model owner assigning identity information to the model user, which is then encoded into identity information codes with redundancy using Turbo codes. These identity information codes undergo encoding by the encoder, denoising of latent variables, inversion of latent variables, extraction of watermark information and error correction of the extracted identity information redundancy codes to restore the initial identity information. The mechanism of error correction codes combines partial watermark regions into a unified part, correcting the initial latent variables located at the boundaries of watermark detection regions, thereby enhancing the robustness of watermark detection. 5 THEORETICAL ANALYSIS OF THE PROPOSED SCHEME 5.1 Unified Representations of Watermark Regions and Latent Variables Based on the initial requirements, we aim to establish a unified representation for watermark information and latent variable regions. For each watermark \ud835\udc4a, specific distributions of latent variables are distributed. These settings ensure that all images generated by the model can be attributed to the initial distribution of latent variables. Formally, We set both the diffusion model and the watermark model to share the same latent space. For specific parts of this latent space, we can sample and extract watermark features based on a probability function \ud835\udc43(\ud835\udc67). We assume a series of deterministic functions \ud835\udc53(\ud835\udc67;\ud835\udf03) parameterized by a vector \ud835\udf03in some space \u03a6, where \ud835\udc53: \ud835\udc4d\u00d7 \u03a6 \u2192X . When \ud835\udf03is fixed and \ud835\udc67\u223cN (1, 0), \ud835\udc53(\ud835\udc67;\ud835\udf03) can generate latent variables that conform to a standard Gaussian distribution. By adopting this approach, we can construct watermark distribution regions corresponding to specific watermark information. These regions coincide with the latent variables of the diffusion model, achieving a unified representation of both. Additionally, the distribution of the watermark conforms to a standard normal distribution. This embedding process solely alters the selection of initial latent variables, preserving semantic consistency and image quality. \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY We aim to optimize \ud835\udf03such that \ud835\udc43(\ud835\udc67) can be sampled \ud835\udc67from while ensuring it closely matches the watermark \ud835\udc4a. To formalize this concept mathematically, the objective of DiffuseTrace is to maximize the probability of each \ud835\udc4athroughout the entire watermark extraction process. This objective stems from the principle of maximum likelihood. If the decoder is capable of reconstructing the watermark from the latent variables, it is also likely to reconstruct watermark from similar samples and unlikely to reconstruct watermark from dissimilar ones. To illustrate the dependence of \ud835\udc43(\ud835\udc67) on\ud835\udc4a, we transform \ud835\udc53(\ud835\udc67,\ud835\udf03) into \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03). The probability density function can be formalized as follows: \ud835\udc43(\ud835\udc4a) = \u2211\ufe01 \ud835\udc67 \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03)\ud835\udc43(\ud835\udc67) (13) The output distribution conforms to a Gaussian distribution after watermark embedding. Therefore, \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03) satisfies the following distribution: \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03) = N (\ud835\udc4a|\ud835\udc53(\ud835\udc67;\ud835\udf03), \ud835\udf0e2\ud835\udc3c) (14) After embedding the watermark, the latent variables have a mean of \ud835\udc53(\ud835\udc67;\ud835\udf03) and a covariance equal to the identity matrix \ud835\udc3cmultiplied by the scalar \ud835\udf0ewhich is a hyperparameter. 5.2 The Implicit Allocation of Watermarks Essentially, we need to partition the standard normal distribution, with each partition capable of accurately reconstructing the original watermark. For a 48-bit watermark, dividing into over two hundred eighty-one trillion regions presents a challenge in manually determining the watermark encoding regions given the complexity of explicitly partitioning watermark regions under the standard normal distribution. This implicit partitioning problem is analogous to the challenges faced by variational autoencoders in fitting distributions to data. As outlined in the paper [11], any distribution in \ud835\udc51dimensions can be generated using a set of \ud835\udc51variables drawn from a normal distribution and mapped through a sufficiently complex function. For \ud835\udc43(\ud835\udc4a), within the partitioning of the watermark into over two hundred eighty-one trillion blocks, most sampled \ud835\udc67contribute minimally to \ud835\udc43(\ud835\udc4a), since \ud835\udc43(\ud835\udc4a|\ud835\udc67) is close to zero for most \ud835\udc67. The approximation of the prior distribution can be simplified by introducing the posterior distribution \ud835\udc5e(\ud835\udc67|\ud835\udc65). By computing the KL divergence between the posterior and prior distributions, we obtain: \ud835\udc37[\ud835\udc5e(\ud835\udc67|\ud835\udc64)||\ud835\udc5d(\ud835\udc67|\ud835\udc64)] = E\ud835\udc67\u223c\ud835\udc5e[(\ud835\udc67|\ud835\udc64) \u2212log\ud835\udc5d(\ud835\udc67|\ud835\udc64)] (15) The same to solving the variational evidence lower bound, we derive the watermark reconstruction evidence lower bound through Bayesian transformation: log\ud835\udc5d(\ud835\udc64) \u2265E\ud835\udc67\u223c\ud835\udc5e[log\ud835\udc5d(\ud835\udc64|\ud835\udc67)] \u2212\ud835\udc37[\ud835\udc5e(\ud835\udc67|\ud835\udc64)||\ud835\udc5d(\ud835\udc67)] (16) The first term in the equation represents maximizing the expected probability distribution of the watermark \ud835\udc64given the latent variable \ud835\udc67, i.e., the loss incurred by the watermark decoder in reconstructing the watermark. The second term is for the approximate posterior distribution of the latent space \ud835\udc67to closely resemble the prior distribution, i.e., the watermark information generated by the encoder and the standard normal distribution should be as similar as possible. 5.3 Offset of Watermark Detection Region As stated in Equation 7, diffusion inversion attributes the generated image to the initial latent variables. The assumption of diffusion inversion approximates \ud835\udc4b\ud835\udc61\u22121\u2212\ud835\udc4b\ud835\udc61to \ud835\udc4b\ud835\udc61+1\u2212\ud835\udc4b\ud835\udc61. While unconditional diffusion inversion can yield accurate results, excessive guidance scale in conditional diffusion amplifies the errors introduced by null-text diffusion inversion [23]. In fact, after extracting the semantic embeddings of the images, conducting a forward pass after each inversion and applying gradient descent can enhance the effectiveness of the inversion process. Let the current latent variable be \ud835\udc4d\ud835\udc61\ud835\udc56. \ud835\udc4d\ud835\udc61\ud835\udc56+1 is obtained after performing inversion on \ud835\udc4d\ud835\udc61\ud835\udc56. The process of solving \ud835\udc4d\ud835\udc61\ud835\udc56+1 under the guidance of extracting semantic embeddings can be mathematically expressed as follows: \u2207\ud835\udc9b\ud835\udc61\ud835\udc56+1 \u2225\ud835\udc9b\ud835\udc61\ud835\udc56\u2212\ud835\udc9b\u2032 \ud835\udc61\ud835\udc56\u22252 2 (17) Theoretically, refining the decoder by restoring the initial latent variables through the aforementioned approach would yield better results. However, considering the computational overhead of the gradient descent process, the approach adopted in the paper accepts the inaccuracy of diffusion inversion under zero text and defines this inaccuracy as the offset to the watermark detection region. The purpose of fine-tuning is to learn the offset vector as \ud835\udc5d. The watermark encoder trained with maximum likelihood exhibits the following properties, similar samples have more similar latent variables, while dissimilar samples have greater distances in the latent space. The distance between the similar latent variables obtained after inversion and the initial latent variables should be less than a certain threshold \ud835\udf16to guarantee the accuracy of detection. After the watermark region is segmented, the watermark detection area is offset due to diffusion inversion, the refinement target at this point transforms into: min \ud835\udf03 E(\ud835\udc65\ud835\udc56,\ud835\udc66\ud835\udc56)\u223cD [max \ud835\udc3f(\ud835\udf03,\ud835\udc56\ud835\udc5b\ud835\udc63(\ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5c(\ud835\udc65\ud835\udc56)) + \ud835\udc5d\ud835\udc56,\ud835\udc66\ud835\udc56)]. (18) \ud835\udc65\ud835\udc56denotes specific latent variables and \ud835\udc66\ud835\udc56denotes the watermark region \ud835\udc65\ud835\udc56belong. In the formula 19, \ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5crepresents the process of diffusion denoising 6, \ud835\udc56\ud835\udc5b\ud835\udc63represents the precise inversion process, and \ud835\udc5d\ud835\udc56denotes the offset of the watermark detection area caused by approximation 7. After fine-tuning the watermark decoder, it should satisfy \ud835\udc5d< \ud835\udf16to ensure detection accuracy. Taking into account that images may undergo various treatments including image blurring, Gaussian noise, color transformations, etc., such attacks can affect samples on the edges of the watermark region, leading to decreased detection accuracy. Essentially, this process does not alter the watermark\u2019s region, but it notably aids in repairing the evasion of edge samples. Adversarial training can appropriately expand the range of the watermark detection region for various attacks. Therefore, the refinement target can be further transformed into: min \ud835\udf03 E(\ud835\udc65\ud835\udc56,\ud835\udc66\ud835\udc56)\u223cD [max \ud835\udc3f(\ud835\udf03,\ud835\udc56\ud835\udc5b\ud835\udc63(\ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5c(\ud835\udc65\ud835\udc56) + \ud835\udeff) + \ud835\udc5d\ud835\udc56,\ud835\udc66\ud835\udc56)]. (19) The variable \ud835\udeffcan be expressed as the deviations caused by various attacks on the image, where images generated after such attacks are semantically similar but deviate from the original image in semantic space. Correcting this step further enhances the watermark decoder\u2019s detection accuracy for edge samples. \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 5.4 Security Analysis Based on the above analysis, DiffuseTrace divides the watermark region into multiple contiguous areas. Assuming the image undergoes image processing resulting in changes compared to the original image, this change is assumed to be \ud835\udf16\ud835\udc5dwithin the latent variable space. The initial latent variable corresponding to the original image is \ud835\udc4d0 \u2208X. As long as \ud835\udc4d\ud835\udc47+\ud835\udf16\ud835\udc5d\u2208X, the watermark verification is successful. For the initial latent variables close to the center of the watermark region, the distance from the latent variables to other watermark regions is \ud835\udc37\u226b\ud835\udf16\ud835\udc5d. In this case, watermark verification is straightforward. However, for samples at the edges of the watermark region, \ud835\udc4d\ud835\udc47+ \ud835\udf16\ud835\udc5d\u2209X. In the detection phase, we effectively expanded the detection area for each watermark, considering the outer radius \ud835\udc5fof each watermark region as part of the region itself. This process can be formalized as follows: \ud835\udc51\ud835\udc52\ud835\udc61\ud835\udc52\ud835\udc50\ud835\udc61(\ud835\udc67\ud835\udc47+ \ud835\udf16\ud835\udc5d) = \ud835\udc57\ud835\udc62\ud835\udc51\ud835\udc54\ud835\udc52(\ud835\udc670 + \ud835\udf16\ud835\udc5d\u2208(X + r)) (20) The size of \ud835\udc5fdepends on the magnitude of the perturbations in adversarial samples used during adversarial training. Expanding the partition of watermark regions actually increases the risk of overlap to some extent between different watermark regions. We set the distance \ud835\udc51between the two watermark regions. Since the encoder remains fixed, the region of the watermark itself won\u2019t change. However, due to inversion-induced overall shifts and image processing, the detection area post-inversion corresponds to a deviated initial region. If \ud835\udc5f\u2264\ud835\udc51, adversarial training enhances the robustness of the watermark, ensuring that even edge latent variables can still extract the watermark. Security Analysis Without Attack. If the magnitude of adversarial training \ud835\udc5fexceeds \ud835\udc51, it causes the watermark from one edge sample to fall within the detection range of another, leading to bit errors. Indeed, during training, adversarial samples at the boundary regions steer the model in the wrong direction, while correct samples in these regions guide the model back on track. As a result, the accuracy of samples in these areas remains above fifty percent but unstable, leading to a fluctuating state. To correct such errors, we employ error correction codes. As mentioned by 4.4, if the error rate of samples in the boundary region is within an acceptable range, error correction codes can restore the original information. Essentially, this approach uses a larger amount of information to rectify errors and merges multiple regions into one. Security Analysis of Image Processing. In our scheme, we consider image manipulation where the same image undergoes a certain offset in the latent space, but within an acceptable range smaller than a certain threshold. If the corresponding change in the latent space is less than \ud835\udc51, adversarial training ensures that both central and marginal latent variables can successfully decode the information. Common image manipulations such as Gaussian transformations, color jittering, brightness variations and image compression all keep the image\u2019s position in the latent space within an acceptable range. Therefore, DiffuseTrace effectively defends against such attacks. Even with significant image manipulations such as JPEG compression to 10 percent, contrast increase to 8, and brightness increase to 6, DiffuseTrace maintains a certain level of accuracy. Security Analysis of VAE-based Attacks and Diffusionbased Attacks. The core idea behind attacks such as VAE-based attacks and Diffusion-based attacks in the proposed scheme is to disrupt and reconstruct. Disruption involves adding noise to the image, while reconstruction involves removing the noise through a diffusion model. The reason why such attacks can succeed is that the primary objective of most watermarking schemes is to add minimal watermark noise to the image while still being able to extract the watermark information. These methods often utilize the LPIPS loss [47] or differences in the color channels of the image as the loss function, aiming to minimize the SSIM and PSNR metrics of the final image. This allows reconstruction attacks to exploit this vulnerability by continuously adding noise to gradually degrade the stability of the watermark. Eventually, the reconstruction process generates an image that is indistinguishable from the watermark. While some watermarking schemes, such as Stegastamp, sacrifice image quality and significantly increase adversarial training to enhance their stability, there is no defense against reconstruction attacks when constructive steps become sufficiently numerous. In fact, reconstruction attacks can even produce images that are clearer than the watermark samples. The watermark based on the initial latent variables primarily operates at the semantic level, allowing for stable watermark extraction as long as there are no significant changes in the image within the latent space. Attacks on watermarks based on diffusion models by adding noise do not alter the original semantic content of the image actually. The initial hidden space positions of the image can still be discerned which makes it resistant to such reconstruction attacks. This is exactly the advantage of DiffuseTrace in combating attacks. 6 EXPERIMENTS 6.1 Experimental settings Datasets. In the experiment, we utilized the following datasets: \u2022 Real Photos: 500 images were randomly selected from MSCOCO [18], which contains over 328K images along with their annotations. \u2022 AI-Generated Images Prompts: 500 prompts were randomly sampled from Diffusion Prompts, a database of approximately 80,000 prompts filtered and extracted from image finders. \u2022 AI-Generated Images: 500 images and prompts are randomly chosen from StableDiffusionDB [41]. This dataset contains images generated by Stable Diffusion based on prompts and hyperparameters provided by actual user interactions. Watermark Baselines. For traditional watermarking schemes, we selected DcTDwt [1] and DcTDwtSvD [8] which is deployed in Stable Diffusion as a watermark with an embedding capacity of 48. For post-processing watermarking schemes based on EncoderDecoder/GAN structures, we chose RivaGAN [44], Hidden [51] and StegaStamp [37] with embedding capacities of 32, 48, 48, and 48 respectively. For watermarking schemes based on Variational Autoencoders, we chose Stable Signature [13] and and SSLWatermark [14] with an embedding capacity of 48. Additionally, for watermarking schemes based on latent variables, we chose Tree-Ring with a watermark radius of 10. Given that tree-ring is a zero-bit watermark scheme, we utilized p-values as the detection metric. The \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Table 1: Bit Accuracy/Detection Accuracy Under Image Processing Method Brightness Noise Contrast Hue JPEG Blur Resize BM3D Value 2.0 0.05 2.0 0.25 50 7*7 0.3 30 Traditional Wm. DwtDct 0.601/0.000 0.801/0.642 0.497/0.000 0.479/0.000 0.488/0.000 0.582/0.092 0.493/0.000 0.498/0.000 D.Svd 0.612/0.042 0.850/0.999 0.718/0.118 0.485/0.000 0.498/0.000 0.989/0.999 0.506/0.000 0.632/0.084 Enc.-Dec. Wm. RivaGan 0.975/0.999 0.960/0.994 0.832/0.992 0.984/0.999 0.773/0.801 0.867/0.924 0.504/0.000 0.858/0.873 Hidden 0.964/0.999 0.971/0.994 0.979/0.999 0.992/0.999 0.849/0.823 0.816/0.852 0.825/0.873 0.626/0.168 S.Stamp 0.937/0.999 0.979/0.999 0.972/0.999 0.995/0.999 0.952/0.999 0.981/0.999 0.972/0.999 0.980/0.999 VAE-Based Wm. S.Signa 0.971/0.999 0.976/0.996 0.965/0.999 0.954/0.994 0.806/0.809 0.781/0.822 0.513/0.011 0.604/0.013 Latent-Based Wm. SSLWm. 0.927/0.999 0.627/0.124 0.975/0.999 0.942/0.997 0.547/0.000 0.997/0.999 0.844/0.901 0.620/0.224 Ours 0.942/0.999 0.915/0.999 0.959/0.999 0.982/0.999 0.912/0.999 0.966/0.999 0.922/0.999 0.902/0.999 Table 2: Image Sematic Quality and Undetectability Evaluation. The table demonstrates the impact of adding semantic watermarks on image quality through two No-inference Metrics, NIQE and PIQE. The semantic consistency before and after adding the DiffuseWatermark is evaluated through the Clip metric. Dataset Method NIQE\u2193PIQE\u2193Clip\u2191Bit/Detect DiffusionDB No-Watermark 4.91 28.21 0.342 0.511/0.000 Tree-ring(rad10) 5.32 30.28 0.332 -/0.999 Tree-ring(rad20) 6.64 37.33 0.301 -/0.999 DiffuseTrace(16) 4.22 29.08 0.344 0.999/0.999 DiffuseTrace(32) 5.04 29.77 0.339 0.992/0.999 DiffuseTrace(48) 4.72 28.41 0.340 0.984/0.999 MS-COCO Prompts No-Watermark 3.85 33.28 0.335 0.504/0.000 Tree-ring(rad10) 4.32 34.28 0.324 -/0.999 Tree-ring(rad20) 5.64 38.33 0.291 -/0.999 DiffuseTrace(16) 4.12 33.25 0.333 0.999/0.999 DiffuseTrace(32) 3.81 30.21 0.326 0.994/0.999 DiffuseTrace(48) 4.17 32.34 0.330 0.990/0.999 Diffusion Prompts No-Watermark 4.88 29.72 0.326 0.488/0.999 Tree-ring(rad10) 5.32 30.28 0.327 -/0.999 Tree-ring(rad20) 5.94 37.33 0.303 -/0.999 DiffuseTrace(16) 4.93 28.42 0.358 0.999/0.999 DiffuseTrace(32) 5.11 30.18 0.353 0.999/0.999 DiffuseTrace(48) 4.70 26.33 0.328 0.984/0.999 corresponding bit capacity of DiffuseTrace is 48 bits. Considering the additional overhead of redundancy codes, no error correction codes were used in the comparative experiments. Attack Baselines. To thoroughly evaluate the robustness of DiffuseTrace, we test it against a comprehensive set of baseline attacks that represent common image processing, VAE-based attack and diffusion-based attack. Specially, The set of attacks employed in our testing includes: \u2022 brightness and contrast change of 2.0 \u2022 addition of Gaussian noise with standard deviation of 0.05 \u2022 Adjustment of the hue by 0.25. \u2022 JPEG compression with a quality setting of 50. \u2022 BM3D denoising algorithm with Peak Signal-to-Noise Ratio Standard Deviation of 30. \u2022 Gaussian blur with kernel size 7 and standard deviation of 1 \u2022 Two Variational AutoEncoder (VAE) based image compression models, Bmshj18 [2] and Cheng20 [7], both with compression factors of 3. \u2022 A stable diffusion-based image regeneration model for watermark attack, Zhao23 [49] with 40 denoising steps. Evaluation Metrics. The two main objectives of incorporating watermarks are copyright protection and user tracing. Therefore, we utilize \ud835\udc5d\ud835\udc63\ud835\udc4e\ud835\udc59\ud835\udc62\ud835\udc52as the standard for copyright tracing and utilize bit accuracy rate as the standard for user tracing. We set a decision threshold to reject the null hypothesis for \ud835\udc5d< 0.01, requiring detection of the corresponding method-corrected 24/32 and 34/48 bits. Otherwise, the image is deemed to be without a watermark. Semantic consistency. Since our images have watermarks added before image generation, the watermark is reflected at the semantic level. Therefore, we choose the CLIP score metric [25] to evaluate the semantic consistency between generated images and prompt words. The reference metric will be used to evaluate the semantic quality difference between the generated images with and without watermark embedding in DiffuaeTrace in order to evaluate the fidelity of watermark embedding Image Quality. We evaluate the quality of an image through two no-reference metrics, the Natural Image Quality Evaluator (NIQE) score [22] and the Perceptual Image Quality Evaluator (PIQE) score [38] . The reference indicators will be used to compare the quality of images without watermarks with images with watermarks embedded in order to evaluate the loss of watermark embedding on the image and the invisibility of the watermark. 6.2 Sematic and image quality evaluation From Table 2, we evaluated the impact of embedding the watermark on image quality and semantic consistency before and after. The experiment utilized the stable-diffusion-2-1-base model [29] with 25 inference steps at the guidance scale of 5. Results indicate no significant differences in NIQE and PIQE quality metrics across different watermark bits. Additionally, semantic alignment of generated images, as assessed by Clip scores, remains similar to the original model. This suggests that DiffuseTrace does not rely on the trade-off between image quality and watermark robustness typical of post-processing watermarks. Since images are generated \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 0 1 2 3 4 5 6 Brightness Intesity 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Brightness Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0.0 0.1 0.2 0.3 0.4 Standard Deviation of Noise 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Noise Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 2 4 6 8 Contrast Intensity 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Contrast Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 20 40 60 80 100 Quality Rate 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR JPEG Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0.0 2.5 5.0 7.5 10.0 12.5 15.0 Kernel Size 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Blur Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 20 40 60 80 Resize Scale 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Resize Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 20 40 60 80 100 Denoising Strength 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR BM3D Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 2 4 6 8 Quality Rate 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR VAE-based Attack (Cheng 20) Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 25 50 75 100 125 150 Denoiset Steps 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Diffusion-based Attack (Zhao 23) Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp Figure 2: The figure illustrates the performance of DiffuseTrace in response to various attacks of different intensities, measured by bit accuracy and TPR@0.01FPR. It also compares TPR@0.01FPR of traditional watermarks such as DwtDctSvd, SSL Watermark and Stable Signaturez under corresponding attacks. The watermark capacity for each scheme in the figure is 48 bits. entirely through correct sampling processes and variables are properly distributed without subsequent modifications to the images, the DiffuseTrace approach exhibits significant advantages in terms of image quality compared to post-processing solutions. Compared to other methods that embed watermarks in the latent space, the SSL watermark remains a post-processing solution. Tree-ring alters the distribution of initial latent variables by embedding the watermark in the frequency domain of the latent space through Fourier transformation. However, U-net fails to recover from the losses incurred during this process. Consequently, as the watermark radius increases, the generated images suffer significant losses in both quality and semantic consistency. 6.3 Robustness evalution against image processing From Table 1, we evaluated the robustness of the watermark against various image processing attacks. It could be observed from the graph that DiffuseTrace demonstrates stability and roubustness when faced with common image processing attacks. DiffuseTrace achieve watermark detection rate close to 100 percent and average bit accuracy above 90 percent under common attack. Compared to post-processing watermarking schemes and VAE-based watermarking schemes, DiffuseTrace demonstrates excellent stability when faced with significant image compression and resizing. Stegastamp remain highly robust in the comparison, since it sacrifices image quality and utilizes error correction codes to compress 96 bits into 48 bits, with a relatively large error correction space. Stable Signature watermark specially for diffusion model remain stable under most attacks, but is vulnerable to denoise algorithm and processing to high extent. Furthermore, We conducted detailed experiments on various types of image disturbance amplitudes and compared the current method to latent-based method ssl watermark and vaebased watermark stable signature under maximum attack intensity. The results showed that DiffuseTrace has a significant advantage in image processing stability compared to other methods. 6.4 Robustness evaluation against VAE-based attacks and diffusion based attacks. In Table 3, we evaluated the accuracy of various watermarking schemes when faced with deep learning-based attacks. The experiments consist of VAE-based attack and diffision-based attack which is the latest watermark attack. The table reveals that the majority of \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY schemes are unable to withstand this type of reconstruction attack. Stable Signature exhibits fragile From the results, it is evident that DiffuseTrace exhibits a significant advantage in countering VAEbased attacks utilizing diffusion models. SSL watermarks and stable signatures all exhibit low watermark detection rates, indicating that they are unable to resist both VAE-based and diffusion based attacks. For diffusion based attacks, except for DiffuseTrace, other watermark schemes have experienced a significant drop in bit accuracy. In subsequent experiments, we increased the intensity of the diffusion attack. From the results, it is evident that DiffuseTrace exhibits significantly higher resilience against reconstruction attacks compared to other methods. Even the VAE-attack with a quality coefficient of 1 or the diffusion-based attack with 150 denoise steps do not fundamentally affect the stability of the watermark and only the DiffuseTrace was able to maintain accuracy in high-intensity reconstruction. Reconstruction attacks are achieved by maintaining semantic accuracy, continuously adding noise to destroy watermarks and continuously reconstructing and restoring images to obtain images without watermarks. However, this process essentially does not alter the semantic consistency of the image nor does it significantly alter the initial latent variables of image inversion. Therefore, DiffuseTrace can remain stable under reconstruction attacks. Table 3: Bit Accuracy/Detection Accuracy Under Deeplearning-based Attack Method VAE A. Diffusion A. Bmshj18 [2] Cheng20 [7] Zhao23 [49] Traditional Wm. DwtDct 0.524/0.000 0.517/0.012 0.489/0.000 D.Svd 0.504/0.000 0.512/0.013 0.523/0.014 Enc.-Dec. Wm. RivaGan 0.611/0.063 0.632/0.070 0.588/0.070 Hidden 0.621/0.170 0.641/0.198 0.497/0.009 S.Stamp 0.979/1.000 0.965/1.000 0.852/0.927 VAE-based Wm. Stable Signature 0.616/0.224 0.682/0.409 0.541/0.014 Latent-based Wm. SSL Wm. 0.623/0.123 0.631/0.144 0.655/0.149 Tree-ring /0.993 /0.991 /0.997 Ours 0.972/1.000 0.967/1.000 0.970/1.000 6.5 Ablation Experiments This section, we experimentally quantify the impact of several key hyperparameters mentioned in the theoretical analysis 5 on the inaccuracy. we consider the impact of the guidance scale used during the generation phase, the inference steps employed during the inversion phase, and the version of the model on watermark detection in order to demonstrate the effectiveness of DiffuseTrace. Ablation on Guidance Scale. In the theoretical analysis 5.3, we elaborate on the reasons why the guidance scale introduces errors into the experiments. In the following experiments, we quantify the impact of the guidance scale on the DiffuseTrace watermarking scheme through experimentation. For the ablation experiment on the guidance scale, the scheduler is set the dpm++ [20] scheduler. The experimental setup includes setting both the inference steps and reverse inference steps to 20. We adjust the guidance scale to assess its influence on the experimental results. The specific experimental results depicted in the graph 3 show that as the guidance scale increases during the inference stage, the bit accuracy gradually decreases, while the detection accuracy remains relatively stable within the guidance scale range of 0 to 20. This indicates that the watermark detection accuracy is maintained, demonstrating the robustness of the watermark. Thus, users can freely adjust the guidance scale during the image generation stage while still ensuring traceability of the watermark. Deploying the diffusion model as a service can provide users with the option to adjust the guidance scale hyperparameter, which will not significantly affect watermark detection. Ablation on Inference Steps. The ablation experiment for reverse inference steps employed the DPM++ scheduler, with an inference step setting of 20 and a guidance scale set to 5. The evaluation of the experiment\u2019s results involves adjusting the reverse inference steps to assess their impact. The experimental results, as depicted in the figure 3, indicate that after 5 inference steps of inversion, the watermark detection rate stabilizes. Even with only 2 inference steps, a good detection rate can still be maintained. This suggests that the number of inference steps does not significantly affect the accuracy of detection. Therefore, during the detection phase, to increase efficiency, a small number of reverse inference steps can be employed to extract the image watermark. 7 RELATED WORK 7.1 Detection of AI-Generated Images It is difficult for humans to distinguish between real and fake images. Realistic fake images intensify concerns about the disinformation dissemination. To tackle this problem, various fake image detection approaches have been proposed. A typical approach [15, 36, 39] involves extracting temporal, frequency, and texture features from images. Subsequently, a feature extraction network is constructed to train a binary classifier to distinguish between AI-generated images and real images. However, this image detection method exhibits noticeable performance degradation when applied to diffusion models. For AI-generated image detection based on diffusion models [40], leveraging a pre-trained diffusion model allows for a more accurate reconstruction of the characteristics of images generated through the diffusion process. By reconstructing the diffusion process, differences between real images and images generated by the diffusion model can be detected thereby enabling the detection of AI-generated images. Adding a watermark to generated images is also a method for identifying AI-generated images. 7.2 Image Watermarking The strategy of adding watermarks to images for protecting intellectual property rights has a long history in the field of computer vision. Traditional image watermarking methods typically involve embedding watermarks into appropriate frequency components of the image, utilizing techniques such as Discrete Cosine Transform (DCT), Discrete Wavelet Transform (DWT) [1] or Singular Value Decomposition (SVD) [19]. Deep learning-based approaches, such as HiDDeN [51] , StegaStamp [37], have demonstrated competitive results in terms of robustness against various geometric \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 0 5 10 15 20 Guidance Scale 0.0 0.2 0.4 0.6 0.8 1.0 Bit accuracy/TPR@1%FPR Ablation on Guidance Scales Stable-diffusion-v1-4 Stable-diffusion-2-1-base TPR@1%FPR Bit accuracy 5 10 15 20 25 30 Reverse Inference Steps 0.0 0.2 0.4 0.6 0.8 1.0 Bit accuracy/TPR@1%FPR Ablation on Reverse Inference Steps Stable-diffusion-v1-4 Stable-diffusion-2-1-base TPR@1%FPR Bit accuracy Figure 3: The figure (left) illustrates the ablation experiment concerning the guidance scale, where adjusting the guidance scale leads to a gradual decrease in the watermark\u2019s bit accuracy, while the watermark detection rate remains stable. The figure (right) shows the results of the ablation study on reverse inference steps, where the bit rate detected stabilizes after two inference steps. transformations. These methods often employ deep learning encoders and extractors to embed and extract watermarks respectively. the aforementioned watermarking methods primarily focus on postprocessing existing images. The core idea is to achieve robustness against various attacks while minimizing the impact on the visual quality of the image. Therefore, post-processing methods are confronted with a trade-off between watermark stability, watermark capacity and image quality. For diffusion model watermarking, it can mainly be categorized into three types: Watermark embedding during training phase. In methods incorporating watermarks during the training phase, watermarks are embedded into the training data. The data is encoded with the watermark during training and a decoder is trained to extract the watermark. During the detection phase, all images generated by diffusion models will carry encoded binary strings. Watermark [50] is a representative approach. Methods of this kind typically have stringent requirements for watermark embedding, involving the incorporation of watermarks into a substantial dataset of images followed by training the entire model. Fine-tuning phase with watermark incorporation. The main purpose of such watermark embedding methods is to integrate the watermark component into the model component, making it inseparable during distribution. Watermarks are incorporated into model components during fine-tuning. For instance, methods like Stable Signature [13] and FSwatermark [43] fine-tune the variational autoencoders to ensure that all generated images carry the watermark. It\u2019s approximate to integrating the watermark into the final generation stage. Watermark embedding into latent space during inference. During inference steps, watermarks are added to the latent variable space of the model. Methods like Tree-ring [42] and ZoDiac [45] achieve this by diffusing inversion and applying frequency domain transformations to latent variables, ensuring that all generated images carry the watermark. DiffuseTrace also falls into this category of methods. The watermark is embedded in the image prior to its generation. 7.3 Image Watermarking Attack The goal of image watermark attacks is to assess the robustness of image detection after practical modifications. These attacks mainly fall into two categories: image processing attacks and deep learningbased attacks. image processing attacks. Common image processing techniques include adding noise, color jitter, image compression, image scaling and Gaussian blur. Image processing or compression methods may utilize frequency-domain or 3D transformation-based approaches including BM3D denoising algorithm [9]. Deep learning-based attack. Deep learning-based attack methods, including methods based on variational autoencoders such as [2] and [7] can disrupt watermarks embedded in images. In recent research, diffusion based attacks [49] are used to encode the semantic features of images, add noise to disrupt watermark and regenerate images. Reconstruction models exhibit prominent performance and can eliminate most watermarks injected by most existing methods. 8", + "additional_graph_info": { + "graph": [ + [ + "Liangqi Lei", + "Liehuang Zhu" + ] + ], + "node_feat": { + "Liangqi Lei": [ + { + "url": "http://arxiv.org/abs/2405.02696v1", + "title": "DiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model", + "abstract": "Latent Diffusion Models (LDMs) enable a wide range of applications but raise\nethical concerns regarding illegal utilization.Adding watermarks to generative\nmodel outputs is a vital technique employed for copyright tracking and\nmitigating potential risks associated with AI-generated content. However,\npost-hoc watermarking techniques are susceptible to evasion. Existing\nwatermarking methods for LDMs can only embed fixed messages. Watermark message\nalteration requires model retraining. The stability of the watermark is\ninfluenced by model updates and iterations. Furthermore, the current\nreconstruction-based watermark removal techniques utilizing variational\nautoencoders (VAE) and diffusion models have the capability to remove a\nsignificant portion of watermarks. Therefore, we propose a novel technique\ncalled DiffuseTrace. The goal is to embed invisible watermarks in all generated\nimages for future detection semantically. The method establishes a unified\nrepresentation of the initial latent variables and the watermark information\nthrough training an encoder-decoder model. The watermark information is\nembedded into the initial latent variables through the encoder and integrated\ninto the sampling process. The watermark information is extracted by reversing\nthe diffusion process and utilizing the decoder. DiffuseTrace does not rely on\nfine-tuning of the diffusion model components. The watermark is embedded into\nthe image space semantically without compromising image quality. The\nencoder-decoder can be utilized as a plug-in in arbitrary diffusion models. We\nvalidate through experiments the effectiveness and flexibility of DiffuseTrace.\nDiffuseTrace holds an unprecedented advantage in combating the latest attacks\nbased on variational autoencoders and Diffusion Models.", + "authors": "Liangqi Lei, Keke Gai, Jing Yu, Liehuang Zhu", + "published": "2024-05-04", + "updated": "2024-05-04", + "primary_cat": "cs.CR", + "cats": [ + "cs.CR", + "cs.AI" + ], + "main_content": "INTRODUCTION The strides made in latent diffusion models [10, 17, 28, 35] have substantially elevated the capacity for synthesizing photorealistic content in image generation and profoundly impact text-to-image [32, 46], image editing [5, 24], in-painting [21, 31], super-resolution [12, 33], content creation [26, 27] and video synthesis [4, 16]. Relevant commercial applications are becoming mainstream creative tools for designers, artists, and the general public. However, contemporary text-to-image generation models, such as Stable Diffusion and Midjourney, can generate a multitude of novel images as well as convincing depictions of fabricated events for malicious purposes. Criminals might utilize LDMs to produce insulting or offensive images, which shall be disseminated to spread rumors and pose a substantial threat to societal security. The hazards of deepfakes, impersonation and copyright infringement are also prevalent issues associated with current generative models. The potential illicit use of text-to-image models has spurred research for embedding watermarks in model outputs. Watermarked images contain signals imperceptible to humans but are marked as machine-generated. Copyright information of the model and the identity information of the model users will be embedded into images. Extracting watermarks from AI-generated images enables the detection of model copyrights and tracing unauthorized users. False and harmful images can be promptly identified and removed from platforms and unauthorized users of the model can be traced through the extraction of image information, which mitigates the potential harm caused by AI-generated content. Existing research on image watermarking tended towards postprocessing solutions. The core concept involves embedding the watermark into the image with minimal adjustments, emphasizing subtlety and intricacy. For instance, the watermark implemented arXiv:2405.02696v1 [cs.CR] 4 May 2024 \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu in Stable Diffusion [8] operates by altering a particular Fourier frequency within the generated image. This type of watermark faces a key trade-off between watermark robustness and image quality. For diffusion model watermarks, Some researchers have proposed embedding fixed messages into generated images by fine-tuning diffusion models like U-Net [30] or variational autoencoders. However, this approach only allows embedding fixed information into the generated images, requiring re-finetuning of the diffusion model when the embedding information needs to be changed. Moreover, if the model owner distributes the diffusion model to a large number of users, each distributed model must be fine-tuned separately, resulting in significant consumption of computational resources and time. Additionally, when the model requires iterative updates, the stability of the watermark becomes unreliable due to adjustments in model parameters. Recent studies [48] have demonstrated that methods involving the random addition of noise to images to disrupt watermarks, followed by image reconstruction using diffusion models, can effectively remove a significant portion of post-processing watermarking schemes. This poses new challenges to the robustness of watermarking. To address the aforementioned challenges and achieve high extraction accuracy, robustness and image quality, we propose a new watermarking scheme called DiffuseTrace. DiffuseTrace differs fundamentally from previous watermarking methods. DiffuseTrace embeds the watermark into the latent variables of the model, subtly influencing the sampling phase of the model. The watermark is embedded at the semantic level prior to image generation, without any post-processing of the generated images. We specialize in a watermarking scheme that can be seamlessly integrated into a wide range of latent diffusion models. DiffuseTrace can serve as a plug-and-play solution across various diffusion models. Taking practical application scenarios into account, we categorize the roles involved in model usage into two types: model producers and model users. Model producers train and possess all pre-trained models, including diffusion models, watermark encoders, watermark decoders. Model producers assign specific binary identity information to each user. By providing APIs, model producers offer generative model services to users. When malicious images resembling model-generated content or images suspected of copyright infringement appear on art platforms, news outlets or other sharing platforms, model producers can trace illegal usage or infringement-involved users by extracting watermark information from the generated images. For watermark modules, we control the distribution of the watermark through an encoder and dynamically allocate a watermark close to the standard normal distribution for each user. Since the data distribution and sampling process remain consistent with the original model, the generated images can achieve transparent watermark embedding with semantic consistency. Human inspection cannot distinguish watermark samples from random samples. Through transforming images into latent variables and inversely diffusing them to obtain the initial latent variables, the watermark can be decoded through a decoder. Considering the diverse processing stages in the flow of image data as well as the potential bias introduced by the inverse diffusion of the diffusion model, we employ adversarial training and fine-tuned the watermark decoder to enhance the robustness of watermark extraction. The primary contributions of this work are outlined as follows: (1) Among diffusion watermarking schemes based on initial hidden variables, DiffuseTrace is the first scheme that embeds robust multi-bit watermarks. DiffuseTrace is embedded at the semantic level of diffusion-model-generated images without relying on the trade-off between image quality and watermark robustness. It exhibits evident advantages over post-processing methods in terms of image quality. (2) Compared to the state-of-the-art post-processing watermarking and diffusion model watermarking schemes, DiffuseTrace not only exhibits significant performance in common image processing but also shows remarkable robustness against attacks based on variational autoencoders and diffusion models. The paper provides a thorough analysis at the theoretical level regarding the superior watermark robustness of DiffuseTrace. (3) The proposed universal watermark module for latent diffusion models can be seamlessly integrated across different versions of diffusion models. The watermark message of DiffuseTrace can be flexibly modified without being affected by model fine-tuning or model update iterations. Our code is open source: https://anonymous.4open.science/r/DiffuseTrace6DED. Paper Organization. The overview of this paper is organized as follows: The basic introduction of DiffuseTrace is shown in Section 1. The background of DiffuseTrace are summarized in Section 2. In Section 3, we introduce the problem formulation for DiffuseTrace. In Section 4, we demonstrate DiffuseTrace in detail. In Section 5, We have provided a detailed theoretical exposition and security analysis of the proposed scheme. In Section 6, we summarize and analyze the experimental results. In Section 7, we present the realted work of watermarking for LDMs. In Section 8, we summarize the DiffuseTrace watermarking scheme. 2 BACKGROUND 2.1 Diffusion Model based Image Generation Diffusion models progressively transitions the sample x from the true data distribution \ud835\udc5d(\ud835\udc65) to stochastic noise and adeptly reverses this process through iterative denoising of the noisy data [17]. A typical diffusion model framework involves a forward process that progressively diffuses the data distribution \ud835\udc5d(\ud835\udc65,\ud835\udc50) towards the noise distribution \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61,\ud835\udc50) for \ud835\udc61\u2208(0,\ud835\udc47], where c denotes the conditional context. The conditional gaussian distribution of the diffusion process can be formulated as: \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61|\ud835\udc65) = \ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61|\ud835\udefc\ud835\udc61\ud835\udc65, \ud835\udf0e2 \ud835\udc61\ud835\udc3c), (1) where \ud835\udefc\ud835\udc61, \ud835\udf0e\ud835\udc61\u2208R+. \ud835\udefc\ud835\udc61and \ud835\udf0e\ud835\udc61are the strengths of signal and noise respectively decided by a noise scheduler. \ud835\udc67\ud835\udc61= \ud835\udefc\ud835\udc61\ud835\udc65+ \ud835\udf0e\ud835\udc61\ud835\udf16is the noisy data. It has been proved that there exists a denoising process with the same marginal distribution as the forward process [35]. The estimation of the only variable can be derived as: \u25bd\ud835\udc67\ud835\udc61log\ud835\udc5d\ud835\udc61(\ud835\udc67\ud835\udc61,\ud835\udc50) \u2248 \ud835\udefc\ud835\udc61\ud835\udc65\ud835\udc61 \ud835\udf03(\ud835\udc67\ud835\udc61,\ud835\udc50) \u2212\ud835\udc67\ud835\udc61 \ud835\udf0e2 \ud835\udc61 . (2) Specifically, given a noise-predicting diffusion model parameterized by \ud835\udf03, which is typically structured as a U-Net [30], training can be \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY T T M Step1: DiffuseTrace Enc./Dec. Pretraining M\u2019 Step2: DiffuseTrace Decoder Finetuning \u201c a cute cat \u201d Step3: Sematic Watermarked Image Generation Initial Latents Distribute Sample Watermark Region M Sample Distribute Initial Latents Attack ... Iterative Denoising \ufffd0 VAE Reconstruct T Locate M\u2019 Watermark Region W Sample Distribute Initial Latents \u201c a cute cat \u201d Diffusion Model Step4: Watermark Message Extraction Diffusion Inversion Reconstruct Locate Watermark Region W Diffusion Model DiffuseTrace Enc./Dec. U-Net of Diffusion Model Variational Autoencoder VAE Rec. Loss Distri. Loss Figure 1: Methods of DiffuseTrace. (Step1) Train the DiffuseTrace Encoder through resampling methods to generate latent variables approximate to a standard normal distribution and jointly train the decoder to decode the information. M: Random n-bit messages. (Step2) Keep the encoder fixed and train the decoder. Randomly select prompts for the diffusion model denoising process to generate images. Decode the images after passing through the attack layer to obtain latent variables and execute diffusion inversion to extract the initial latent variables. Compare the decoded message from the initial latent variables with the initial message to build a reconstruction loss for fine-tuning the decoder. (Step3) Assign watermark message w and generate initial watermarked latent variables by the encoder to generate images. (Step4) Extract watermark message after inverting the images and trace the source through statistical testing. formulated as the following noise prediction problem: \ud835\udc5a\ud835\udc56\ud835\udc5b \ud835\udf03 E\ud835\udc65,\ud835\udc61,\ud835\udf0e|| \u02c6 \ud835\udf16\ud835\udf03(\ud835\udefc\ud835\udc61\ud835\udc65+ \ud835\udf0e\ud835\udc61\ud835\udf16,\ud835\udc61) \u2212\ud835\udf16||2 2, (3) where \ud835\udc61refers to the time step; \ud835\udf16is the ground-truth noise; the noise \ud835\udf16\u223cN (\ud835\udf16|0, \ud835\udc3c) is a standard Gaussian. Recently, LDMs [28] streamlines inference processes by incorporating denoising process within the encoded latent space derived from a pre-trained variational autoencoder (VAE) [6]. Diffusion models reconstructs images through the latent state. During the inference phase, stable diffusion models take both a latent seed and a text prompt as an input. The U-Net progressively removes noise from random latent image representations guided by text embeddings. The noise residual from the U-Net is utilized in conjunction with a scheduler algorithm to generate a denoised latent. When synthesizing images, a crucial technique, classifierfree guidance is adopted to enhance the quality of generated images. \u02dc \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udc50) = \ud835\udc64\u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udc50) + (\ud835\udc64\u22121) \u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udf19) (4) where The guidance scale \ud835\udc64can be modified to regulate the influence of conditional information on the produced images, aiming to strike a balance between quality and diversity. \u02c6 \ud835\udf16\ud835\udc61\u210e\ud835\udc52\ud835\udc61\ud835\udc4e(\ud835\udc61,\ud835\udc67\ud835\udc61,\ud835\udf19) denotes the unconditional diffusion obtained by empty prompt. 2.2 Diffusion Denoising and Inversion The well-trained diffusion model leverages a diverse range of samplers to generate samples from noise and execute denoising procedures. A notable denoising method is the Denoising Diffusion Implicit Model (DDIM) [34] which stands out for its efficiency and deterministic output. DDIM accomplishes denoising with significantly fewer steps. The image \ud835\udc650 will be reproduced with 50 inference steps to the standard 1000-step process. Formally, for each denoising step \ud835\udc61, DDIM utilizes a learned noise predictor \ud835\udf16\ud835\udf03to estimate the noise \ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) added to \ud835\udc650, which leads to the estimation of \ud835\udc650 as follows: \u02c6 \ud835\udc650 = \ud835\udc65\ud835\udc61\u2212\u221a1 \u2212\u00af \ud835\udefc\ud835\udc61\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) \u221a\u00af \ud835\udefc\ud835\udc61 . (5) the estimated noise \ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) is recombined with the approximated \u02c6 \ud835\udc650 to compute \ud835\udc65\ud835\udc61\u22121: \ud835\udc65\ud835\udc61\u22121 = \u221a\u00af \ud835\udefc\ud835\udc61\u22121 \u02c6 \ud835\udc650 + \u221a1 \u2212\u00af \ud835\udefc\ud835\udc61\u22121\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) . (6) DDIM also incorporates an inversion mechanism [10], which facilitates the reconstruction of the noise representation \ud835\udc65\ud835\udc47from an image \ud835\udc650. The recovered \ud835\udc65\ud835\udc47should be mappable to an image approximate to \ud835\udc650. Based on the assumption that \ud835\udc65\ud835\udc61\u22121 \u2212\ud835\udc65\ud835\udc61\u2248\ud835\udc65\ud835\udc61+1 \u2212\ud835\udc65\ud835\udc61, The DDIM inversion shall be formulated as: \u02c6 \ud835\udc65\ud835\udc61+1 = \u221a\u00af \ud835\udefc\ud835\udc61+1\ud835\udc650 + \u221a1 \u2212\u00af \ud835\udefc\ud835\udc61+1\ud835\udf16\ud835\udf03(\ud835\udc65\ud835\udc61) (7) Essentially, this process follows the forward diffusion process as described in Equation 6. Diffusion inversion, even in zero-text inversion within conditional diffusion, can still achieve decent accuracy. Meanwhile, the method is applicable to deterministic sampling methods like DPM++ [20]. Our watermarking scheme leverages this property of diffusion inversion. \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 3 PROBLEM FORMULATION 3.1 Threat Model In this paper, we consider two parties: the defender and the adversary. The defender is the owner of the generative model. Latent diffusion model is deployed as an online service. The core objectives are protecting the copyright of the model and tracing the illegal usage through model outputs. Conversely, the adversary\u2019s objective is to disrupt the watermark information in the model output and circumvent the copyright protection and tracing mechanisms of the model. Adversary\u2019s Motivation. The adversary\u2019s motivation stems from two aspects: Firstly, training a latent diffusion model requires gathering a significant amount of data, expertise in architecture or algorithms and numerous failed experiments, all of which are expensive. As a result, the model parameters are considered proprietary information for businesses. Generative model services are deployed as online services. Adversaries may manipulate images to destroy watermark information and redistribute the outputs of online services to cloud platforms, effectively becoming commercial competitors. Secondly, Attackers may exploit online generative services to generate insulting or offensive images for malicious purposes such as fabricating fake news or spreading rumors and remove watermarks from the images to evade tracing. Adversary\u2019s Background Knowledge. We assume that adversaries can access the victim\u2019s latent diffusion model in a black-box manner. Attackers can query the victim\u2019s latent diffusion model with data samples and obtain corresponding responses. Specifically, we categorize adversary background knowledge into two dimensions: the architecture of the victim\u2019s diffusion model and the watermark removal capability. For the architecture of the diffusion model, we assume adversaries can access it since such information is typically publicly accessible. Regarding watermark removal capability, we assume adversaries can manipulate images using techniques such as Gaussian blur, color jittering and image compression. Meanwhile, we consider adversaries who possess the capability to perform state-of-the-art watermark removal attacks using variational autoencoders and diffusion models. 3.2 Image Watermarking and Verification Formally, the validation scheme for generative image watermarking in Diffusers is defined as follows: The generative image watermarking verification scheme is a tuple Verification = \u27e8\ud835\udc47\ud835\udc5f\ud835\udc5b, \ud835\udc38\ud835\udc5a\ud835\udc4f, \ud835\udc38\ud835\udc63\ud835\udc4e,\ud835\udc49\ud835\udc5f\ud835\udc53\u27e9of processes: A Train process \ud835\udc47\ud835\udc5f\ud835\udc5b(\ud835\udc37,\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7], \ud835\udc3f) = {\ud835\udc38\ud835\udc5b\ud835\udc50[\ud835\udc4a], \ud835\udc37\ud835\udc52\ud835\udc50[\ud835\udc4a]}, is a fine-tuning or training process that takes training data \ud835\udc37= {\ud835\udc65\ud835\udc51,\ud835\udc66\ud835\udc51} as inputs and outputs the models \ud835\udc38\ud835\udc5b\ud835\udc50[\ud835\udc4a] and \ud835\udc37\ud835\udc52\ud835\udc50[\ud835\udc4a] by minimizeing a given loss L. An embedding process \ud835\udc38\ud835\udc5a\ud835\udc4f(\ud835\udc5d\ud835\udc5f\ud835\udc5a,\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7], \ud835\udc3f\ud835\udc4e\ud835\udc61,\ud835\udc46\ud835\udc56\ud835\udc54) = \ud835\udc43\ud835\udc56\ud835\udc50 [\ud835\udc46\ud835\udc56\ud835\udc54] is an inference process that embeds the signature \ud835\udc46\ud835\udc56\ud835\udc54into latent variables through an encoder and performs inference through the model \ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7] to output the watermarked image \ud835\udc43\ud835\udc56\ud835\udc50[\ud835\udc46\ud835\udc56\ud835\udc54]. An quality evaluation process \ud835\udc38\ud835\udc63\ud835\udc4e\ud835\udc59(\ud835\udc34\ud835\udc5f\ud835\udc50[\u00b7], \ud835\udc40, \ud835\udc3f\ud835\udc4e\ud835\udc61,\ud835\udf16) = {\ud835\udc47\ud835\udc5f\ud835\udc62\ud835\udc52, \ud835\udc39\ud835\udc4e\ud835\udc59\ud835\udc60\ud835\udc52} is to evaluate whether or not the discrepency is less than a predefined threshold i.e. |\ud835\udc40(\ud835\udc34\ud835\udc5f\ud835\udc50[\ud835\udc4a,\ud835\udc46\ud835\udc56\ud835\udc54], \ud835\udc3f\ud835\udc4e\ud835\udc61, \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7]) \u2212\ud835\udc40| \u2264\ud835\udf16, where \ud835\udc40(\ud835\udc34\ud835\udc5f\ud835\udc50[\ud835\udc4a,\ud835\udc46\ud835\udc56\ud835\udc54], \ud835\udc3f\ud835\udc4e\ud835\udc61, \ud835\udc38\ud835\udc5b\ud835\udc50[\u00b7]) denotes the image fidelity or semantic consistency tested against a set of watermarked latents. \ud835\udc40is the target generation performance. A verification process \ud835\udc38\ud835\udc63\ud835\udc4e(\ud835\udc3c\ud835\udc5a\ud835\udc54, \ud835\udc46\ud835\udc56\ud835\udc54, \ud835\udc34\ud835\udc61\ud835\udc58, \ud835\udc37\ud835\udc52\ud835\udc50[\u00b7],\ud835\udf16) = {\ud835\udc47\ud835\udc5f\ud835\udc62\ud835\udc52, \ud835\udc39\ud835\udc4e\ud835\udc59\ud835\udc60\ud835\udc52} checks whether the expected signature \ud835\udc46\ud835\udc56\ud835\udc54of a given generative image can be successfully verified by Decoder \ud835\udc37\ud835\udc52\ud835\udc50[\u00b7] when facing image attacks. Watermark Detaction. DiffuseTrace embed a k-bit secret message \ud835\udc5a\u2208{0, 1}\ud835\udc58into the watermark image. The watermark detection algorithm includes an extractor that can extract the hidden signal \ud835\udc5a\u2032 from the watermarked image. It uses statistical testing to set a threshold \ud835\udf0f\u2208{0, 1, 2...\ud835\udc58} for the extracted bits . If the number of matching bits \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) \u2265\ud835\udf0f, the image is marked as watermarked. Formally, We establish the hypothesis H1: The image pic is generated by DiffuseTrace against the null hypothesis H0: The image is not generated by DiffuseTrace. Under \ud835\udc3b0, we assume that the extracted bits \ud835\udc5a\u2032 1,\ud835\udc5a\u2032 2...\ud835\udc5a\u2032 \ud835\udc58are independent and identically distributed Bernoulli random variables with a probability of 0.5. \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) follows a binomial distribution \ud835\udc35(\ud835\udc58, 0.5). Type I error (false positive rate (FPR) , \ud835\udf0e) equals the probability of \ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) exceeding \ud835\udf0f, derived from the binomial cumulative distribution function. It has a closed form using the regularized incomplete beta function \ud835\udc3c\ud835\udc65(\ud835\udc4e;\ud835\udc4f). \ud835\udf161(\ud835\udf0f) = P(\ud835\udc38(\ud835\udc5a,\ud835\udc5a\u2032) > \ud835\udf0f| \ud835\udc3b0) = 1 2\ud835\udc58 \ud835\udc58 \u2211\ufe01 \ud835\udc56=\ud835\udf0f+1 ( \ud835\udc58 \ud835\udc56 ) = \ud835\udc3c1/2(\ud835\udf0f+ 1,\ud835\udc58\u2212\ud835\udf0f). (8) If we reject the null hypothesis \ud835\udc3b0 with a p-value less than 0.01, we consider the image to be without a watermark. In practice, for a watermark of 48 bits (\ud835\udc58= 48), at least 34 bits should be extracted to confirm the presence of the watermark. This provides a reasonable balance between detecting genuine watermarks and avoiding false positives. 3.3 Objective for Watermarking DiffuseTrace should have the following propeties: Robust against Watermarking Attacking: Images with watermarks may undergo various image processing operations. Even after post-processing, the watermark can still be fully recovered. DiffuseTrace should withstand watermark removal attacks, such as Gaussian noise, color jittering, Gaussian blur and others. Meanwhile, DiffuseTrace should be able to defend against the latest watermark attacks based on the state-of-the-art variational autoencoder and diffusion model techniques. Generalizability: Considering the cost of embedding fixed information into fine-tuned models, DiffuseTrace can adjust embedded message flexibly and should be compatible with various versions of diffusion models and remain unaffected by model fine-tuning or model update iterations. Fidelity: Minimizing the impact on the model\u2019s output before and after watermarking to the greatest extent possible. The images generated by the DiffuseTrace maintain consistency with the original model in terms of semantic consistency and image quality. The watermark samples generated by DiffuseTrace should exhibit no significant differences in visual and semantic quality compared to normal samples. \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY The goal is to design a watermark that is flexible, robust to postprocessing, generalizable and does not compromise the quality or semantic consistency of the image. Additionally, it should remain unaffected by model fine-tuning or update iterations. 4 PROPOSED WATERMARKING SCHEME 4.1 Overview The overview of our method is in figure 1. As described in the first section, we have three objectives: \u2022 The watermark is embedded into the initial latent variables at the semantic level without altering semantic consistency and image quality. \u2022 Watermark messages can be modified flexibly without retraining or fine-tuning the model. \u2022 The watermark is robust against various image processing techniques and state-of-art watermark removal methods. The core idea of DiffuseTrace is to embed the watermark into latent variables. The initial latent variables of the latent space are divided into multiple watermark regions, with each region corresponding to a portion of the watermark information. To ensure both lossless quality and semantic consistency of the image, the embedded watermark should approximate a standard normal distribution and be extractable by the decoder. Specifically, DiffuseTrace consists of a watermark encoder and watermark decoder. The model owner encodes the initial latent variables through the watermark encoder. The latent variables are then processed through a scheduler guided by prompts and denoised through a U-Net. Afterward, latent variables are decoded by a variational autoencoder into watermarked images. The watermarked images are subjected to an attack layer and decoded back into the latent space. Through diffusion inversion, the original latent variables are restored. The watermark is then extracted from the decoded latent variables through the decoder. 4.2 Pre-training Watermark Encoder-Decoder The paper pretrains the encoder-decoder structure for watermark embedding and extraction. The training objective of the encoder is to construct a unified representation of watermark information and latent variables under a standard Gaussian distribution based on the watermark information and the embedded watermark region. Specifically, when binary identity information of the user is inputted into the encoder, it will produce watermark-embedded latent variables which adhere to a standard Gaussian distribution. The following explains the reason for latent variables with watermark conforming to a standard normal distribution. When the latent generator of the LDM samples latent variables \ud835\udc4dfrom noise, the function of the U-Net is to iteratively denoise Gaussian noise matrices within the diffusion cycle guided by text and timesteps. By subtracting the predicted noise from random Gaussian noise matrices, the random Gaussian noise matrices are eventually transformed into the latent variables of the image. Since the noise introduced during the training process of the U-Net follows a normal distribution, the initial latent variables of the LDM inference process should ideally approximate a standard normal distribution. When training a variational autoencoder to encode images into latent variables, one of the training objectives is to approximate the latent variables to adhere roughly to a standard normal distribution. More precisely, the training set for U-net involves repeatedly adding noise from a standard normal distribution to images. With a sufficient number of iterations, the original images will converge close to a standard normal distribution. Hence, during the denoising image generation phase, the initial noise is selected to conform to a standard normal distribution. If there is a significant deviation of the initial noise from the standard normal distribution, it may lead to inconsistencies between image quality and semantics. Watermarked latent variables that are closer to a standard normal distribution better conform to the standard denoising process. Due to the non-differentiability and gradient descent limitations of distributions, the encoder\u2019s model architecture employs the reparameterization technique to generate watermark-embedded latent variables. Considering the difficulty of explicitly distributing watermark regions at the trillion level, we have adopted an implicit partitioning of the watermark regions. Sampled latent variables are constrained by Kullback-Leibler divergence to approximate a standard normal distribution. Each watermark information independently maps to a portion of the probability distribution. The specific principles are detailed in our theoretical analysis 5. The decoder network is the inverse of the encoder. The training objective of the decoder is to extract watermark information from the initial latent variables. The encoder and decoder are jointly trained to ultimately produce watermark-embedded latent variables that conform to a standard normal distribution. The decoder then outputs the corresponding watermark information based on these latent variables. According to the analysis of 5.2, the reconstruction of watermark refers to maximizing the expected probability distribution of the watermark \ud835\udc64given the latent variable. The loss for reconstructing the message L\ud835\udc64is calculated as the Mean Square Error (MSE) loss between the original watermark message and the decoded message: L\ud835\udc64= \ud835\udc40\ud835\udc46\ud835\udc38(\ud835\udc5a\ud835\udc52\ud835\udc60\ud835\udc60\ud835\udc4e\ud835\udc54\ud835\udc52,\ud835\udc51\ud835\udc52\ud835\udc50(\ud835\udc5a\ud835\udc52\ud835\udc60\ud835\udc60\ud835\udc4e\ud835\udc54\ud835\udc52\u2032)) (9) For the loss of the initial latent variable distribution, We compute the Kullback-Leibler (KL) divergence between the distribution of the latent variables and the standard normal distribution as the distribution loss. KL divergence is a measure of how one probability distribution diverges from the expected probability distribution. Suppose we have two probability distributions P and Q for a random variable \ud835\udf09. If \ud835\udf09is a discrete random variable, the KL divergence from P to Q is defined as: DKL(\ud835\udc43\u2225\ud835\udc44) = \u2211\ufe01 \ud835\udc56 \ud835\udc43(\ud835\udc56) ln \u0012 \ud835\udc43(\ud835\udc56) \ud835\udc44(\ud835\udc56) \u0013 (10) According to the analysis of 5.1, we assume that the output follows a normal distribution, denoted as \ud835\udc5d1 \u223cN (\ud835\udf071, \ud835\udf0e2 1) and the standard normal distribution is denoted as \ud835\udc5d2 \u223cN (0, 1). The distribution loss L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61used in this paper is as follows: L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61= \ud835\udc3e\ud835\udc3f(\ud835\udc5d1\u2225\ud835\udc5d2) = \u22121 2 \u00d7 [2 log\ud835\udf0e1 + 1 \u2212\ud835\udf0e2 1 \u2212\ud835\udf072 1] (11) In the above two loss functions, L\ud835\udc64ensures the correct decoding of watermark information, while L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61guarantees the initial distribution of latent variables, thereby ensuring the quality and semantic \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu consistency of the images. The encoder and decoder are jointly trained by minimizing the following loss function: L = \ud835\udf061L\ud835\udc64+ \ud835\udf062L\ud835\udc51\ud835\udc56\ud835\udc60\ud835\udc61 (12) \ud835\udf061 and \ud835\udf062 represent the proportion constant parameter. Therefore, the trained encoder is capable of embedding information into latent variables that approximately adhere to a standard normal distribution, while the decoder can be seen as the inverse process of the encoder to extract the watermark. 4.3 Decoder Fine-Tuning According to the analysis of 5.3, throughout the entire watermark embedding-extraction process, following factors contribute to decoding imprecision: (1) The diffusion inversion process approximates the differences between adjacent step latent variables; (2) Since the prompt is not available in the practical scenarios during the decoding stage, we utilize zero-text inversion; (3) Potential alterations and manipulations to the image occur through various image processing techniques. These factors contribute to inevitable deviations in the inferred initial latent variables. In essence, these processes result in a global shift of the initial latent variables in the semantic space of the images. The decoder can accurately extract most of the watermark information, but samples located at the edges of the watermark region exhibit significant inaccuracies. During the fine-tuning phase of the decoder, the objectives are to adapt to the shift occurring in the watermark region and accurately extract the watermark from the attacked samples. Specifically, we fix the encoder of the watermark model and diffusion model. To simulate the image processing procedures in real-world scenarios, the attack layer employs an image perturbation technique after generating various images with randomly prompted words. The perturbation layer includes randomly adding Gaussian noise, applying Gaussian blur, color jittering and image compression to the images. Adversarial training will enhance the robustness of watermark detectors against image processing. After inverting the images subjected to image processing, we obtain the modified initial latent variables. We fine-tune the decoder by computing the mean squared error between the decoded messages and the original watermark messages as the loss function. 4.4 Error correction mechanism The scheme clearly delineates the watermark region, but during watermark detection, the effects of inversion and image processing due to adversarial training on the decoder can lead to overlap in watermark detection areas. This results in bit errors for samples at the edges of the watermark region where overlap occurs during adversarial training. We have provided detailed reasons and explanations in the security analysis 5.4 and elucidated the reasons and necessity for employing error correction codes. Recursive Systematic Convolutional (RSC) Codes: RSC codes provide a systematic approach to encoding and decoding bitstreams, allowing for error correction of data and adaptive recovery of the original message from corrupted data. Concretely, Given an input bitstream m, the RSC encoder transforms it into another bitstream \ud835\udc5a+\ud835\udc501 +\ud835\udc502...\ud835\udc50\ud835\udc58. where each \ud835\udc50\ud835\udc56is a bitstream that has the same length as the bitstream \ud835\udc5aand the symbol + indicates the concatenation of bitstreams. A higher encoding ratio can withstand a greater proportion of errors but results in a lengthier encoded bitstream. When decoding, if the modified bit string \ud835\udc5a\u2032 +\ud835\udc501...\ud835\udc50\ud835\udc56is input to the RSC decoder and the error rate of the encoded stream is less than a certain threshold, the original information m can be recovered. We can utilize this property to make corrections to watermark encoding. Turbo Codes [3]: Turbo codes can tolerate more bit errors compared to other codes at the same bit rate. A typical Turbo code consists of two convolutional codes and an interleaver. The primary function of the interleaver is to shuffle the outputs of the two convolutional codes, increasing the independence of each code and thus enhancing error correction performance. During the decoding process, an iterative algorithm is utilized to estimate and rectify errors iteratively, thereby enhancing the error correction performance. In our experiments, we utilize Turbo codes as error correction codes to further enhance the stability of watermark extraction. The specific process involves the model owner assigning identity information to the model user, which is then encoded into identity information codes with redundancy using Turbo codes. These identity information codes undergo encoding by the encoder, denoising of latent variables, inversion of latent variables, extraction of watermark information and error correction of the extracted identity information redundancy codes to restore the initial identity information. The mechanism of error correction codes combines partial watermark regions into a unified part, correcting the initial latent variables located at the boundaries of watermark detection regions, thereby enhancing the robustness of watermark detection. 5 THEORETICAL ANALYSIS OF THE PROPOSED SCHEME 5.1 Unified Representations of Watermark Regions and Latent Variables Based on the initial requirements, we aim to establish a unified representation for watermark information and latent variable regions. For each watermark \ud835\udc4a, specific distributions of latent variables are distributed. These settings ensure that all images generated by the model can be attributed to the initial distribution of latent variables. Formally, We set both the diffusion model and the watermark model to share the same latent space. For specific parts of this latent space, we can sample and extract watermark features based on a probability function \ud835\udc43(\ud835\udc67). We assume a series of deterministic functions \ud835\udc53(\ud835\udc67;\ud835\udf03) parameterized by a vector \ud835\udf03in some space \u03a6, where \ud835\udc53: \ud835\udc4d\u00d7 \u03a6 \u2192X . When \ud835\udf03is fixed and \ud835\udc67\u223cN (1, 0), \ud835\udc53(\ud835\udc67;\ud835\udf03) can generate latent variables that conform to a standard Gaussian distribution. By adopting this approach, we can construct watermark distribution regions corresponding to specific watermark information. These regions coincide with the latent variables of the diffusion model, achieving a unified representation of both. Additionally, the distribution of the watermark conforms to a standard normal distribution. This embedding process solely alters the selection of initial latent variables, preserving semantic consistency and image quality. \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY We aim to optimize \ud835\udf03such that \ud835\udc43(\ud835\udc67) can be sampled \ud835\udc67from while ensuring it closely matches the watermark \ud835\udc4a. To formalize this concept mathematically, the objective of DiffuseTrace is to maximize the probability of each \ud835\udc4athroughout the entire watermark extraction process. This objective stems from the principle of maximum likelihood. If the decoder is capable of reconstructing the watermark from the latent variables, it is also likely to reconstruct watermark from similar samples and unlikely to reconstruct watermark from dissimilar ones. To illustrate the dependence of \ud835\udc43(\ud835\udc67) on\ud835\udc4a, we transform \ud835\udc53(\ud835\udc67,\ud835\udf03) into \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03). The probability density function can be formalized as follows: \ud835\udc43(\ud835\udc4a) = \u2211\ufe01 \ud835\udc67 \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03)\ud835\udc43(\ud835\udc67) (13) The output distribution conforms to a Gaussian distribution after watermark embedding. Therefore, \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03) satisfies the following distribution: \ud835\udc43(\ud835\udc4a|\ud835\udc67;\ud835\udf03) = N (\ud835\udc4a|\ud835\udc53(\ud835\udc67;\ud835\udf03), \ud835\udf0e2\ud835\udc3c) (14) After embedding the watermark, the latent variables have a mean of \ud835\udc53(\ud835\udc67;\ud835\udf03) and a covariance equal to the identity matrix \ud835\udc3cmultiplied by the scalar \ud835\udf0ewhich is a hyperparameter. 5.2 The Implicit Allocation of Watermarks Essentially, we need to partition the standard normal distribution, with each partition capable of accurately reconstructing the original watermark. For a 48-bit watermark, dividing into over two hundred eighty-one trillion regions presents a challenge in manually determining the watermark encoding regions given the complexity of explicitly partitioning watermark regions under the standard normal distribution. This implicit partitioning problem is analogous to the challenges faced by variational autoencoders in fitting distributions to data. As outlined in the paper [11], any distribution in \ud835\udc51dimensions can be generated using a set of \ud835\udc51variables drawn from a normal distribution and mapped through a sufficiently complex function. For \ud835\udc43(\ud835\udc4a), within the partitioning of the watermark into over two hundred eighty-one trillion blocks, most sampled \ud835\udc67contribute minimally to \ud835\udc43(\ud835\udc4a), since \ud835\udc43(\ud835\udc4a|\ud835\udc67) is close to zero for most \ud835\udc67. The approximation of the prior distribution can be simplified by introducing the posterior distribution \ud835\udc5e(\ud835\udc67|\ud835\udc65). By computing the KL divergence between the posterior and prior distributions, we obtain: \ud835\udc37[\ud835\udc5e(\ud835\udc67|\ud835\udc64)||\ud835\udc5d(\ud835\udc67|\ud835\udc64)] = E\ud835\udc67\u223c\ud835\udc5e[(\ud835\udc67|\ud835\udc64) \u2212log\ud835\udc5d(\ud835\udc67|\ud835\udc64)] (15) The same to solving the variational evidence lower bound, we derive the watermark reconstruction evidence lower bound through Bayesian transformation: log\ud835\udc5d(\ud835\udc64) \u2265E\ud835\udc67\u223c\ud835\udc5e[log\ud835\udc5d(\ud835\udc64|\ud835\udc67)] \u2212\ud835\udc37[\ud835\udc5e(\ud835\udc67|\ud835\udc64)||\ud835\udc5d(\ud835\udc67)] (16) The first term in the equation represents maximizing the expected probability distribution of the watermark \ud835\udc64given the latent variable \ud835\udc67, i.e., the loss incurred by the watermark decoder in reconstructing the watermark. The second term is for the approximate posterior distribution of the latent space \ud835\udc67to closely resemble the prior distribution, i.e., the watermark information generated by the encoder and the standard normal distribution should be as similar as possible. 5.3 Offset of Watermark Detection Region As stated in Equation 7, diffusion inversion attributes the generated image to the initial latent variables. The assumption of diffusion inversion approximates \ud835\udc4b\ud835\udc61\u22121\u2212\ud835\udc4b\ud835\udc61to \ud835\udc4b\ud835\udc61+1\u2212\ud835\udc4b\ud835\udc61. While unconditional diffusion inversion can yield accurate results, excessive guidance scale in conditional diffusion amplifies the errors introduced by null-text diffusion inversion [23]. In fact, after extracting the semantic embeddings of the images, conducting a forward pass after each inversion and applying gradient descent can enhance the effectiveness of the inversion process. Let the current latent variable be \ud835\udc4d\ud835\udc61\ud835\udc56. \ud835\udc4d\ud835\udc61\ud835\udc56+1 is obtained after performing inversion on \ud835\udc4d\ud835\udc61\ud835\udc56. The process of solving \ud835\udc4d\ud835\udc61\ud835\udc56+1 under the guidance of extracting semantic embeddings can be mathematically expressed as follows: \u2207\ud835\udc9b\ud835\udc61\ud835\udc56+1 \u2225\ud835\udc9b\ud835\udc61\ud835\udc56\u2212\ud835\udc9b\u2032 \ud835\udc61\ud835\udc56\u22252 2 (17) Theoretically, refining the decoder by restoring the initial latent variables through the aforementioned approach would yield better results. However, considering the computational overhead of the gradient descent process, the approach adopted in the paper accepts the inaccuracy of diffusion inversion under zero text and defines this inaccuracy as the offset to the watermark detection region. The purpose of fine-tuning is to learn the offset vector as \ud835\udc5d. The watermark encoder trained with maximum likelihood exhibits the following properties, similar samples have more similar latent variables, while dissimilar samples have greater distances in the latent space. The distance between the similar latent variables obtained after inversion and the initial latent variables should be less than a certain threshold \ud835\udf16to guarantee the accuracy of detection. After the watermark region is segmented, the watermark detection area is offset due to diffusion inversion, the refinement target at this point transforms into: min \ud835\udf03 E(\ud835\udc65\ud835\udc56,\ud835\udc66\ud835\udc56)\u223cD [max \ud835\udc3f(\ud835\udf03,\ud835\udc56\ud835\udc5b\ud835\udc63(\ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5c(\ud835\udc65\ud835\udc56)) + \ud835\udc5d\ud835\udc56,\ud835\udc66\ud835\udc56)]. (18) \ud835\udc65\ud835\udc56denotes specific latent variables and \ud835\udc66\ud835\udc56denotes the watermark region \ud835\udc65\ud835\udc56belong. In the formula 19, \ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5crepresents the process of diffusion denoising 6, \ud835\udc56\ud835\udc5b\ud835\udc63represents the precise inversion process, and \ud835\udc5d\ud835\udc56denotes the offset of the watermark detection area caused by approximation 7. After fine-tuning the watermark decoder, it should satisfy \ud835\udc5d< \ud835\udf16to ensure detection accuracy. Taking into account that images may undergo various treatments including image blurring, Gaussian noise, color transformations, etc., such attacks can affect samples on the edges of the watermark region, leading to decreased detection accuracy. Essentially, this process does not alter the watermark\u2019s region, but it notably aids in repairing the evasion of edge samples. Adversarial training can appropriately expand the range of the watermark detection region for various attacks. Therefore, the refinement target can be further transformed into: min \ud835\udf03 E(\ud835\udc65\ud835\udc56,\ud835\udc66\ud835\udc56)\u223cD [max \ud835\udc3f(\ud835\udf03,\ud835\udc56\ud835\udc5b\ud835\udc63(\ud835\udc51\ud835\udc52\ud835\udc5b\ud835\udc5c(\ud835\udc65\ud835\udc56) + \ud835\udeff) + \ud835\udc5d\ud835\udc56,\ud835\udc66\ud835\udc56)]. (19) The variable \ud835\udeffcan be expressed as the deviations caused by various attacks on the image, where images generated after such attacks are semantically similar but deviate from the original image in semantic space. Correcting this step further enhances the watermark decoder\u2019s detection accuracy for edge samples. \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 5.4 Security Analysis Based on the above analysis, DiffuseTrace divides the watermark region into multiple contiguous areas. Assuming the image undergoes image processing resulting in changes compared to the original image, this change is assumed to be \ud835\udf16\ud835\udc5dwithin the latent variable space. The initial latent variable corresponding to the original image is \ud835\udc4d0 \u2208X. As long as \ud835\udc4d\ud835\udc47+\ud835\udf16\ud835\udc5d\u2208X, the watermark verification is successful. For the initial latent variables close to the center of the watermark region, the distance from the latent variables to other watermark regions is \ud835\udc37\u226b\ud835\udf16\ud835\udc5d. In this case, watermark verification is straightforward. However, for samples at the edges of the watermark region, \ud835\udc4d\ud835\udc47+ \ud835\udf16\ud835\udc5d\u2209X. In the detection phase, we effectively expanded the detection area for each watermark, considering the outer radius \ud835\udc5fof each watermark region as part of the region itself. This process can be formalized as follows: \ud835\udc51\ud835\udc52\ud835\udc61\ud835\udc52\ud835\udc50\ud835\udc61(\ud835\udc67\ud835\udc47+ \ud835\udf16\ud835\udc5d) = \ud835\udc57\ud835\udc62\ud835\udc51\ud835\udc54\ud835\udc52(\ud835\udc670 + \ud835\udf16\ud835\udc5d\u2208(X + r)) (20) The size of \ud835\udc5fdepends on the magnitude of the perturbations in adversarial samples used during adversarial training. Expanding the partition of watermark regions actually increases the risk of overlap to some extent between different watermark regions. We set the distance \ud835\udc51between the two watermark regions. Since the encoder remains fixed, the region of the watermark itself won\u2019t change. However, due to inversion-induced overall shifts and image processing, the detection area post-inversion corresponds to a deviated initial region. If \ud835\udc5f\u2264\ud835\udc51, adversarial training enhances the robustness of the watermark, ensuring that even edge latent variables can still extract the watermark. Security Analysis Without Attack. If the magnitude of adversarial training \ud835\udc5fexceeds \ud835\udc51, it causes the watermark from one edge sample to fall within the detection range of another, leading to bit errors. Indeed, during training, adversarial samples at the boundary regions steer the model in the wrong direction, while correct samples in these regions guide the model back on track. As a result, the accuracy of samples in these areas remains above fifty percent but unstable, leading to a fluctuating state. To correct such errors, we employ error correction codes. As mentioned by 4.4, if the error rate of samples in the boundary region is within an acceptable range, error correction codes can restore the original information. Essentially, this approach uses a larger amount of information to rectify errors and merges multiple regions into one. Security Analysis of Image Processing. In our scheme, we consider image manipulation where the same image undergoes a certain offset in the latent space, but within an acceptable range smaller than a certain threshold. If the corresponding change in the latent space is less than \ud835\udc51, adversarial training ensures that both central and marginal latent variables can successfully decode the information. Common image manipulations such as Gaussian transformations, color jittering, brightness variations and image compression all keep the image\u2019s position in the latent space within an acceptable range. Therefore, DiffuseTrace effectively defends against such attacks. Even with significant image manipulations such as JPEG compression to 10 percent, contrast increase to 8, and brightness increase to 6, DiffuseTrace maintains a certain level of accuracy. Security Analysis of VAE-based Attacks and Diffusionbased Attacks. The core idea behind attacks such as VAE-based attacks and Diffusion-based attacks in the proposed scheme is to disrupt and reconstruct. Disruption involves adding noise to the image, while reconstruction involves removing the noise through a diffusion model. The reason why such attacks can succeed is that the primary objective of most watermarking schemes is to add minimal watermark noise to the image while still being able to extract the watermark information. These methods often utilize the LPIPS loss [47] or differences in the color channels of the image as the loss function, aiming to minimize the SSIM and PSNR metrics of the final image. This allows reconstruction attacks to exploit this vulnerability by continuously adding noise to gradually degrade the stability of the watermark. Eventually, the reconstruction process generates an image that is indistinguishable from the watermark. While some watermarking schemes, such as Stegastamp, sacrifice image quality and significantly increase adversarial training to enhance their stability, there is no defense against reconstruction attacks when constructive steps become sufficiently numerous. In fact, reconstruction attacks can even produce images that are clearer than the watermark samples. The watermark based on the initial latent variables primarily operates at the semantic level, allowing for stable watermark extraction as long as there are no significant changes in the image within the latent space. Attacks on watermarks based on diffusion models by adding noise do not alter the original semantic content of the image actually. The initial hidden space positions of the image can still be discerned which makes it resistant to such reconstruction attacks. This is exactly the advantage of DiffuseTrace in combating attacks. 6 EXPERIMENTS 6.1 Experimental settings Datasets. In the experiment, we utilized the following datasets: \u2022 Real Photos: 500 images were randomly selected from MSCOCO [18], which contains over 328K images along with their annotations. \u2022 AI-Generated Images Prompts: 500 prompts were randomly sampled from Diffusion Prompts, a database of approximately 80,000 prompts filtered and extracted from image finders. \u2022 AI-Generated Images: 500 images and prompts are randomly chosen from StableDiffusionDB [41]. This dataset contains images generated by Stable Diffusion based on prompts and hyperparameters provided by actual user interactions. Watermark Baselines. For traditional watermarking schemes, we selected DcTDwt [1] and DcTDwtSvD [8] which is deployed in Stable Diffusion as a watermark with an embedding capacity of 48. For post-processing watermarking schemes based on EncoderDecoder/GAN structures, we chose RivaGAN [44], Hidden [51] and StegaStamp [37] with embedding capacities of 32, 48, 48, and 48 respectively. For watermarking schemes based on Variational Autoencoders, we chose Stable Signature [13] and and SSLWatermark [14] with an embedding capacity of 48. Additionally, for watermarking schemes based on latent variables, we chose Tree-Ring with a watermark radius of 10. Given that tree-ring is a zero-bit watermark scheme, we utilized p-values as the detection metric. The \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Table 1: Bit Accuracy/Detection Accuracy Under Image Processing Method Brightness Noise Contrast Hue JPEG Blur Resize BM3D Value 2.0 0.05 2.0 0.25 50 7*7 0.3 30 Traditional Wm. DwtDct 0.601/0.000 0.801/0.642 0.497/0.000 0.479/0.000 0.488/0.000 0.582/0.092 0.493/0.000 0.498/0.000 D.Svd 0.612/0.042 0.850/0.999 0.718/0.118 0.485/0.000 0.498/0.000 0.989/0.999 0.506/0.000 0.632/0.084 Enc.-Dec. Wm. RivaGan 0.975/0.999 0.960/0.994 0.832/0.992 0.984/0.999 0.773/0.801 0.867/0.924 0.504/0.000 0.858/0.873 Hidden 0.964/0.999 0.971/0.994 0.979/0.999 0.992/0.999 0.849/0.823 0.816/0.852 0.825/0.873 0.626/0.168 S.Stamp 0.937/0.999 0.979/0.999 0.972/0.999 0.995/0.999 0.952/0.999 0.981/0.999 0.972/0.999 0.980/0.999 VAE-Based Wm. S.Signa 0.971/0.999 0.976/0.996 0.965/0.999 0.954/0.994 0.806/0.809 0.781/0.822 0.513/0.011 0.604/0.013 Latent-Based Wm. SSLWm. 0.927/0.999 0.627/0.124 0.975/0.999 0.942/0.997 0.547/0.000 0.997/0.999 0.844/0.901 0.620/0.224 Ours 0.942/0.999 0.915/0.999 0.959/0.999 0.982/0.999 0.912/0.999 0.966/0.999 0.922/0.999 0.902/0.999 Table 2: Image Sematic Quality and Undetectability Evaluation. The table demonstrates the impact of adding semantic watermarks on image quality through two No-inference Metrics, NIQE and PIQE. The semantic consistency before and after adding the DiffuseWatermark is evaluated through the Clip metric. Dataset Method NIQE\u2193PIQE\u2193Clip\u2191Bit/Detect DiffusionDB No-Watermark 4.91 28.21 0.342 0.511/0.000 Tree-ring(rad10) 5.32 30.28 0.332 -/0.999 Tree-ring(rad20) 6.64 37.33 0.301 -/0.999 DiffuseTrace(16) 4.22 29.08 0.344 0.999/0.999 DiffuseTrace(32) 5.04 29.77 0.339 0.992/0.999 DiffuseTrace(48) 4.72 28.41 0.340 0.984/0.999 MS-COCO Prompts No-Watermark 3.85 33.28 0.335 0.504/0.000 Tree-ring(rad10) 4.32 34.28 0.324 -/0.999 Tree-ring(rad20) 5.64 38.33 0.291 -/0.999 DiffuseTrace(16) 4.12 33.25 0.333 0.999/0.999 DiffuseTrace(32) 3.81 30.21 0.326 0.994/0.999 DiffuseTrace(48) 4.17 32.34 0.330 0.990/0.999 Diffusion Prompts No-Watermark 4.88 29.72 0.326 0.488/0.999 Tree-ring(rad10) 5.32 30.28 0.327 -/0.999 Tree-ring(rad20) 5.94 37.33 0.303 -/0.999 DiffuseTrace(16) 4.93 28.42 0.358 0.999/0.999 DiffuseTrace(32) 5.11 30.18 0.353 0.999/0.999 DiffuseTrace(48) 4.70 26.33 0.328 0.984/0.999 corresponding bit capacity of DiffuseTrace is 48 bits. Considering the additional overhead of redundancy codes, no error correction codes were used in the comparative experiments. Attack Baselines. To thoroughly evaluate the robustness of DiffuseTrace, we test it against a comprehensive set of baseline attacks that represent common image processing, VAE-based attack and diffusion-based attack. Specially, The set of attacks employed in our testing includes: \u2022 brightness and contrast change of 2.0 \u2022 addition of Gaussian noise with standard deviation of 0.05 \u2022 Adjustment of the hue by 0.25. \u2022 JPEG compression with a quality setting of 50. \u2022 BM3D denoising algorithm with Peak Signal-to-Noise Ratio Standard Deviation of 30. \u2022 Gaussian blur with kernel size 7 and standard deviation of 1 \u2022 Two Variational AutoEncoder (VAE) based image compression models, Bmshj18 [2] and Cheng20 [7], both with compression factors of 3. \u2022 A stable diffusion-based image regeneration model for watermark attack, Zhao23 [49] with 40 denoising steps. Evaluation Metrics. The two main objectives of incorporating watermarks are copyright protection and user tracing. Therefore, we utilize \ud835\udc5d\ud835\udc63\ud835\udc4e\ud835\udc59\ud835\udc62\ud835\udc52as the standard for copyright tracing and utilize bit accuracy rate as the standard for user tracing. We set a decision threshold to reject the null hypothesis for \ud835\udc5d< 0.01, requiring detection of the corresponding method-corrected 24/32 and 34/48 bits. Otherwise, the image is deemed to be without a watermark. Semantic consistency. Since our images have watermarks added before image generation, the watermark is reflected at the semantic level. Therefore, we choose the CLIP score metric [25] to evaluate the semantic consistency between generated images and prompt words. The reference metric will be used to evaluate the semantic quality difference between the generated images with and without watermark embedding in DiffuaeTrace in order to evaluate the fidelity of watermark embedding Image Quality. We evaluate the quality of an image through two no-reference metrics, the Natural Image Quality Evaluator (NIQE) score [22] and the Perceptual Image Quality Evaluator (PIQE) score [38] . The reference indicators will be used to compare the quality of images without watermarks with images with watermarks embedded in order to evaluate the loss of watermark embedding on the image and the invisibility of the watermark. 6.2 Sematic and image quality evaluation From Table 2, we evaluated the impact of embedding the watermark on image quality and semantic consistency before and after. The experiment utilized the stable-diffusion-2-1-base model [29] with 25 inference steps at the guidance scale of 5. Results indicate no significant differences in NIQE and PIQE quality metrics across different watermark bits. Additionally, semantic alignment of generated images, as assessed by Clip scores, remains similar to the original model. This suggests that DiffuseTrace does not rely on the trade-off between image quality and watermark robustness typical of post-processing watermarks. Since images are generated \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 0 1 2 3 4 5 6 Brightness Intesity 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Brightness Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0.0 0.1 0.2 0.3 0.4 Standard Deviation of Noise 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Noise Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 2 4 6 8 Contrast Intensity 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Contrast Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 20 40 60 80 100 Quality Rate 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR JPEG Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0.0 2.5 5.0 7.5 10.0 12.5 15.0 Kernel Size 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Blur Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 20 40 60 80 Resize Scale 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Resize Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 20 40 60 80 100 Denoising Strength 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR BM3D Attack Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 2 4 6 8 Quality Rate 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR VAE-based Attack (Cheng 20) Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp 0 25 50 75 100 125 150 Denoiset Steps 0.00 0.25 0.50 0.75 1.00 Bit accuracy/TPR@1%FPR Diffusion-based Attack (Zhao 23) Bit accuracy TPR@1%FPR Stable Signature DwtDctSvd SSL Watermark Stegastamp Figure 2: The figure illustrates the performance of DiffuseTrace in response to various attacks of different intensities, measured by bit accuracy and TPR@0.01FPR. It also compares TPR@0.01FPR of traditional watermarks such as DwtDctSvd, SSL Watermark and Stable Signaturez under corresponding attacks. The watermark capacity for each scheme in the figure is 48 bits. entirely through correct sampling processes and variables are properly distributed without subsequent modifications to the images, the DiffuseTrace approach exhibits significant advantages in terms of image quality compared to post-processing solutions. Compared to other methods that embed watermarks in the latent space, the SSL watermark remains a post-processing solution. Tree-ring alters the distribution of initial latent variables by embedding the watermark in the frequency domain of the latent space through Fourier transformation. However, U-net fails to recover from the losses incurred during this process. Consequently, as the watermark radius increases, the generated images suffer significant losses in both quality and semantic consistency. 6.3 Robustness evalution against image processing From Table 1, we evaluated the robustness of the watermark against various image processing attacks. It could be observed from the graph that DiffuseTrace demonstrates stability and roubustness when faced with common image processing attacks. DiffuseTrace achieve watermark detection rate close to 100 percent and average bit accuracy above 90 percent under common attack. Compared to post-processing watermarking schemes and VAE-based watermarking schemes, DiffuseTrace demonstrates excellent stability when faced with significant image compression and resizing. Stegastamp remain highly robust in the comparison, since it sacrifices image quality and utilizes error correction codes to compress 96 bits into 48 bits, with a relatively large error correction space. Stable Signature watermark specially for diffusion model remain stable under most attacks, but is vulnerable to denoise algorithm and processing to high extent. Furthermore, We conducted detailed experiments on various types of image disturbance amplitudes and compared the current method to latent-based method ssl watermark and vaebased watermark stable signature under maximum attack intensity. The results showed that DiffuseTrace has a significant advantage in image processing stability compared to other methods. 6.4 Robustness evaluation against VAE-based attacks and diffusion based attacks. In Table 3, we evaluated the accuracy of various watermarking schemes when faced with deep learning-based attacks. The experiments consist of VAE-based attack and diffision-based attack which is the latest watermark attack. The table reveals that the majority of \fDiffuseTrace: A Transparent and Flexible Watermarking Scheme for Latent Diffusion Model Conference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY schemes are unable to withstand this type of reconstruction attack. Stable Signature exhibits fragile From the results, it is evident that DiffuseTrace exhibits a significant advantage in countering VAEbased attacks utilizing diffusion models. SSL watermarks and stable signatures all exhibit low watermark detection rates, indicating that they are unable to resist both VAE-based and diffusion based attacks. For diffusion based attacks, except for DiffuseTrace, other watermark schemes have experienced a significant drop in bit accuracy. In subsequent experiments, we increased the intensity of the diffusion attack. From the results, it is evident that DiffuseTrace exhibits significantly higher resilience against reconstruction attacks compared to other methods. Even the VAE-attack with a quality coefficient of 1 or the diffusion-based attack with 150 denoise steps do not fundamentally affect the stability of the watermark and only the DiffuseTrace was able to maintain accuracy in high-intensity reconstruction. Reconstruction attacks are achieved by maintaining semantic accuracy, continuously adding noise to destroy watermarks and continuously reconstructing and restoring images to obtain images without watermarks. However, this process essentially does not alter the semantic consistency of the image nor does it significantly alter the initial latent variables of image inversion. Therefore, DiffuseTrace can remain stable under reconstruction attacks. Table 3: Bit Accuracy/Detection Accuracy Under Deeplearning-based Attack Method VAE A. Diffusion A. Bmshj18 [2] Cheng20 [7] Zhao23 [49] Traditional Wm. DwtDct 0.524/0.000 0.517/0.012 0.489/0.000 D.Svd 0.504/0.000 0.512/0.013 0.523/0.014 Enc.-Dec. Wm. RivaGan 0.611/0.063 0.632/0.070 0.588/0.070 Hidden 0.621/0.170 0.641/0.198 0.497/0.009 S.Stamp 0.979/1.000 0.965/1.000 0.852/0.927 VAE-based Wm. Stable Signature 0.616/0.224 0.682/0.409 0.541/0.014 Latent-based Wm. SSL Wm. 0.623/0.123 0.631/0.144 0.655/0.149 Tree-ring /0.993 /0.991 /0.997 Ours 0.972/1.000 0.967/1.000 0.970/1.000 6.5 Ablation Experiments This section, we experimentally quantify the impact of several key hyperparameters mentioned in the theoretical analysis 5 on the inaccuracy. we consider the impact of the guidance scale used during the generation phase, the inference steps employed during the inversion phase, and the version of the model on watermark detection in order to demonstrate the effectiveness of DiffuseTrace. Ablation on Guidance Scale. In the theoretical analysis 5.3, we elaborate on the reasons why the guidance scale introduces errors into the experiments. In the following experiments, we quantify the impact of the guidance scale on the DiffuseTrace watermarking scheme through experimentation. For the ablation experiment on the guidance scale, the scheduler is set the dpm++ [20] scheduler. The experimental setup includes setting both the inference steps and reverse inference steps to 20. We adjust the guidance scale to assess its influence on the experimental results. The specific experimental results depicted in the graph 3 show that as the guidance scale increases during the inference stage, the bit accuracy gradually decreases, while the detection accuracy remains relatively stable within the guidance scale range of 0 to 20. This indicates that the watermark detection accuracy is maintained, demonstrating the robustness of the watermark. Thus, users can freely adjust the guidance scale during the image generation stage while still ensuring traceability of the watermark. Deploying the diffusion model as a service can provide users with the option to adjust the guidance scale hyperparameter, which will not significantly affect watermark detection. Ablation on Inference Steps. The ablation experiment for reverse inference steps employed the DPM++ scheduler, with an inference step setting of 20 and a guidance scale set to 5. The evaluation of the experiment\u2019s results involves adjusting the reverse inference steps to assess their impact. The experimental results, as depicted in the figure 3, indicate that after 5 inference steps of inversion, the watermark detection rate stabilizes. Even with only 2 inference steps, a good detection rate can still be maintained. This suggests that the number of inference steps does not significantly affect the accuracy of detection. Therefore, during the detection phase, to increase efficiency, a small number of reverse inference steps can be employed to extract the image watermark. 7 RELATED WORK 7.1 Detection of AI-Generated Images It is difficult for humans to distinguish between real and fake images. Realistic fake images intensify concerns about the disinformation dissemination. To tackle this problem, various fake image detection approaches have been proposed. A typical approach [15, 36, 39] involves extracting temporal, frequency, and texture features from images. Subsequently, a feature extraction network is constructed to train a binary classifier to distinguish between AI-generated images and real images. However, this image detection method exhibits noticeable performance degradation when applied to diffusion models. For AI-generated image detection based on diffusion models [40], leveraging a pre-trained diffusion model allows for a more accurate reconstruction of the characteristics of images generated through the diffusion process. By reconstructing the diffusion process, differences between real images and images generated by the diffusion model can be detected thereby enabling the detection of AI-generated images. Adding a watermark to generated images is also a method for identifying AI-generated images. 7.2 Image Watermarking The strategy of adding watermarks to images for protecting intellectual property rights has a long history in the field of computer vision. Traditional image watermarking methods typically involve embedding watermarks into appropriate frequency components of the image, utilizing techniques such as Discrete Cosine Transform (DCT), Discrete Wavelet Transform (DWT) [1] or Singular Value Decomposition (SVD) [19]. Deep learning-based approaches, such as HiDDeN [51] , StegaStamp [37], have demonstrated competitive results in terms of robustness against various geometric \fConference acronym \u2019XX, June 03\u201305, 2024, Woodstock, NY Liangqi Lei, Keke Gai, Jing Yu, and Liehuang Zhu 0 5 10 15 20 Guidance Scale 0.0 0.2 0.4 0.6 0.8 1.0 Bit accuracy/TPR@1%FPR Ablation on Guidance Scales Stable-diffusion-v1-4 Stable-diffusion-2-1-base TPR@1%FPR Bit accuracy 5 10 15 20 25 30 Reverse Inference Steps 0.0 0.2 0.4 0.6 0.8 1.0 Bit accuracy/TPR@1%FPR Ablation on Reverse Inference Steps Stable-diffusion-v1-4 Stable-diffusion-2-1-base TPR@1%FPR Bit accuracy Figure 3: The figure (left) illustrates the ablation experiment concerning the guidance scale, where adjusting the guidance scale leads to a gradual decrease in the watermark\u2019s bit accuracy, while the watermark detection rate remains stable. The figure (right) shows the results of the ablation study on reverse inference steps, where the bit rate detected stabilizes after two inference steps. transformations. These methods often employ deep learning encoders and extractors to embed and extract watermarks respectively. the aforementioned watermarking methods primarily focus on postprocessing existing images. The core idea is to achieve robustness against various attacks while minimizing the impact on the visual quality of the image. Therefore, post-processing methods are confronted with a trade-off between watermark stability, watermark capacity and image quality. For diffusion model watermarking, it can mainly be categorized into three types: Watermark embedding during training phase. In methods incorporating watermarks during the training phase, watermarks are embedded into the training data. The data is encoded with the watermark during training and a decoder is trained to extract the watermark. During the detection phase, all images generated by diffusion models will carry encoded binary strings. Watermark [50] is a representative approach. Methods of this kind typically have stringent requirements for watermark embedding, involving the incorporation of watermarks into a substantial dataset of images followed by training the entire model. Fine-tuning phase with watermark incorporation. The main purpose of such watermark embedding methods is to integrate the watermark component into the model component, making it inseparable during distribution. Watermarks are incorporated into model components during fine-tuning. For instance, methods like Stable Signature [13] and FSwatermark [43] fine-tune the variational autoencoders to ensure that all generated images carry the watermark. It\u2019s approximate to integrating the watermark into the final generation stage. Watermark embedding into latent space during inference. During inference steps, watermarks are added to the latent variable space of the model. Methods like Tree-ring [42] and ZoDiac [45] achieve this by diffusing inversion and applying frequency domain transformations to latent variables, ensuring that all generated images carry the watermark. DiffuseTrace also falls into this category of methods. The watermark is embedded in the image prior to its generation. 7.3 Image Watermarking Attack The goal of image watermark attacks is to assess the robustness of image detection after practical modifications. These attacks mainly fall into two categories: image processing attacks and deep learningbased attacks. image processing attacks. Common image processing techniques include adding noise, color jitter, image compression, image scaling and Gaussian blur. Image processing or compression methods may utilize frequency-domain or 3D transformation-based approaches including BM3D denoising algorithm [9]. Deep learning-based attack. Deep learning-based attack methods, including methods based on variational autoencoders such as [2] and [7] can disrupt watermarks embedded in images. In recent research, diffusion based attacks [49] are used to encode the semantic features of images, add noise to disrupt watermark and regenerate images. Reconstruction models exhibit prominent performance and can eliminate most watermarks injected by most existing methods. 8" + } + ], + "Liehuang Zhu": [ + { + "url": "http://arxiv.org/abs/1812.02009v2", + "title": "Research on the Security of Blockchain Data: A Survey", + "abstract": "With the more and more extensive application of blockchain, blockchain\nsecurity has been widely concerned by the society and deeply studied by\nscholars. Moreover, the security of blockchain data directly affects the\nsecurity of various applications of blockchain. In this survey, we perform a\ncomprehensive classification and summary of the security of blockchain data.\nFirst, we present classification of blockchain data attacks. Subsequently, we\npresent the attacks and defenses of blockchain data in terms of privacy,\navailability, integrity and controllability. Data privacy attacks present data\nleakage or data obtained by attackers through analysis. Data availability\nattacks present abnormal or incorrect access to blockchain data. Data integrity\nattacks present blockchain data being tampered. Data controllability attacks\npresent blockchain data accidentally manipulated by smart contract\nvulnerability. Finally, we present several important open research directions\nto identify follow-up studies in this area.", + "authors": "Liehuang Zhu, Baokun Zheng, Meng Shen, Shui Yu, Feng Gao, Hongyu Li, Kexin Shi, Keke Gai", + "published": "2018-12-05", + "updated": "2018-12-07", + "primary_cat": "cs.CR", + "cats": [ + "cs.CR" + ], + "main_content": "Introduction Blockchain [1] technology combines multiple computer technologies such as encryption, distributed storage, consensus, Peer to Peer (P2P) network, and smart contracts [2]. These key technologies make blockchain open, secure, trust \u2217Corresponding author Email address: shenmeng@bit.edu.cn (Meng Shen) Preprint submitted to Journal of L A T EX Templates December 10, 2018 arXiv:1812.02009v2 [cs.CR] 7 Dec 2018 \fand smart. Moreover, these techniques allow transactions to be continuously linked to blockchain. Blockchain records all transactions and historical data by establishing a jointly maintained and untampered database. Internet users who do not know each other can reach a credit agreement through smart contracts, point-to-point ledger, or digital encryption without any central trust [3]. Thereby blockchain has attracted extensive research attention from various industries [4, 5, 6, 7, 8, 9]. With the development of blockchain applications, the security of blockchain data is particularly important, and it is the fundamental enabling factors of many blockchain applications. Currently, attackers use the characteristics of the blockchain itself to conduct various attacks on the blockchain data, which makes the blockchain data face various threats. (1) The openness of blockchain data exposes users\u2019 privacy. Attackers can \ufb01nd the relationship between addresses through transactions [10]. (2) Network attacks cause abnormal or incorrect access to blockchain data, which undermine the availability of the blockchain data. A Bitcoin address can be associated with an Internet protocol (IP) address; therefore, Attackers can track the correspondence among addresses, users and real identity [11, 12]. (3) Blockchain data will be tampered if an attacker passes an attack on the blockchain consensus mechanism. Blockchain is also vulnerable to sel\ufb01sh mining attacks [13, 14, 15]. These undermine the integrity of blockchain data. (4) Smart contract vulnerabilities can cause serious problems by making blockchain data not controlled by users [16]. In addition to these enumerated problems, there are many other security threats in blockchain, such as mining pool attacks [13] and miner attacks [17]. These threats seriously a\ufb00ect the data security of blockchain, which threatens the related blockchain applications. There are some recent surveys about blockchain security. Gervais et al. [18] surveyed security and adversarial strategies of proof of work (PoW). Atzei et al. [19] and Luu et al. [16] investigated the vulnerabilities of smart contracts. However, these surveys focused on the security and privacy of a certain aspect of blockchain. Li et al. [20] summarized some cases of attacks against blockchain 2 \f1.0 and 2.0. However, their article lacks systematic description and categorization of threats and countermeasures. With the rapid development of blockchain, many new threats and countermeasures have emerged, and up-to-date research is needed to meet the needs of blockchain development. Our paper summarizes and analyzes the security of blockchain data. We present the attacks and defenses of blockchain data in terms of the privacy, availability, integrity and controllability. Data privacy attacks include the threats of transaction and identity privacy. Data availability attacks include the threats brought by network traceability and eclipse attacks. Data integrity attacks include the threats brought by double-spending, sel\ufb01sh mining, and block withholding attacks. Data controllability attacks include the vulnerabilities of smart contracts. We present corresponding countermeasures for the threats for each type of attack. Our main contributions include the following: \u2022 We created a comprehensive classi\ufb01cation and summary of the security of blockchain data. \u2022 We present the attacks and defenses of blockchain data in terms of the privacy, availability, integrity and controllability. \u2022 We describe attacks and defenses in a contrastive way. According to blockchain data security features, we present the attack mechanism and the countermeasures. We present the evolution of the attacks and countermeasures. \u2022 We discuss research hotspots and present several future research directions. The rest of this paper includes: In section 2, we introduces classi\ufb01cation of attacks. In section 3, we present blockchain data challenges. In sections 4, we present corresponding solutions. Finally, we present research directions for the future in section 5 and summarize our survey in section 6. 3 \fTable 1: Classi\ufb01cation of Blockchain Attacks Data privacy attacks Transaction privacy attacks Identity privacy attacks [10, 21, 22] [10, 21, 22, 23, 24, 27, 28] Data availability attacks Network traceability attacks Eclipse attacks [31, 32, 33, 11, 12] [34, 35, 12, 36, 37, 38, 39] Data integrity attacks Double-spending attacks Sel\ufb01sh mining attacks Block withholding attacks [40, 41, 25, 37, 43, 44] [15, 45, 46, 47, 48] [17, 15, 45, 49, 50] Data controllability attacks Logic problems Semantic misunderstandings Design problems veri\ufb01er\u2019s dilemma Privacy preservation [51] [16] [52] [53, 54] 2. Classi\ufb01cation of Blockchain Attacks As previously mentioned, the security of blockchain data is mainly divided into four aspects: privacy, availability, integrity, and controllability. Each aspect contains several attacks, as shown in Table 1. Data privacy attacks refer to data leakage or data obtained by attackers through analysis. In this aspect, we present the threats of transaction and identity privacy. Data availability attacks refer to abnormal or incorrect access to blockchain data. In this aspect, we present the threats brought by network traceability and eclipse attacks. Data integrity attacks refer to blockchain data being tampered. In this aspect, we present the threats brought by double-spending, mining pool, and miner attacks. Data controllability attacks refer to blockchain data accidentally manipulated by smart contract vulnerability. In this aspect, we present the vulnerabilities of smart contracts. 4 \fTXA TXB TXC 3.0BTC 2.0BTC 2.5BTC 0.5BTC (change) 2.0BTC 4.0BTC 0.5BTC (change) Input Output/ Input Output Figure 1: Bitcoin transactions schematic diagram. 3. Blockchain Data Attacks 3.1. Data Privacy Attacks Using the transaction process of Bitcoin as an example, we can analyze the threats and corresponding solutions of blockchain data. In Bitcoin, every transaction is traceable. A transaction output is the input to another transaction, thus forming a transaction chain. Based on the chain of transactions, the analyst can obtain the use of any coins and the relevant transactions of any address. As shown in Figure 1, an example illustrates the simple transaction process, assuming that Alice launched transaction A, Bob launched transaction B, and Mike launched transaction C. The relationship of transaction input and output is as shown in the \ufb01gure. Potential attackers can analyze users\u2019 transaction and identity privacy by analyzing transaction records, as shown in Figure 2. 3.1.1. Transaction Privacy Attacks The transaction input comes from the output of another transaction. Based on the blockchain of transactions, analysts can obtain the following information: \u2022 The Use of Bitcoin: The Bitcoin came from the mining process, which was \ufb01rst recorded in the miners\u2019 mining address and then transferred to other addresses. Both mining and transaction information will be recorded in 5 \fData Privacy Attacks Address Relations [10] Special Transactions [21] Transaction Rules [22] Change Address [26] Transaction Characteristics [23] Transaction Rules [24] Coinbase Transactions [25] Multi-input Transactions [10,21,22] Transaction Privacy Threats Identity Privacy Threats Figure 2: Data privacy attacks. the global ledger. Therefore, by analyzing these public data, an attacker can acquire all transactions of any Bitcoin. \u2022 The Blockchain Transaction Addresses: Each blockchain transaction details the information of all the input and output addresses. Therefore, analysts can obtain the following information: \u2022 Finding Bitcoin Relations between Di\ufb00erent Addresses: The transfer of the coins between accounts re\ufb02ects the relationship between accounts. Reid and Harrigan [10] analyzed the accounts published by WikiLeaks and tallied the balances , Bitcoin sources and \ufb02ows of the Bitcoin addresses published on the WikiLeaks website. The paper also analyzed a stolen address in Bitcoin and found the \ufb01ve closest addresses to the theft address, revealing the preand post-theft Bitcoin \ufb02ows. \u2022 Tracking Special Transactions: We can monitor the transaction information of special transactions involving large or suspected malicious acts such as theft, and further trace the \ufb02ow of Bitcoins through continuous observation. Liao et al. [21] showed the attack of CryptoLocker that extorts Bitcoin by encrypting the victim\u2019s \ufb01les. The authors studied the relation transactions of public Bitcoin ransomware addresses. 968 addresses that belong to the organization were found, and ransom transactions worth 6 \f1128.40 BTC were identi\ufb01ed. This information assists in determining the identity of the criminals. \u2022 Discovering the Rule of Transactions: The Rule of Transactions can reveal the relationship between transactions. Ron and Shamir [22] focused on the transactions statistics. They traced 364 transactions of more than 50,000 BTC and studied the transactions rules for a transaction of 90,000 BTC . The authors found that the large transactions used a variety of methods to disperse Bitcoins to di\ufb00erent addresses. These transaction modes include long chains, fork-merge patterns and self-loops, keeping Bitcoins in saving accounts, binary tree-like distributions. 3.1.2. Identity Privacy Attacks There are many clues and side information in blockchain transactions, and it is possible to use these clues and side information to speculate about the identity privacy. The architecture of Bitcoin can be revealed the following: \u2022 Multiple Input Addresses belong to the same person or organization. The multiple input transactions are initiated by the same user because each input in a multi-input transaction requires a separate signature [10, 21, 22]. \u2022 Multiple Output Addresses in the same Coinbase [25] transaction belong to the same user set. Many miners want to increase their income by joining one mining pool where they participate in collective mining. All miner addresses involved in mining are recorded as the Coinbase transaction output. \u2022 Input Addresses and Change Address belong to the same user. The change address is generated by the Bitcoin system, which save the change Bitcoins in one transaction [26]. The features of the change address include the following: the status of the output address is usually only once, the change address only belongs to the transaction input or output in one transaction; and only change address cannot appear in the output address. 7 \fThe \ufb01rst clues and side information are due to the design of Bitcoin itself. By using these clues and side information, analysts can discover the correlation between di\ufb00erent addresses and reduce the anonymity of blockchain addresses. Meiklejohn et al. [27] used heuristic analysis to analyze transaction data in the blockchain to identify the same user\u2019s di\ufb00erent addresses. They analyzed the public addresses of Silk Road and the addresses associated with some theft cases and found many related addresses. Zhao et al. [28] proposed a clustering process for Bitcoin transaction data. Based on the analysis of 35,587,286 addresses in the global ledger of Bitcoin, there were 13,062,822 di\ufb00erent users. The second clues and side information is the following: \u2022 Transaction Characteristics: The transaction characteristics are usually related to the actual transaction processes. Many transaction behaviors have their own characteristics in daily life [23]. For example, transactions at breakfast stores often occur in the morning, and the transaction amount is set at one to 20 coins. The gas station transaction time is an average, but the transaction amount is concentrated in a few speci\ufb01c values, i.e., 100 coins, 200 coins, or full price (changes based on the change of oil price have universal regularity). \u2022 Transaction Rules: Each user has a di\ufb00erent transaction behavior. Monaco [24] analyzed the transaction parameters, and then proposed a method based on parameter identi\ufb01cation. 3.2. Data Availability Attacks The main threat of data availability is to make abnormal or incorrect access to blockchain data. 3.2.1. Network Traceability Attacks In Bitcoin network, IP address, topology, and transmission information can be obtained by attackers. Based on this information, the analyst can analyze user identity privacy. Each network node is connected to many other nodes 8 \f... Victim node Neighbor node Probe node \u2460 \u2460 \u2461 \u2461 \u2462 Monitored link First forwarding Second forwarding Third forwarding Server Connected path \u2461 \u2461 \u2460 Transaction propagation path Neighbor node Figure 3: Transaction traceability mechanism diagram. through the P2P network, and the connection relationship between these nodes can be analyzed. [29, 30]. Transaction traceability is to estimate the transaction propagation path according to the time order that the di\ufb00erent nodes send the transaction to arrive at the probe, as shown in Figure 3. Ideally, the originating node is the earliest to arrive at the probe, the neighbor arrives at the neighbor second, and the order the next n\u2212th neighboring nodes arrive at the probe will increase with distance. In the actual environment, the time order of di\ufb00erent nodes\u2019 transmitted transactions arriving at probes is a\ufb00ected by many factors, such as network delay and delay transmitting strategy, and the transactions transmitted by the longdistance nodes may arrive earlier. To accurately analyze the matching degree of transaction ranking and node network topology, we will consider a variety of in\ufb02uencing factors and calculate the trading order accuracy. Network traceability technology uses the collection of Bitcoin network transmissions of information to analyze the transmission path of Bitcoin transactions in the network, then tracks the transaction-generated server IP information. This technology can directly contact an anonymous transaction via the trade originating node\u2019s IP address to permit traceability. However, the existing net9 \fwork traceability technology has a low accuracy and generally needs additional computing and storage resources; therefore, it is less practical. Bitcoin users can make double-sided transactions of Bitcoin tokens by creating Bitcoin transactions with other users on servers anywhere in the world [31, 32, 33]. Since the transaction does not require the participation of third parties, and the addresses used by both parties in the transaction are anonymous, the real identity of the Bitcoin traders is hard to \ufb01nd. Transaction traceability technology desires to track the transmission path of Bitcoin transactions in the network to \ufb01nd the originating node of a transaction, which is the \ufb01rst server node of the transaction in the Bitcoin network. Once a Bitcoin transaction is associated with the IP address of the originating node, the anonymous account number in the transaction can be associated with the user identity, which helps to identify the identity information of the malicious trader and analyze the \ufb02ow of the Bitcoin funds. Network traceability technology is to analyze the transaction information transmitted by the Bitcoin network, locate the propagation path of a speci\ufb01c transaction, and then infer the origin node of the transaction. Koshy et al. [11] analyzed the patterns of Bitcoin transactions in the network and found that we can search for the origin node by using the special transaction mode. For example, a transaction that is transmitted only by one node is usually due to a problem with the transaction format, then this transaction is transmitted only once by the originating node. However, the e\ufb00ect of this method is limited due to the small proportion of all transactions in the special transaction mode (less than 9% of the special transactions in the paper trial). Biryukov et al. [12] analyzed transaction traceability using neighbor nodes. By using neighbor nodes as the basis for judgment, the accuracy of traceability can be improved. However, the solution must continuously send information to all the nodes in the Bitcoin network, which may cause serious interference to the Bitcoin network and is less practical. 10 \f3.2.2. Eclipse Attacks Heilman et al. [34] described eclipse attack, which exploits the broadcast features of P2P networks to attack. The attacker controls the reception and transmission of all information of the victim node, causing the victim node\u2019s inbound connection to the illegal node. The attack node maliciously \ufb01lls the victim node\u2019s routing table before the victim node of the blockchain restarts, forcing the victim node to restart and establish an outgoing connection with the attack address in the routing table [34] [35]. At the same time, the attack node continuously establishes an incoming connection with the victim node. Eventually, the channel of the monopolistic victim node is reached, and the purpose of its information \ufb02ow is controlled so that it can only receive useless or even malicious information sent by the attack node. If the attack node can successfully implement eclipse attacks on more nodes, it can control the blockchain channel and information \ufb02ow of more nodes, and gradually control most of the blockchain networks. Attackers can even launch 51% attacks and double-spending attacks on this basis, causing more serious consequences. The eclipse attack process is usually divided into four steps, as shown in Figure 4 and detailed as follows: \u2022 Populating Tried and New Tables: The blockchain node is capable of receiving the addresses of the unsolicited incoming connections and the unsolicited ADDR message. The addresses of the incoming connections will be stored in the tried table, and the addresses contained in the ADDR message can be inserted directly into the new table. The nodes will not test the addresses\u2019 connectivity. Therefore, when the attack nodes are connected to the victim node through the attack addresses, the attack node can send an ADDR message containing a lot of \u201ctrash\u201d IP addresses that will gradually overwrite all legal addresses of the new table. The nodes rarely get network information from their neighbor nodes and DNS seeders. Therefore, when an attacker overwrites the tried and new tables 11 \fControl multiple attack addresses Create incoming connections periodically Send ADDR message to victim nodes Restart victim nodes Reselect the outgoing node Successful attack Monopolize the eclipsed victim Figure 4: Eclipse attack \ufb02ow diagram. of the victim node, the victim node almost never veri\ufb01es its authenticity by querying a legitimate peer or sower. \u2022 Restarting the Victim: The victim node will be restarted by the eclipse attack. After the node is restarted, the victim node can be connected to the attack addresses. The reasons for the Bitcoin node restart include: ISP shutdown, machine shutdown, operating system upgrade of the mining machine, etc [12, 36, 37, 38, 39]. \u2022 Selecting Outgoing Connections: After the victim node is restarted, if the address is selected from the new table to establish an outgoing connection, all connections fail. Therefore, the victim node is forced to only pick the addresses from the tried table. Because the victim node prefers to choose the updated addresses, all the outgoing connections of the victim node are connected to the attack addresses. 12 \fTable 2: Some other Attacks that may be caused by an Eclipse Attack Reference Attacks Description [40, 41, 25, 43, 37, 44] Double-spending threat Using the same cryptocurrency in multiple transactions by a sender [15, 45, 46, 47, 48] Sel\ufb01sh mining attack Hiding the excavated blocks to cause the chain to fork [15, 45, 17, 49, 50] Block withholding attack The attacker never submits any blocks \u2022 Monopolizing the Eclipsed Victim: If the above attack is successful, The attacker must control all incoming connections to the victim node in order to truly monopolize the victim node. In addition, the eclipse attack will also cause other attacks. The main attacks are shown in Table 2, the details of the attacks will be described in detail in section 5. 3.3. Data Integrity Attacks Data integrity attacks primarily include double-spending, sel\ufb01sh mining, and block withholding attacks. 3.3.1. Double-Spending Attacks Double-spending attacks refer to the use of the same cryptocurrency in multiple transactions by a sender. Bitcoins use the PoW system, which has approximately ten minutes of con\ufb01rmation time between blocks. Therefore, an attacker will implement a the attack in this time interval. In addition, if the attacker has a signi\ufb01cant amount of computational power, he or she will be more likely to successfully perform the attack. Double-spending attack is a unique attack on the bitcoin system that falls into two types: \u2022 Attacker Used the same Bitcoin to Trade with multiple Users at the same Time: If these trading users complete the transaction without the transac13 \fBitcoin Network Attacker Attacker Vendor Bitcoin Mining Pools Figure 5: Double-spending attack model. tion being recorded in the legal blockchain, the attacker achieves the goal of double spending or even multiple spending [37, 40, 41, 42, 43]. Although in the multiple transactions launched by the attacker, only one transaction is considered legal and recorded in the blockchain, the transaction has been completed and the attacker has bene\ufb01ted from the attack. \u2022 Attacker Used his own Computing Power to Launch an Attack: The attacker used the same Bitcoin to trade both transaction A and transaction B with two users. If the transactions A is con\ufb01rmed to be recorded in the blockchain, transaction A is completed. Because the attacker has a powerful computing power, he records transaction B in the private blockchain and mines a longer chain than the legal one, prompting transaction B to be con\ufb01rmed and completing transaction B [44]. Ghassan et al. [43] analyzed the double-spending threat of Bitcoin in the fast payment scenario. Figure 5 illustrates the attack model. We assume that the attacker A must pay BTCs to a vendor V , and A creates the transaction TXv to V . Simultaneously, to realize double-spending, A creates another transaction TXa that has the same BTCs as those involved in TXv\u2019s inputs. The successful implementation of a double-spending attack must meet the following three requirements: \u2022 TRv is added to V \u2019s wallet. 14 \f\u2022 TRa is con\ufb01rmed in the blockchain. \u2022 V \u2019s service time is less than the time when V detects the wrong behavior. In fact, because of the PoW mechanism, it usually takes ten minutes to prevent double-spending attacks, so it does not apply to quick payment scenarios. Additionally, without a suitable detection mechanism, double-spending attacks can be implemented in a low-cost manner. 3.3.2. Sel\ufb01sh Mining Attacks Sel\ufb01sh mining attack [15] is a typical attack on blockchain. A cryptocurrency like Bitcoin requires a high computing power to solve the cryptographic problem for a miner, so the mining becomes very di\ufb03cult. In view of this, a group of miners (or mining pools) are usually combined with each other and share the rewards after successfully solving the password problem. This helps individual miners produce more continuous and constant income when mining alone. Eyal et al. [15] proposed that if there is a group of sel\ufb01sh miners who use sel\ufb01sh mining strategies and succeed, it may invalidate the work of honest miners. A malicious mining pool does not publish the blocks it \ufb01nds and creates a fork. Therefore, there are public chain maintained by honest miners and the private fork by malicious mining pools. Since the fork is the longest chain in the current network, it will be recognized as a legal chain by honest miners. Therefore, the original public chain and the honest data it contains will be discarded. The results of the study show that usually the sel\ufb01sh mining strategy will get more bene\ufb01ts. At the same time, the analysis shows that if the sel\ufb01sh pool exceeds one third of the total net, the existing protocol will no longer be safe. Courtois et al. [45] conducted experimental simulation and theoretical analysis of sel\ufb01sh mining. The results show that the computational waste of Bitcoin is minimal, and it is even decreasing over time. Sapirshtein et al. [46] studied the optimal strategy of the sel\ufb01sh-mining underlying model. Nayak et al. [47] shows when this attack is combined with an eclipse attack, these strategies sometimes 15 \fBitcoin Network Miners \u03b1 Miners \u03b1 Miners \u03b1' Miners \u03b1' Miners \u03b2 Miners \u03b2 Pool #1 Pool #2 Figure 6: Block withholding attack diagram. result in a gain of 30% depending on the di\ufb00erent parameters. Carlsten et al. [48] proposed a more complex sel\ufb01sh mining strategy that led to uneven returns and exceeded default mining and traditional sel\ufb01sh mining. Once deployed, the attack will be pro\ufb01table, which could result in 51% of attacks or consensus failures. 3.3.3. Block withholding Attack Block withholding attack [17] is one of the typical attacks on blockchain. In the attack, some malicious attackers who have joined the joint mining pool do not have any mining blocks, which reduces the revenue of the mining pool and wastes the computing power provided by other miners. This kind of attack is also called sabotage attack. Usually, the malicious miners will not have any bene\ufb01t. The blocker attack will cause di\ufb00erent losses to the miners and mining pools, and the mining pools\u2019 losses are relatively large compared to the miners\u2019 low cost. As a result, block withholding attack is more common in competing mining pools and less common in miners [15]. Block withholding attack diagram is shown in Figure 6. Courtois et al. [45] analyzed the actual examples and found that the main hazard of the malicious miners who can pro\ufb01t from this attack is to waste the computing resources of the mining pools and reduce the income of the mining pools. Eyal [49] analyzed the game of miners\u2019 dilemmas, and there 16 \fSmart Contract Value|State Transactions Sending Value to the Contract Events Sending information to the contract Transactions Sending Value from the Contract Events Sending information from the contract Replicated, shared ledger Figure 7: Smart contract schematic diagram. is a balance between competing mining pools, which makes miners repeatedly choose whether to attack. Kwon et al. [50] extended the BWH attack [49] and proposed a new attack method called fork after withholding (FAW) attack. The attack uses sel\ufb01sh mining attacks based on BWH attacks. The FAW attacks\u2019 frequency is four times as often as BWH attacks, and the attack will also gain an additional 56%. In addition, the research showed that when two pools attack each other, the more computing power, the easier it is to win. 3.4. Data Controllability Attacks Smart contracts are blockchain-based programs that directly control digital assets. Additionally, it is executed automatically by a computer system. Nick Saab [51] indicates that smart contracts are essentially a recognized tool for forming relationships between individuals, institutions and property, i.e., a set of agreements that form relationships and reach consensus. Smart contracts work similar to if-then statements. When a prede\ufb01ned trigger condition is reached, the smart contract is executed. The most signi\ufb01cant feature of smart contracts based on Ethereum is Turing completeness. Smart contracts are written into the blockchain in the form of digitization, which is protected by the blockchain. The entire process of storing, reading and executing by the characteristics of blockchain is transparent and traceable and cannot be changed. If a user wants to modify a smart contract, he or she must control at least 51% of the calculation power. The input to a smart contract includes transactions and events. The transac17 \ftions mainly include transaction data, and the events refer to the description of the transactions. Smart contracts are triggered when conditions are met. Smart contracts exist to allow a complex set of digitized promises with triggering conditions to be properly executed according to the wishes of the participants, as shown in Figure 7. Table 3: Smart Contract Vulnerability Summary Reference Classi\ufb01cation Description [51] Errors in encoding state machines Coins may not be returned. [51] Failing to use cryptography Attackers can adjust their input according to the user\u2019s input. [51] Misaligned incentives The second user will no longer have any action (i.e., no reward) when he feels he may have failed. [51] Ethereum-speci\ufb01c mistakes The problem causes some bugs. [16] Transaction-ordering dependence If the transaction veri\ufb01cation order is di\ufb00erent, the execution result is di\ufb00erent. [16] Timestamp dependence Miners can attempt di\ufb00erent timestamps in advance to calculate the winning value, to award the prize to the winners they desire. [16] Mishandled exceptions If there is an error during the call, it will return to the pre-contract state. [16] Reentrancy vulnerability The new chain is broadcast to the old chain, and the transaction is still successful, resulting in confusion. [52] Resource exhaustion attack by problem givers The miners were unable to mine the next block, causing damage to the miners. [52] Incorrect transaction attack by provers The user not only wastes his or her reward but also does not receive a correct answer. [53] Data feed An attacker could gain valuable information by analyzing the transaction history. 18 \fData Controllabili -ty Attacks Failing to Use Cryptography [51] Misaligned Incentives [51] Timestamp Dependence [16] Mishandled Exceptions [16] Data Feed [53] Resource Exhaustion Attack [52] Incorrect Transaction Attack [52] Errors in Encoding State Machines [51] TransactionOrdering Dependence [16] Ethereum-Specific Mistakes [51] Reentrancy Vulnerability [16] Privacy Preservation Logic Problems Semantic Misunder standings Design Problems Figure 8: Data controllability attacks. Smart contracts maximize open source and solve the trust issues of traditional SAAS services. Developers can validate the code\u2019s original code through compilation to prove the code\u2019s usability. Therefore, smart contracts are applied in various \ufb01elds such as housing leasing, savings insurance, \ufb01nancial lending, and probation. However, smart contracts solve the contradiction between the openness and security of the code, currently, there remain other security privacy issues. A smart contract vulnerability summary is shown in Table 3 and Figure 8. In the aspect of the programming of smart contracts [51], if the contract itself has a logic trap, the execution result of the smart contract can be changed through certain trigger conditions to generate the result that is bene\ufb01cial to the developer. Semantic misunderstandings [16] may occur during the execution of a smart contract deployed at Ethereum, inconsistent with the notion of a smart contract written by the original developer, causing the result to deviate from the expected performance. Incentives designed for smart contracts [52] may create a veri\ufb01er\u2019s dilemma where honest miners choose to continue verifying or mining to get rewarded when faced with the more di\ufb03cult task of verifying transactions. For the data privacy protection of smart contracts, the privacy 19 \fprotection of data [53] and an authenticated data feed [54] are elaborated. We will detail each threat and its corresponding security method in a later section. After detailing each of the attacks in Table 3, we develop a solution (except for privacy reasons, because they have no vulnerabilities to attack). 3.4.1. Logic Problems of Smart Contracts Delmolino et al. [51] gathered smart contracts written by students, and there are many security issues in the design process. The security of smart contracts is very important in the process of programming them. Even if some malicious miners exist, they will not increase their own pro\ufb01ts. They search bugs of contracts, and there will be security pitfalls, although the design and implementation of the contract is very simple. This contract mainly consists of two parts, one for each player to input his or her own results and the other for the contract to determine the winner and send him or her the award. \u2022 Errors in Encoding State Machines: During the game between the two players, the contract may contain some mistakes. If there is a third player to send coins to in the contract, no one\u2019s coins will be returned. Even a cautious player cannot avoid this situation. Since developers do not fully consider the status of the execution of each step of the contract or clearly de\ufb01ne the clear conversion between the states in the programming of smart contracts, these problems arise. \u2022 Plaintext transmission: Players send their inputs in plaintext in smart contracts is a serious problem. Because the transactions are transmitted through plaintext, malicious players only need to intercept other people\u2019s inputs \ufb01rst and adjust their input results according to other players\u2019 inputs to maximize their pro\ufb01ts. \u2022 Misaligned Incentives: Once a player believes that he or she will lose the game, the player may choose not to continue to send any further messages, thus refusing to pay the winner\u2019s rewards and protecting his or her own interests. 20 \f\u2022 Ethereum-speci\ufb01c Mistakes \u2013 Call-stack Bug: In EVM, there are three locations for data storage, the stack, temporary memory, and permanent memory. Among them, the stack is the only free data storage area; other areas must pay for gas. However, there are some issues that may arise when using the stack. When the stack depth exceeds a certain limit (Ethereum speci\ufb01es a stack limit of 1024), a stack over\ufb02ow will occur, and the caller of the contract will have a loss of property. \u2013 Blockhash Bug: In Ethereum, block.prevhash instruction is used only to calculate the hash value of the 256 recent blocks. \u2013 Incentive Bugs: There are some incentive bugs in Ethereum, for example, selecting the winner of the election by using a hash of the block as a random beacon. However, miners can selectively withhold blocks to deviate from this value to gain an unfair advantage. If miners mine a new block, they can check whether they win. If they do not win, the miners will keep this block until next block is generated; then, they will receive a second chance to see if they win the game. \u2013 Other Bugs: One of the important issues that must be considered when designing a smart contract is scalability, as contractual upgrades are inevitable. In EVM, code is completely unmodi\ufb01able and it is impossible to load and execute code in memory. The code and data are completely separated. Currently, the upgrade can only be achieved by deploying a new contract, which may require copying all the code in the original contract and redirecting the old contract to the new contract address. Patching the contract or partially upgrading the contract code in EVM is completely impossible. 3.4.2. Semantic Misunderstandings of Smart Contracts Luu et al. [16] documented several several vulnerability in Ethernet smart contracts. These defects refer to di\ufb00erences between the author\u2019s design and 21 \factual semantics. We introduce the following four types of security issues and countermeasures: \u2022 Transaction-Ordering Dependence: The vulnerability is that the order of transaction validation a\ufb00ects the execution result of intelligent contracts. If the transaction veri\ufb01cation order is di\ufb00erent, the execution result is different. The attacker provided a smart contract with a prize wager and promised generous rewards when the user determined the correct solution. When the user submits the answer and the transaction has not been veri\ufb01ed, the attacker will initiate another transaction, making the transaction\u2019s reward value in\ufb01nitely close to zero. At this point, two unveri\ufb01ed transactions appear in the pool. When the miners verify the transactions, the user\u2019s transaction that answers the question after verifying the attacker\u2019s transaction has the user\u2019s rewards signi\ufb01cantly reduced; the attacker seldom pays any bonuses to obtain the right answer. In addition, attackers can make miners prioritize their transactions by increasing transaction fees. \u2022 Timestamp Dependence: The Ethereum states that when the timestamp of a new block generated by the miners is greater than that of the last block and the time di\ufb00erence between the two is less than 900 seconds, the new block is considered valid and its timestamp is legal. Timestamp dependency refers to the implementation of smart contracts that depend on the current timestamp; the results of the execution timestamps vary. If there is a lottery contract, the winning value is calculated from the current timestamp and other variables that are known in advance, and the same code as the lucky number will be awarded. At this point, in the process of mining, miners can attempt di\ufb00erent timestamps in advance to calculate the winning value, to award the prize to the winner they desire. \u2022 Mishandled Exceptions: Ethereum use the send tool to call a contract or call the contract function directly. If there is an error during the call, it 22 \fwill return to the pre-contract state. King of the Ether Throne (KoET) is an Ethereum contract that will make you a king or queen, might grant you riches, and will immortalize your name. A user can become the new king by paying a certain amount of ether; part of the ether will be used to pay the previous king\u2019s remuneration. In the transfer process of the ether, the smart contract did not check the payment results of the transaction, and once the contract call exception occurs, the incumbent kings may also lose their throne and compensation. \u2022 Reentrancy Vulnerability: Traditional reentrancy attacks refer to the situations in which an attacker sends a packet that has been received by the destination host to achieve deception. While a reentrancy attack on the blockchain is a transaction that has been veri\ufb01ed on a chain reappearing on another chain for veri\ufb01cation, this attack usually occurs when the blockchains are permanently divergent. The famous TheDao hack, because of the inaccuracy of the intelligent contract code, led to a large vulnerability in the transaction funds. Although permanent divergence is used during a later period, there will be reentrancy attacks. The new chain is broadcast to the old chain, and the transaction is still successful, resulting in confusion. 3.4.3. Design Problems of Smart Contracts Luu et al. [52] presented the veri\ufb01er\u2019s dilemma, which states that veri\ufb01ers would make a choice between mining or transaction veri\ufb01cation. When the transactions are expensive, miners will decide to bypass their veri\ufb01cation and mine to ensure their own pro\ufb01ts. As a result, miners are vulnerable to resource depletion or incorrect transaction attacks. \u2022 Resource Exhaustion Attacks by Problem Givers: Honest miners verify new transactions in accordance with the protocols. Therefore, attackers can broadcast a very large number of transactions, causing other miners to waste a signi\ufb01cant amount of calculation power to verify the correctness 23 \fof the transaction. To prevent this, Ethereum establishes a gas (consumption) mechanism. Each transaction requires a gas limit and a gas price. Gas limit is the maximum amount of Gas consumption allowed by this transaction. Gas price is a tip. If the user does not have su\ufb03cient Ether to pay the maximum cost of his or her own settings, the transaction is considered invalid, the previously changed state will be restored, and the consumed gas will not be returned to the user. However, the gas mechanism cannot prevent this scenario. The new block is mined by the attacker. Then, the attacker broadcasts their expensive transactions. Even if the attacker pays considerable transaction fees for the deal, because the fees will be given to the miners who mine a new block regardless of the number of transaction fees, the transaction fees will be returned to attacker\u2019s account. \u2022 Incorrect Transaction Attack by Provers: When a user asks for a solution to a di\ufb03cult problem, malicious respondents may provide an incorrect solution, because the transaction veri\ufb01cation requires a signi\ufb01cant amount of calculation power; therefore, the majority of miners will selectively bypass veri\ufb01cation of this transaction, believe it to be correct, and then broadcast it directly to the network, so that the user not only wastes his or her reward but also does not receive the correct answer. Through these two attacks, it is found that if the malicious miners mine a new block, they can attack without considering the reward. When users create a scale of transactions such as block size, Bitcoin can be repaired through prede\ufb01ned standard transactions, but there is no such restriction in Ethereum. They presented a safety model that ensures that the miners who did not perform the agreement received minor rewards, and the honest miners who veri\ufb01ed the transaction were not a\ufb00ected by the malicious miners. 24 \f3.4.4. Privacy-Preserving Smart Contracts The global ledger that stores transaction information is public. An attacker could gain valuable information by analyzing the transaction history, including the speci\ufb01c account balance of funds, transaction details, and the \ufb02ow of speci\ufb01c funds. 4. Blockchain Data Security Protection 4.1. Data Privacy Protection To ensure the reliability, non-falsi\ufb01cation and distributed consistency of the transaction, a special data structure and consensus mechanism are designed. These mechanisms ensure the maintenance of a uniform, high public trust account in distributed untrusted network nodes; however, these mechanisms also lead to privacy risks. The full ledger not only leaks data privacy but also leaks the relation between the traders who are behind the data and the identity privacy [10, 21, 22, 23, 24]. Therefore, the focus of data privacy protection is to hide the data and the information behind it as much as possible. We classify di\ufb00erent protection mechanisms according to the database privacy protection classi\ufb01cation methods, as the following: 4.1.1. Data Distortion Because the blockchain ledger is public, the attacker can \ufb01nd the relationship of the transaction data; the attacker can then infer the transaction and identity privacy. To prevent this attack, we can adopt a method called mixed coin [67] without changing the transaction results; however, this method adds confusion, as shown in Figure 9. Assuming that Alice, Bob, and Mike have transaction addresses Alice1, Bob1, and Mike1, respectively. In the process of mixing coins, \ufb01rst to generate new addresses Alice2, Bob2, and Mike2 for them, then to send the coins that need to be traded to them, mix the coins by the mixed addresses Mix1, Mix2, and Mix3 and output them to these new addresses Alice2, Bob2, and Mike2, so that others can\u2019t grasp the source of these coins. The mixed coin mechanism is classi\ufb01ed as follows. 25 \fAlice1 Bob1 Mike1 Alice2 Bob2 Mike2 Alice2 Bob2 Mike2 1BTC 1BTC 1BTC 1BTC 1BTC 1BTC Figure 9: Bitcoin mixing service diagram. \u2022 The Mixed Coin Scheme based on a Central Node: This scheme utilizes third-party nodes for mixing coins, and the process of mixing coins is done at a third-party node. These methods can improve the security of Bitcoin and other digital currencies without additional technology [68, 69, 70]. However, Its defects include: \u2013 Additional Charge and Mixed Coin with a Slower Speed: A mixed coin service node usually charges a fee. As the mixes increase, the cost rises sharply. The usual delay time is 48 hours, and the transaction costs are between one and three percent. \u2013 Risk of Theft: In this scheme, the third-party node may not perform the agreement after receiving the user\u2019s coins and steal the user\u2019s coins. The users do not have e\ufb00ective countermeasures. \u2013 The Mixing Process is leaked by Intermediate Nodes: The third-party node in this scheme understands the entire mixed coin process, and the users cannot guarantee that the third-party node will not leak the mixed coin process information. In response to these defects, many improvements have been made. Bonneau et al. [55] proposed an improved decentralized mixed coin that can be audited. Valenta and Rowan [56] designed a blindcoin scheme that can prevent a third party from divulging the process information. Qing et 26 \fal. [57] presented a blind signature scheme that use the elliptic curve to improve privacy. In 2015, Dash [58], an anonymous digital coin, launched operation. From an economic point of view, Dash solves the threat posed by centralized mixed coin. \u2022 The Mixed Coin Scheme based on Decentralization: The program does not depend on third-party nodes. CoinJoin [59] is the original plan. CoinJoin merge multiple transactions into one transaction in which the relationship of the transaction inputs and outputs can be hidden. For a multi-input and multi-output transaction, a potential attacker cannot e\ufb00ectively distinguish the relation between inputs and outputs by analyzing the transaction information. The idea of CoinJoin is used in many anonymous Bitcoin transactions, for example, Dark Wallet [60], CoinShu\ufb04e [61] and JoinMarket [71]. The CoinJoin mechanism enhances the privacy protection capabilities of all users. In a digital currency system, if only a fraction of the nodes uses the CoinJoin agreement, the remainder of the users do not use this protocol, nor do they use the original method. The CoinJoin mechanism has many defects, as the following: \u2013 As other users participate, it also faces threats from the other node. \u2013 The information of each node participating in the mixed coin will be exposed to the other. \u2013 If some nodes violate the rules, the mixed coin may fail. \u2013 The parties involved in the mixed coin transaction will be recorded in the ledger. Many scholars have proposed solutions. Ru\ufb03ng et al. [62] propose a completely decentralized CoinShu\ufb04e. Based on CoinJoin, the CoinShu\ufb04e scheme designs an output address shu\ufb04ing mechanism. This mechanism can complete the mixing process without a third party, and it can also ensure that the mixed 27 \fcoin participant does not know the relationship. However, the scheme is easy to trigger denial-of-service attacks. Bissias et al. [72] designed Xim that adopts a multi-wheel and two-square mixed coin agreement. CoinParty [73] adopts a secure multiparty computation protocol to implement an improved scheme that can guarantee the e\ufb00ectiveness of the mixed coin process in the case of malicious operation or failure of some hybrid nodes. Monero [63] is a new digital coin with a main characteristic of privacy protection. It adopts the ring signature mechanism to realize the mixing process. Compared with other schemes, the process of mixed coin in Monero does not require the participation of users; any user can implement the mixed currency independently. Monero can e\ufb00ectively eliminate the denial-of-service attack on the decentralized coin scheme and assist with the problem of users\u2019 mixed coin leakage. Mixed coin is widely used in the blockchain digital coin. There are many improvement schemes. We compare and analyze the schemes, as shown in Table 4. 4.1.2. Data Encryption An encryption mechanism is a common scheme in the \ufb01eld of privacy protection. By encrypting sensitive data, users who hold secret keys can read the data, and others cannot decrypt it, even if they have access to it. Encryption ensures data privacy. In traditional blockchain, application data is stored in plaintext, and any node can access the data. Therefore, using encryption technology to protect privacy in blockchain must ensure that nodes can complete transaction veri\ufb01cation tasks on encrypted data. In addition, since blockchain transactions must be jointly veri\ufb01ed by all nodes, the impact of encryption mechanisms on validation e\ufb03ciency must be reduced. In blockchain, speci\ufb01c transaction information must be encrypted. In digital currency, there have been some protection schemes based on encryption. \u2022 Monroe [63] is an encrypted digital currency. In traditional digital currency, the content of the transaction output address is the receiver\u2019s public key and address information, and the observer can directly determine the 28 \fTable 4: Comparison of mix mechanisms in blockchain Reference Protocol Reliance on third parties Risk of theft Mixed coins cost Resistance to DoS Peculiarity [67] Mix \u221a \u221a \u221a Strong The method is easy to use and is the most widely used. [55] Mixcoin \u221a \u221a \u221a Strong The proof can be raised to reduce the risk of theft. [56] BlindCoin \u221a \u221a \u221a Strong The blind signature mechanism is adopted to avoid leakage. [58] Dash \u221a \u221a \u221a Strong The node that provides a mixed coin increases the cost of a violation by paying a deposit. [59] CoinJoin N/A N/A N/A Weak No third parties involved, so there is no risk of theft. [62] CoinShu\ufb04e N/A N/A N/A Weak The participants of the mixed coin do not know the details of the currency. [72] Xim N/A N/A \u221a Strong The method increases the di\ufb03culty of DoS attacks using a fee. [73] CoinParty N/A N/A N/A Strong The mixing process can still function normally even if some participants violate the rules using the secure multi-party computation. [63] Monero N/A N/A N/A Strong There is no need for multilateral negotiation using the ring signature mechanism. coins\u2019 destination. In Monroe, the output address is the new address information obtained by the receiver\u2019s public key and the random parameter 29 \fPublic Key Private Key Data Encrypted Data Figure 10: Ring signature diagram. generated by the sender. Since the random parameter is only mastered by the sender, the observer cannot determine the relation between the new address information and the receiver. By generating di\ufb00erent random parameters, it can be ensured that the output addresses of each transaction are di\ufb00erent and there is no correlation between them. There are two key technologies in the Monroe coin, the stealth address and the ring signature. The stealth address is to address the problem of the relevance of the input/output address. A stealth address, while ensuring that the recipient\u2019s address changes every time, makes it impossible for an external attacker to see an address connection, but it does not guarantee anonymity between the sender and the receiver. Therefore, the Monroe coin developed a ring signature scheme. As shown in Figure 10, whenever a sender has to establish a transaction, he or she uses his or her private key and a certain number of public keys selected from other users\u2019 public key. to sign the transaction. When a signature is validated, the user must also use the other person\u2019s public key and parameters in his or her signature. At the same time, the sender must provide the key image to provide identity identi\ufb01cation. Both the private and key images are once dense to ensure they cannot be traced. 30 \fZEC TXmint ZEC Normal TX Zcash block 2 ZEC TXmint ZEC Normal TX Zcash block 2 ZEC ZEC ZEC Zcash block 1 ZEC ZEC ZEC Zcash block 1 ZEC TXpour ZEC Zcash block 4 ZEC TXpour ZEC Zcash block 4 ZEC TXmint ZEC Zcash block 3 ZEC TXmint ZEC Zcash block 3 CM1 CM2 CM3 CM4 CM5 CM6 CM7 CM8 Pour CM1 CM2 CM3 CM4 CM5 CM6 CM7 CM8 Pour Mixed coins pool based on zk-SNARKs (untraceability) CM=commitment ZEC=Zcash coins Figure 11: Zcash schematic diagram. \u2022 Zcash [64] is a new digital currency, formerly known as the Zerocoin [74] project. It is an improvement on Zerocoin. Zcash uses the promise function to encapsulate the source of each transaction and the amount of several parameters, while using zk-SNARKs [75] to prove the transaction. The proof process does not need to reveal relevant information; thus, it can hide the value of the sender and even the inputs and outputs of the transaction. Zcash is the best digital currency for privacy protection at present, but its adoption of the zk-SNARKs algorithm is very slow; it usually takes a minute to generate new proof and there is a bottleneck in e\ufb03ciency. As shown in Figure 11, the underlying implementation is similar to the structure of Bitcoin, but Zcash is constructed using zk-SNARKs\u2019 decentralized mixed coin pool, and with the mint and pour operations it can perform in complete anonymity . Mint is the process by which a user writes a commitment to a list for a certain amount of cash. The promise must be a one-o\ufb00serial number, and the user\u2019s private key is calculated and not reversible. Similar to Bitcoin, the increase in the number of Zcash coin (ZEC) is based on mining. The ZEC obtained by a miner can be tracked and recorded, and its use also requires the signature of a private key. Therefore, if you use the ZEC directly, it is similar to Bitcoin, and you can directly complete 31 \fthe transfer between each address; however, it is currently not anonymous. The commitment made by the ZEC operation is not on the surface of the user address but depends on the public key and one one-time random number. When a user wants to spend (i.e., transfer) the ZEC, the user must provide the serial number and a commitment in the commitment list. In this way, the user can spend the ZEC without being completely exposed. The user can also use the redemption operation to extract the ZEC in the pool, the so-called redemption operation. The redemption is a commitment to return to a ZEC similar to the previous one, and the miner does not know which commitment was redeemed for the ZEC. Thus, you do not have to transfer ZEC to anyone, merely place a ZEC in the pool and redeem it; its source is untraceable. 4.1.3. Restricted Release The restriction release plan is to remove data that are directly related to privacy from the public database. Compared with the previous introduction of the mixed coin and encryption mechanisms, this type of method is completely guaranteed to ensure the security of privacy data. However, this approach has additional restrictions on business scenarios and requires additional modi\ufb01cations to the underlying protocol. Common solutions include the following: \u2022 Lightning Network and Raiden Network: The lightning network [65] enables secure out-of-chain transactions. In the lightning network, the majority of the transaction details between users are implemented o\ufb04ine. Only the \ufb01rst and last transactions must be recorded on the blockchain ledger, so it can e\ufb00ectively protect transaction privacy. The Raiden network [66] is a micropayment channel solution proposed by Ethernet. The Raiden network is directly based on the lightning network and has been developed. Because there are no speci\ufb01c \ufb01eld restrictions on the message format of the Ethernet smart contract, Raiden can introduce a single increment number for the channel balance snapshot, which solves the problem of identi\ufb01cation and invalidation of the old version snapshot. 32 \f\u2022 Consortium Blockchain and Private Blockchain: Traditional blockchain applications are mostly public blockchain, such as BTC and ETH. In the public blockchain application, anyone is free to be a member of the blockchain network. The maintenance of the transaction data makes the public blockchain application highly credible, but it also brings the threat of identity and data privacy. To better protect privacy, blockchain technology produces a branch of consortium blockchain and private blockchain. Read and write permissions are open to nodes that join the alliance in the consortium blockchain. Read and write permissions are open to one node in the private blockchain. 4.2. Data Availability Protection 4.2.1. Network Traceability Attacks Protection The blockchain runs on a network with privacy protection so that its topology can be hidden, thereby preventing exposure of identity privacy information. Onion network (Tor) [11, 12] is one of the choices. Onion network is an anonymous communication technology, which protects the privacy of message sender and receiver and hides the route of data message passing through the network. Another is Monroe [63]. In traditional digital currency, the content of the transaction output address is the receiver\u2019s public key and address information, and the observer can directly determine the coins\u2019 destination. In Monroe, the output address is the new address information obtained by the receiver\u2019s public key and the random parameter generated by the sender. 4.2.2. Eclipse Attacks Protection Some researchers proposed several ways to solve the eclipse attack attack as follows. \u2022 Restricting Access: The network node needs to be authenticated. This method can e\ufb00ectively prevent the incoming and outgoing links of the node, so that the malicious node cannot access the blockchain node [29, 33 \f30, 34, 77]. However,the approach will change the operational architecture of the blockchain. \u2022 Detecting and Blocking Malicious Nodes: The blockchain uses a malicious node detection mechanism. Dillon et al. [78] proposesd an e\ufb00ective scheme for detecting malicious nodes and \ufb01nds that malicious nodes add them to the blacklist, thereby limiting its further damage. 4.3. Data Integrity Protection 4.3.1. Double-Spending Attack Protection Karame et al. [43] analyzed that the current detection mode uses a \u201clistening period\u201d, which refers to the receiver detecting a collection of transactions after this period to determine whether double-spending exists. The problem with this approach is the attacker may delay the transmission of TRa because the neighbor node will not broadcast detected double-spending. Thus, V cannot detect double-spending attacks even after the listening period. The fewer the number of neighbor nodes of the receiving node, the higher the success rate of this attack. Another method is to insert observers into the network, which immediately notify the receiver that double-spending has been detected. Only three observers can e\ufb00ectively detect double-spending attacks, but it requires additional costs. This paper proposed a mechanism to improve transactions\u2019 forwarding function, which is to forward to the neighbor node when a doublespending attack is detected. The detection rate of this mechanism is 100%, with a false negative rate of 0%. Ru\ufb03ng et al. [79] designed a smart contract that allows payees to receive payments asynchronously and impose penalties on double-spending attackers. Eleftherios et al. proposed a new Byzantine consensus mechanism that shortend trading time by 15 to 20 seconds and used collective signatures to make transactions irreversible. George et al. [81] proposed a new decentralized cryptocurrency RSCoin, the central bank maintains complete control over the coin supply to prevent double spending. 34 \f4.3.2. Mining Attack Protection Miners attack each other during mining to reduce the other partys or overall bene\ufb01ts. Yang et al. [82] proposed to establish a game model between two miners to improve the pro\ufb01t of miners through game strategies. When a loyal miner employs a pinning strategy, it can unilaterally set the payo\ufb00of a sel\ufb01sh miner within the range of zero to r/2 \u2212c (c is the computing power and r is the expansion of pro\ufb01t), regardless of the sel\ufb01sh miner\u2019s strategy. The sel\ufb01sh miner\u2019s payo\ufb00is proportional to r but inversely proportional to c. The loyal miner cannot control his or her own payo\ufb00even with any subclass of the zerodeterminant strategy. Miller et al. [83] proposed the mining alliance mechanism, in which the members of the mining pool themselves did not trust each other, but submitted a password certi\ufb01cate to demonstrate the work they contributed. Shi [84] changed the consensus mechanism of Bitcoin, in which the value of N is established according to certain rules to ensure the continuous output rate of Bitcoin. The mechanism can improve dispersion and reduce the risk of 51% attack. Gervais et al. [18] analyzed the various parameters of PoW consensus mechanism. They designed the best countermeasures for double spending and sel\ufb01sh mining. 4.4. Data Controllability Protection 4.4.1. Logic Problems of Smart Contracts \u2022 Errors in Encoding State Machines: The contract stipulates that in the absence of a winning player, the coins should be returned to their respective accounts. In Ethereum or Bitcoin, when multiple parties send input to a smart contract simultaneously, the order of transactions in this case depends on the miner mining the new block. \u2022 Failing to Use Cryptography: Cryptography is the \ufb01rst line of defense for security protection. Application of cryptography is primarily to ensure binding and hiding. These two major attributes not only ensure that the transaction input is not tampered with but also ensure that the input 35 \finformation is not leaked. Before a message M is committed, system need to compute a number that called nonce, nonce and message M hashed. The hash value is then sent as input to the contract. \u2022 Misaligned Incentives: To ensure the correct behavior of all players, some incentives must be o\ufb00ered to ensure that players continue, regardless of winning or losing in accordance with the contract. In this scenario, a time limit can be established for the second player, and if the player submits the input before the time limit, another player will be rewarded. In addition, the game can also require both parties to pay a deposit in advance; if a player performs malicious behavior, the deposit is forfeited, bringing a loss to the player. \u2022 Ethereum-speci\ufb01c Mistakes: For the Call-stack bug, developers are advised to minimize the use of variables so that functions are as small as possible. For the Blockhash bug, Luu et al. [16] solves the blockhash bugs allowing smart contract access to more than 256 blocks For Incentive bugs. 4.4.2. Semantic Misunderstandings of Smart Contracts Luu et al. [16] proposed to modify the operation semantics of Ethernet workshops to solve the above attack vulnerabilities, for example, guarded transactions (for TOD), deterministic timestamp and improved exception handling. However, in practical applications, all Ethernet clients must be upgraded. Then, a system called OY ENTE for detecting smart contracts is proposed, which can be used to verify the problems in an intelligent contract. 4.4.3. Design Problems of Smart Contracts Luu et al. [52] proposed a consensus-based computation protocol to solve the veri\ufb01er\u2019s dilemma. They want to motivate miners to validate each transaction in each new block. If the miners did not verify the transaction in accordance with the stipulated protocol, they would receive few pro\ufb01ts, and the honest miners who veri\ufb01ed all the transactions would receive rewards that are una\ufb00ected by malicious miners. 36 \f4.4.4. Privacy-Preserving Smart Contracts \u2022 Privacy Preseration: Blockchain is a completely open database; everyone can learn about each account asset and transaction record. Hawk [53] is a decentralized smart contract system, and to avoid the transaction plaintext details exposed in blockchain, Hawk programmers write smart private contracts without the implementation of cryptography. The compiler uses an encryption protocol (such as zero knowledge proof) to make the parties interact with the blockchain. \u2022 Data Feed: Zhang et al. [54] proposed a trusted link between nonblockchain applications and smart contracts,which called Town Crier (TC). It is a trusted link between smart contracts and non-blockchain applications. TC can help CSC deal with real world crimes (such as property crimes) [85]. 5. Future Research Directions The data security issues of blockchain are crucial to the future development of blockchain. Through the understanding and thinking of the research results of many scholars, we propose several future research directions. 5.1. Data Privacy Protection Mechanism based on a Cryptology Algorithm An e\ufb00ective privacy protection scheme is to prevent an attacker from performing data analysis on the blockchain. However, this kind of scheme will change the underlying architecture of the blockchain, which is not conducive to use in the application. Therefore, it is necessary to design a scheme with high versatility. The solution should consider the computing and storage capabilities of the blockchain nodes. 5.2. Data Availability Promotion Scheme based on Demand The existing anonymous attacks are of low accuracy and high cost; they do not have the conditions for large-scale implementation, but the security threats 37 \fof the data availability are universal in the blockchain, which uses P2P as the underlying protocol of the blockchain application, causing the hidden problems. In the future, we will focus on the appropriate access control policies to limit node access and malicious node detection mechanisms to prevent information leakage. 5.3. Defenses Against PoW Attacks and New Consensus Mechanism Bitcoin\u2019s PoW consensus mechanism requires very strong computing power that have made mining by \u201cnormal users\u201d impractical. The collusion of miners or mines is very aggressive. An important research topic is methods to prevent the collusion of miners or mines. In addition, proof of stake (PoS) [86], proof of personhood [87], memory intensive [88] and consensus alliance [89] have been valued by many scholars. 5.4. Veri\ufb01cation of Smart Contracts Smart contracts often have problems with mismatch between expected and actual behavior. But the language of the veri\ufb01cation tool limits its possibilities. Non-Turing complete and human-readable languages need further research, which is a future research direction. This is mentioned in [90] [91] [92]. 6. Summary With the development of blockchain, its application is increasingly extensive, but the security of blockchain itself is gradually revealed. These problems pose a serious threat to blockchain and its application. In this survey, we created a comprehensive classi\ufb01cation and summary of the security of blockchain. First, we present classi\ufb01cation of blockchain attacks. Subsequently, we present the attacks and defenses of blockchain data in terms of the privacy, availability, integrity and controllability. Data privacy attacks present the threats of transaction and identity privacy. Data availability attacks present the threats brought by network traceability and eclipse attacks. Data integrity attacks present the 38 \fthreats brought by double-spending, sel\ufb01sh mining, and block withholding attacks. Data controllability attacks present the vulnerabilities of smart contracts. Finally, we provided several open research issues and provided some suggestions for the improvement of blockchain security." + }, + { + "url": "http://arxiv.org/abs/1809.07046v1", + "title": "Privacy-Preserving DDoS Attack Detection Using Cross-Domain Traffic in Software Defined Networks", + "abstract": "Existing distributed denial-of-service attack detection in software defined\nnetworks (SDNs) typically perform detection in a single domain. In reality,\nabnormal traffic usually affects multiple network domains. Thus, a cross-domain\nattack detection has been proposed to improve detection performance. However,\nwhen participating in detection, the domain of each SDN needs to provide a\nlarge amount of real traffic data, from which private information may be\nleaked. Existing multiparty privacy protection schemes often achieve privacy\nguarantees by sacrificing accuracy or increasing the time cost. Achieving both\nhigh accuracy and reasonable time consumption is a challenging task. In this\npaper, we propose Predis, which is a privacypreserving cross-domain attack\ndetection scheme for SDNs. Predis combines perturbation encryption and data\nencryption to protect privacy and employs a computationally simple and\nefficient algorithm k-Nearest Neighbors (kNN) as its detection algorithm. We\nalso improve kNN to achieve better efficiency. Via theoretical analysis and\nextensive simulations, we demonstrate that Predis is capable of achieving\nefficient and accurate attack detection while securing sensitive information of\neach domain.", + "authors": "Liehuang Zhu, Xiangyun Tang, Meng Shen, Xiaojiang Du, Mohsen Guizani", + "published": "2018-09-19", + "updated": "2018-09-19", + "primary_cat": "cs.NI", + "cats": [ + "cs.NI" + ], + "main_content": "INTRODUCTION Software-De\ufb01ned Networks (SDNs) have emerged as a new networking paradigm, which is liberated from the vertical integration in traditional networks and gives the program and the network their \ufb02exibility through a centralized logical network controller [1]. SDNs consists of the data plane, the control plane and the application plane. The control plane contains some controllers that run the control logic strategy and maintains the entire network view as a logiccentric. The controllers abstract the whole network view into network services and provide the easy-to-use interface for operators, researchers or third parties to facilitate these personnel to customize the privatization applications and realize the logical management of the network. Users of the SDNs don\u2019t need to worry about the technical details of the underlying device, just a simple programming can realize the rapid deployment of new applications. SDNs simplify the network management and adapt better to the current situation in which the network size continues to expand rapidly. However the features of the centralized control and programming make SDNs susceptible to the well-known Distributed Denial-of-Service (DDoS) attacks. For instance, the controller, which plays a crucial role in determining the functionality of each component in SDNs, is a main target of DDoS attacks [1]. A compromised controller would result in paralyzation or misbehaving of all switches under its control. Denial of service (DoS) attack can run out of the resources of a system on the target computer, stop services and leave its normal users inaccessible. When hackers use two or more compromised computers on the network as \u201dpuppet machine\u201d to launch DoS attacks on a speci\ufb01c target, it is referred to as DDoS attacks. The puppet machine\u2019s IP address and the structure and form of attack packet is random, making it dif\ufb01cult to trace the the attacker. DDoS attacks have become a severe threat to today\u2019s Internet and the attacks make online services unavailable by overwhelming victims with traf\ufb01c from multiple attackers. With the number of businesses migrating their operations online growing dramatically, DDoS attacks can lead to signi\ufb01cant \ufb01nancial losses. A recent report reveals that DDoS attacks account for 22% of the 2015 data center downtime [2]. DDoS attacks essentially operate in three steps [3], i.e., scanning, intrusion, and attack launching. Abnormal traf\ufb01c of DDoS attacks usually affects multiple paths and network domains (e.g., SDNs domains). For ease of illustration, we analyze the stages of typical DDoS attacks using \f3 TABLE I ANALYSIS OF LLDOS DATASET The Number of Flows Stage 172.16.112.* 172.16.113.* 172.16.114.* 172.16.115.* Victim Attacker Merge Scanning 424 328 32 296 0 1081 1081 Intrusion 128 0 97 0 0 332 335 Attacking 2 0 0 285 107465 199 107667 the datasets collected by the Lincoln Laboratory of MIT [4], LLDOS 1.0, as shown in Table I. Prior to the launch of the attack, abnormal traf\ufb01c can be observed at the stages of scanning and intrusion. If the victim and the puppet machines under DDoS attacks were located in different network domains, a detection attempt restricted within a single domain would be unable to identify the attacks at their primary stages. Thus, the involvement of multiple domains in attacks detection will help to achieve more accurate and timely detections [5], [6]. In the SDNs environment, the collaborative detection across multiple domains requires detailed traf\ufb01c data of each domain involved, such as the content of the \ufb02ow table in the latest seconds. However this may cause serious privacy concerns on the SDNs operators, as the traf\ufb01c data reveals sensitive information, such as source IP addresses, destination IP addresses, and traf\ufb01c statistics [7], which have potential utility in mining network topology and network connection behaviors [8]\u2013[10]; Accordingly, SDNs operators are reluctant to share their detailed intra-domain traf\ufb01c data with each other. Therefore, trade-offs between attacks detection ef\ufb01ciency and privacy protection should be carefully balanced in SDNs. Many schemes of DDoS attacks detection in traditional networks have been proposed and have showed satisfying results [11]\u2013[17]. Extensive studies on DDoS attacks in SDNs have also been done and many traf\ufb01c classi\ufb01ers with excellent performance have been proposed (e.g., graphic model [18], the entropy variation of the destination IP address [19], Support Vector Machine (SVM) [20]). While these DDoS attacks detection schemes are usually restricted to a single domain [21], very few studies have considered cross-domain attacks detection. Bian et al. [22] proposed a scheme for cross-domain DDoS attacks detection in SDNs using Selforganizing Map (SOM) as the traf\ufb01c classi\ufb01er. The calculation in the training and the test phase is very complicated when SOM as the classi\ufb01er which requires multiple vector multiplications, or more complex divition. Secure Multi-party Computation (SMC) [23], [24] may enable secure \f4 cross-domain anomaly detection (e.g., secure addition protocol, secure multiplication protocol and secure compare protocol). However, these protocols require a large amount of interaction from the participants and calculations on ciphertext, which undoubtedly consumes many of the controller\u2019s bandwidth. Cross-domain attacks detection will lead to privacy leakage, whereas the introduction of privacy protection usually comes at a cost of excessive time consumption and low detection rate. We should address these challenges when detecting DDoS attacks in cross-domain. The \ufb01rst challenge is how to conduct cross-domain DDoS attacks detection in SDNs without revealing privacy of each network domain. Anomaly detection classi\ufb01ers require detailed traf\ufb01c data, and SDNs domains do not trust each other. It is necessary that we work out the privacy issue when multiple SDNs domains work together to perform anomaly detection. The second challenge is to ensure ef\ufb01cient and accurate DDoS attacks detection while well-preserving privacy. Strong privacy protection in multi-party cooperation is often at the cost of accuracy and high timeconsumption, and it is hard to give priority to one or the other. In the face of these dilemmas, we resort to decoupling the detection into two steps, disturbance and detection and, introducing two servers that work in collaboration to complete the detection process. We combine digital cryptography with perturbation encryption to address the \ufb01rst challenge. Transport Layer Security (TLS) is used to protect the privacy in data transmission process between two servers and SDNs controllers, and perturbation encryption to protect that privacy is not compromised when calculating on the two servers. The ciphertext produced by perturbation encryption, since the special design of Predis, can be compute directly in servers without the need to use complex security computing protocols. With respect to the second challenge, we use the features of k-Nearest Neighbor (kNN) of calculate simple, decoupling the kNN algorithm into two steps and embedding the encryption steps into it. After giving the training data, kNN can classify the test samples by choosing a distance measurement formula without a training phase (Euclidean distance1 is selected in Predis). The kNN\u2019s features of easy to implement is very useful for us when we want to embed some special operations into the classi\ufb01er to protect the privacy of test data. On the other hand, kNN, as a classi\ufb01cation algorithm, has excellent performance in accuracy, and kNN is not sensitive to outliers which can maintain high accuracy when there are some noises in dataset. 1The formula of European distance of n-dimensional vector is d = qPn i=1 (xi1 \u2212x2i)2. \f5 kNN as the classi\ufb01er with high accuracy has been widely used in many different areas [25]\u2013[27]. Our contributions are summarized as follows: 1) We propose Predis, a privacy-preserving cross-domain DDoS attacks detection scheme for SDNs, which considers both the cross-domain DDoS attacks detection and the privacy protection in multi-party cooperation. Predis uses the features of SDNs and the improved kNN algorithm to detect DDoS attacks accurately within effective time, and combines the digital cryptography with perturbation encryption to provide the con\ufb01dentiality and every participant\u2019s privacy. 2) We prove the security of Predis by the asymptotic approach of computational security in modern cryptography. Through rigorous security analysis, we prove that the traf\ufb01c data provided by each participant is indistinguishable for potential adversary. 3) We conduct extensive experiments using multiple authoritative datasets to demonstrate the timeliness and accuracy of Predis. We show that our scheme not only can determine if the traf\ufb01c is abnormal, but also can \ufb01nd abnormal traf\ufb01c at the early stages of DDoS attacks. Results show that Predis is more accurate than existing detection schemes, meanwhile protecting participants\u2019 privacy. The rest of the paper is organized as follows. We review the related work in Section II and introduce the thread model and security goals in Section III. We introduce the improved kNN algorithm in Section IV and describe the design of Predis as well as the concrete calculation steps and encryption details in Section V. We present the security analysis in Section VI and the experimental results in Section VII. We conclude this paper in Section IX. II. RELATED WORK A. Background of DDoS Attacks DDoS attackers can simultaneously control several computers and create an attack architecture that contains control puppets and attack puppets [3], as shown in Figure 1. The traditional attack architecture is analogous to a dumbbell-shaped structure, where an intermediate network is only responsible for data forwarding and security events and control functions are entirely done by management, while the network itself does not have the ability to detect and deal with network attacks. \f6 Fig. 1. A typical structure of DDoS Attacks B. Summary of DDoS Attacks Detection Methods There are numerous studies on DDoS attacks detection because of the severity and prevalence of DDoS attacks. Here we brie\ufb02y summarize the related work from two perspectives, i.e., DDoS attacks detection in conventional networks and DDoS attacks detection in SDNs, as listed in Table II. Detection in conventional networks. Detection approaches of DDoS attacks have been studied extensively in conventional networks, where methods such as Entropy based [12], SVM [13], Naive Bayesian [15], Neural Network [16], cluster analysis [17], Arti\ufb01cial Neural Network (ANN) [14], and kNN [11] are used as classi\ufb01ers. Detection in SDNs. The SDNs controller collects information of \ufb02ow table and uses selected classi\ufb01ers to classify network traf\ufb01c \ufb02ows as either normal or abnormal. Based on the capability of logical centralized controller and programmability of the network, network administrators can respond to the attacks immediately. Classic classi\ufb01cation methods of Bayesian Networks [28] and SVM [20], as well as neural networks of SOM [22], [29], [30] and Deep Learning [31] are used as traf\ufb01c classi\ufb01ers in SDNs. The methods proposed above except Bian et al. not considered cross-domain attacks detection, naturally they didn\u2019t consider the privacy protection, and these methods require complex calculations like vector multiplications, or more complex vector division during the testing phase \f7 TABLE II SUMMARY OF EXISTING DDOS ATTACKS DETECTION METHODS Network Environment Classi\ufb01ers Reference Conventional Network Entropy based David et al. [12] Support Vector Machine Yusof et al. [13] Naive Bayesian Singh et al. [15] Neural network Hsieh et al. [16] Cluster analysis Wei et al. [17] Arti\ufb01cial Neural Network Saied et al. [14] k-Nearest Neighbor Thwe et al. [11] SDNs Self-organizing map Braga et al. [30] Xu et al. [29] Bian et al. [22] Support Vector Machine Kokila et al. [20] Entropy variation of the destination IP address Mousavi et al. [19] Deep Learning Niyaz et al. [31] Bayesian Networks Nanda et al. [28] (e.g., the calculation formula of Naive Bayesian is f (x) = Qd i=1 p (xi|y)2). If these methods are conducted directly for cross-domain attacks detection, secure computation protocols will be needed to solve the privacy protection. Predis not only protects the privacy but also avoids the extensive interactions and calculations that are required when using secure computing protocols. Bian et al. [22] considered both cross-domain DDoS attacks detection and privacy protection. They proposed a privacy-preserving cross-domain detection scheme, using SOM as classi\ufb01er. But their method has major complications if it came to computations, i.e., the time complexity of training a neural network and test should be O(mn2) and O(n2), respectively, where n is the number of neurons and m is the number of training samples. The time complexity of our method in the testing phase is O(m), and as a type of instance-based learning (or lazy learning), kNN don\u2019t has training phase. In addition, they failed to consider detecting DDoS attacks at their early stages. We attempt to \ufb01nd anomaly at the early stages of DDoS attacks, because if we \ufb01nd anomaly before the stage of attacking, we can take countermeasures (e.g., by blocking ingress traf\ufb01c with certain attack characteristics) to avoid further losses. However, this importance has 2x is the test instance, d is the dimensions of test instance and y is the class mark. \f8 hardly been realized by most of the prior studies. Mousavi et al. [19] proposed a method to detect DDoS attacks in SDNs, which claims that it can detect DDoS attacks within the \ufb01rst \ufb01ve-hundred packets of the attack traf\ufb01c. Given that if puppet machines and the victim were in different SDNs domains, traf\ufb01c will not be re\ufb02ected as being abnormal. C. Privacy-preserving in Cross-domain Detection A SDNs domain in Predis refers to a controlled domain under SDNs architecture, which is a network domain with the deployment of the SDNs techniques and can be independently controlled by operators. The SDNs domains conduct centralized control of data forwarding. The multiple SDNs domains described in our article collaborate and these SDNs domains may or may not be adjacent at physical or geographical location. The control plane of SDNs domains centralized sends \ufb02ow table to a speci\ufb01ed location (i.e. computing server). The computing server provides the DDOS detection service and return detection results controllers. Traditional network domains for traf\ufb01c forwarding is a distributed control, it can\u2019t achieve centralized control. Privacy-preserving cross-domain attacks detection can be see as a Secure Multi-Party Computation (SMC) problem [32], which is the matter of how to safely calculate a function when no credible third party is present. There are a hit research subject [33]\u2013[36] about it. Chen et al. [37] present a cryptographic protocol specially devised for privacy-preserving cross-domain routing optimization in SDNs. But these methods do not apply to the problem of cross-domain attacks detection. Martin et al. [38] investigated the practical usefulness of solutions based on SMC, having designed optimized secure multiparty computation operations that ran ef\ufb01ciently on voluminous input data. Their method may provide a new insight into the problem in this paper, but their application scenarios are not exactly the same as ours. Predis uses the kNN algorithm as the classi\ufb01er to perform DDoS attacks detection. The kNN technique has been employed to solve privacy-preserving problems before, and there are already several eminent secure kNN protocols. Wong et al. [39] proposed ASPE, a protocol which preserved a special type of scalar product, and constructed two secure schemes that supported kNN computation on encrypted data. Elmehdwi et al. [40] set up SkNN, which provided better security in solving the kNN query problem over encrypted database outsourced to a cloud. Cao et al. [41] proposed MRSE, which de\ufb01ned and solved the problem of multi-keyword ranked search over encrypted cloud data. These secure kNN protocols focus on applying kNN to querying over encrypted data. Secure kNN does inspire us in some ways the problem to be dealt with is DDoS \f9 attacks detection, which demands a higher accuracy and an immediate response and is different to the querying problem over encrypted data. Comparing with previous studies about DDoS attacks detection, Predis not only considers detecting DDoS attacks over multiple domains with privacy-preserving, but also attempts to detect DDoS attacks at the early stages. III. SYSTEM MODEL AND THREAT MODEL In this section, we \ufb01rst describe the overview of the system model and the roles involved in Predis. Then, we present the thread model, followed by the security goals. A. System Model Predis mainly contains three types of roles: Computing Server (CS), Detection Server (DS) and SDNs domains3, as exhibited in Figure 2(a). Domain Dn is the n-th domain who participates in attacks detection and provides data to CS and DS, which, in turn, provide computing and encryption services for domain Dn. The system sequence diagram is shown in Figure 2(b). Each domain sends traf\ufb01c information to CS for calculation and receives the detection results from DS. CS provides computing service and sends the intermediate results to DS, where the latter provides detection service based on the intermediate results and replies the detection results to each domain. Thus, CS and DS perform computation in collaboration with one another. The details of how computing and encryption work in CS and DS will be described later in Section V. Predis provides accurate DDoS attacks detection service for domains, where each domain is unwilling to share privacy traf\ufb01c information. Here, we give a formal de\ufb01nition of privacy as follows: De\ufb01nition 1: (Privacy). The information of \ufb02ow table is provided by domains that participate in the detection. Speci\ufb01cally, privacy includes IP Source, IP Destination, Port Source, Port Destination, Length, and Flow Packets. We de\ufb01ne the basic operations in Predis of the three roles mentioned above as three functions with input and output. Each function is designed to run on continuous inputs in real time of data partitioned into a certain time interval. Predis has a set of n input peers. Input peers 3Hereafter we refer to domains as SDNs domains unless otherwise stated. \f10 (a) System Overview (b) System Sequence Chart Fig. 2. Privacy-preserving Cross-domain Attacks Detection Scheme Schematic Diagram. want to jointly compute the \ufb01nal result of Predis on their private data without the slightest relevant disclosure. Predis has m players called privacy peers that perform the computation of Predis by simulating a trusted third party (TTP) [38]. Domains are both input peers and privacy peers, while CS and DS are privacy peers. B. Threat Model We abstract the corss-domain privacy-preserving DDoS attacks detection problem with a threat model. In the thread model, there are two types of adversaries, namely the external adversary and the semi-honest adversary. External adversary. Adversaries that through Internet eavesdropping or data interception and other means to illegally obtain the data in the transmission process for their purposes. Semi-honest adversary. A curious participant who follows the protocol properly to ful\ufb01ll service functions, but tries its best to infer sensitive or private information from intermediate results of calculation, or even colludes with other participants. Privacy peers will set up a secure, con\ufb01dential and authentic channel connecting each other to resist the external adversary. In Predis, we use TLS to build this secure channel. We adopt the semi-honest assumption for all privacy peers. Honest privacy peers follow the protocol and do not combine their information. Semi-honest privacy peers do follow the protocol but try to infer input peers\u2019 privacy as much as possible from the values they learn, and also by combining their \f11 information. Domains are hoping to get the correct results of attacks detection. While following the right steps, some domains may try to infer other domains\u2019 privacy for certain purpose. CS and DS will provide the right calculation service, but may use the intermediate results generated by intermediate steps in calculation to infer and spy privacy from domains. We assume that all privacy peers have the potential to be external adversary through eavesdropping or other methods to illegally obtain input peers\u2019 privacy. In addition to the roles included in this program, any other external eavesdropper is also the adversary we need to tackle. C. Security Goal The purpose of this paper is to obtain accurate cross-domain DDoS attacks detection results under the premise of privacy protection. Privacy peers may steal privacy as the external adversaries or the semi-honest adversaries. Furthermore, privacy peers may collude with each other. In our solution, we allow one or more domains to collude with each other, with CS, and with DS. Based on these, we make the following assumptions: 1) Each domain performs function honestly but may have interest in the private information of other domains. 2) CS or DS performs calculation process correctly but may have interest in obtaining domains\u2019 private information. 3) CS or DS may collude with one or more domains. Semi-honest privacy peers do follow the protocol but try to infer peers\u2019 privacy as much as possible from the values they learn. Thus, CS or DS may collude with one or more domains. 4) CS and DS do not collude with each other. In reality, DS and CS can be deployed by different operators. Operators are likely to have con\ufb02ict of interests, so it is assumed that CS does not collude with DS. Before describing our security goals, we introduce a security de\ufb01nition (i.e., De\ufb01nition 2), an adversarial indistinguishability experiment PrivKA\u00b7\u03c0 (n) as shown in Table III, and a de\ufb01nition about negligible (i.e., De\ufb01nition 3) for a probabilistic polynomial-time (PPT) adversary (A) [42]. De\ufb01nition 2: (Indistinguishability). A private-key encryption scheme \u03a0 = (Gen, Enc, Dec) has indistinguishable encryptions under an attack, if for all PPT adversaries A there is a negligible function \u03b5 such that Pr [PrivKA\u00b7\u03c0 (n) = 1] = 1 2 + \u03b5(n), where the probability is taken over the randomness used by A, as well as the randomness used in the experiment. \f12 TABLE III INDISTINGUISHABILITY EXPERIMENT PrivKA\u00b7\u03c0 (n) The indistinguishability experiment PrivKA\u00b7\u03c0 (n): 1. A key k is generated by running Gen (1n). 2. The adversary A is given input 1n, and outputs a pair of messages m0, m1 of the same length. 3. A uniform bit b \u2208{0, 1} is chosen, and then a ciphertext c \u2190Enc (mb) is computed and given to A. 4. A outputs a bit b\u2032. 5. The output of the experiment is de\ufb01ned to be 1 if b\u2032 = b, and 0 otherwise. In the former case, we say that A succeeds. De\ufb01nition 3: (Negligible). A function f from the natural numbers to the nonnegative real numbers is negligible if for every positive polynomial p there is an N such that for all integers n > N it holds that f (n) < 1 p (n). We aim at achieving the security objective of keeping privacy of each domain. We specify our security goals as follows: 1) For CS and DS, input peers privacy is protected. 2) For domains, other input peers\u2019 privacy is protected. IV. CLASSIFICATION METHOD To adapt to the proposed privacy protection scheme, we design a classi\ufb01er by the kNN algorithm, decoupling it into two steps and embedding the encryption steps into it. In this section, we will introduce the details of how traf\ufb01c classi\ufb01cation is carried out. A. Improved kNN as Classi\ufb01er In general, kNN is implemented by linear scanning [43]. In linear scanning, we need calculate every distance between the test data and training data, and than sort and \ufb01nd the nearest k instances. When the training dataset is very large, the computation will be very time-consuming. KD-tree is a balanced binary tree that divides the entire attribute space into speci\ufb01c d parts according to the number of attributes of the dataset, and then carries out relevant query operations in a speci\ufb01c space. Best Bin First (BBF) is an optimization algorithm for querying on the KDtree, the main idea of which is to sort the nodes in the \u201dquerying path\u201d, and the retroactive checking is always performed from the best-priority tree node. Using KD-Tree to store training \f13 Algorithm 1 Improved kNN Algorithm Input: Training datasets Dt, test instance t, timeout limit L. Output: Detection result y. 1: Building KD-tree based on the dimensions of training data in CS. 2: calculating the preliminary results from the ordered training data in CS. 3: Removing the perturbation from preliminary results to get the correct distance in DS. 4: t as the root is added into traversal queue. 5: Initializing a queue Qk. 6: while traversal queue is not null and (L! = 0) do 7: node \u2190traversal queue\u2019 top. 8: Get the distance between node and t distance. 9: if distance < Qk\u2019s top then 10: remove Qk\u2019s top. 11: Insert node to Qk. 12: if node\u2019s n-th dimension\u2019s value \u2266t\u2019s n-th dimension\u2019s value then 13: node\u2019s left children enters traversal queue. 14: traverse right subtree. 15: else 16: node\u2019s right children enters traversal queue. 17: traverse left subtree. 18: Getting the detection result y by queue Qk. 19: return y. dataset and searching with BBF not only don\u2019t need to calculate every distance between test data and training data, but also improve the ef\ufb01ciency. Readers interested in KD-Tree or BBF can read literature [44], because these are not the focus of Predis, we don\u2019t detail describe it here. In Section III, we have introduced the system model where CS has the training dataset, and DS provides detection service. So, we decoupled kNN into two steps: In the \ufb01rst step, CS builds a KD-tree based on the training dataset, and calculates the preliminary results of the distance between the test data and the ordered training data. The second step, DS gets the preliminary results and \ufb01nds the nearest k instances by using BBF. The time complexity of kNN with linear scan is O (n log k), and with BBF the time complexity is O(n). When the dataset is large, the time consumption shorten by BBF is very impressive. Main steps are shown in Algorithm 1. B. Feature Selection The proposed DDoS attacks detection scheme is based on the \ufb02ow table obtained from SDNs controllers. As there are a lot of redundant information inside, which affects not only the detection \f14 ef\ufb01ciency but also the results, we extract feature information from the \ufb02ow table. Normal traf\ufb01c is generally interactive because the purpose of it is to obtain or provide services, but the number of ports and source IP addresses will increase signi\ufb01cantly when DDoS attacks occur. One of the other features of a DDoS attacks is source IP spoo\ufb01ng, which usually results in a lot of traf\ufb01c with a small number of packets with a small number of bytes. Normal \ufb02ow usually has many packets, and the number of \ufb02ow\u2019s bytes is larger. So we calculate the median of packets per \ufb02ow and bytes per \ufb02ow to reinforce this feature instead of the mean, because the mean is possible to smooth this feature. To quantify these characteristics, \ufb01ve parameters are used in the feature selection module, including MPF, MBF, PCF, GOP and GSI, which are elaborated as follows: 1) Median of Packets per Flow (MPF), which describes the number of packets\u2019 median in every n \ufb02ows. We rank the \ufb02ows X = {X1, X2, . . . , Xn} in ascending order based on the number of packets per \ufb02ow, and then compute the median value according to Formula (1). M (X) = \uf8f1 \uf8f4 \uf8f2 \uf8f4 \uf8f3 X(n+1)/2, n is odd; X(n/2) + X(n/2+1) 2 , otherwise. (1) 2) Median of Bytes per Flow (MBF), which describes the number of bytes\u2019 median in every n \ufb02ows. We rank the \ufb02ows in ascending order based on the number of bytes per \ufb02ow, and then compute the median value. 3) Percentage of Correlative Flow (PCF), which describes the number of \ufb02ows with interactive features in every n \ufb02ows. We de\ufb01ne \ufb02ow X as X = (srcIP = A, dstIP = B) and \ufb02ow Y as Y = (srcIP = B, dstIP = A), where X and Y use the same protocol. PCF = inactN/n, where inactN is the number of X in addition to the number of Y . 4) Growth of Ports (GOP), which describes the growth rate of the number of ports within a \ufb01xed time. GOP = portN/t, where t is the \ufb01xed time interval and portN is the number of port growth. 5) Growth of Source IP Addresses (GSI), which describes the growth rate of the number of source IP addresses within one \ufb01xed time. GSI = srcIPN/t, where srcIPN is the number of source IP addresses growth. V. PRIVACY-PRESERVING CROSS-DOMAIN ATTACKS DETECTION SCHEME In this section, we describe the work\ufb02ow of Predis and detail the processes of how to combine privacy protection in DDoS attacks detection. \f15 Algorithm 2 Traf\ufb01c Pretreatment in Each SDNs Domain Input: Traf\ufb01c data of \ufb02ow table. Output: Ciphertext passed to DS CDS, ciphertext passed to CS CCS. 1: Initialize seven tuple set T by feature selection module\u2019s formula and traf\ufb01c data of \ufb02ow table. 2: while 1 do 3: for \u2200t \u2208T do 4: for i \u21900 < 6 do 5: Random generation disturbance parameter r = {0, 1}231. 6: \u2206ti = ti + r. 7: for \u2200\u2206t \u2208\u2206T do 8: CCS \u2190Encskc (\u2206t). 9: for \u2200r\u2208R do 10: CDS \u2190Encskd (r). 11: return CDS to DS. 12: return CCS to CS. A. Encryption in Data Transmission Process To avoid traf\ufb01c data being leaked in transmission process, we leverage the TLS [45]. TLS is a security protocol that provide secure connections between two applications to communicate across a network to exchange data and is designed to prevent eavesdropping and tampering. Before the application layer protocol communication, TLS protocol has completed the encryption algorithm, the communication key agreement and server authentication. Application layer protocol can be created transparently on the TLS protocol. TLS consists of three basic steps: The client asks and veri\ufb01es the public key to the server; Both parties negotiate to generate session key; Both parties use the session key for encrypted communications. TLS for information transfer across a network is considered safe and reliable up to now. B. Traf\ufb01c Pretreatment in Domains In traf\ufb01c pretreatment, domains need collect traf\ufb01c and abstract each piece of traf\ufb01c information as a seven tuple, followed by generating perturbation parameter respectively. The obtained seven tuple is encrypted by the perturbation parameter. Ultimately, domains transmit the encrypted seven tuple to CS, the perturbation parameter to DS, as shown in Algorithm 2. Domains collect and transmit traf\ufb01c information every 3 seconds, since an overly long interval would cause the network paralyzed before the attacks are detected, while an overly short one \f16 (a) SDNs Flow Table Content (b) Traf\ufb01c Pretreatment Fig. 3. The Format of SDNs Flow Table and Traf\ufb01c Pretreatment. would make the resource utilization of detection module too high to handle other requests in the controller, which can cause heavy load on the link between the controller and its switches. As mentioned in Section IV-B, the information needed in detection are source IP, destination IP, source port, destination port, \ufb02ow bytes, and \ufb02ow packets. Domains go through the process written in the \ufb02ow table with the equations described in Section IV-B and calculate the MPF, MBF, PCF, GOP and GSI. We de\ufb01ne a seven tuple as \u27e8Serial Number, Time, MPF, MBF, PCF, GOP and GSI \u27e9. The functions of Serial Number and Time are similar to the primary key in relational database. It is a label that uniquely identi\ufb01es this \ufb02ow table item generated by domains. In experiments we set the Serial Number as number n for n-th domain participating in detection, and Time as the timestamp of the \ufb02ow table item. Each attribute in the seven tuple is stored as a binary of 33 bits (we add an additional bit as an over\ufb02ow \ufb02ag), and the total length of the seven tuple is 231 bits. Attributes less than 33 bits will be \ufb01lled with 0 in front. In each domain, the disturbance parameter is added to the seven tuple. Using the TLS, domains securely deliver the encrypted seven tuple to CS, and, the disturbance parameter to DS. Flow table content is shown in Figure 3(a) and the schematic diagram of the traf\ufb01c pretreatment in domains is shown in Figure 3(b). C. Preliminary Calculation in CS Upon receiving the encrypted seven tuple, CS calculates preliminary seven tuple used for attacks detection. Then, CS sends the results to DS by using TLS. \f17 (a) Preliminary Calculation in CS (b) Attacks Detection in DS Fig. 4. Schematic Diagram of Preliminary Calculation and Attacks Detection. Algorithm 3 Preliminary Calculation in CS Input: Training data Dt, set of encrypted seven tuple \u25b3T. Output: CDS. 1: while 1 do 2: for \u2200t \u2208T do 3: for \u2200dt \u2208Dt do 4: PreR = Dt \u2212t. 5: for \u2200preR \u2208PreR do 6: CDS \u2190Encskc (preR). 7: return CDS to DS. The calculation process in CS is exhibited in Algorithm 3. Predis employs the kNN for attacks detection, computing distance is thus an important step. We calculate the preliminary results of the distance between the test data and the training data. CS calculates preliminary results in the received encrypted seven tuple directly and obtains the distance between the disturbance data and the training data. We leave the work of removal of the perturbation and get the exact result of distance to DS. The schematic diagram is shown in Figure 4(a). D. Attacks Detection in DS The attacks detection process in DS is abstracted in Figure 4(b) and exhibited in Algorithm 4. Upon receiving domains\u2019 perturbation parameters and CS\u2019s preliminary results of the distance, DS removes the perturbation from preliminary results to get the correct distance. The improved kNN uses the correct distance to get correct detection results. Finally, if the classi\ufb01er \ufb01nds DDoS attacks, DS will returns the alarm (Serial Number and Time) to domains. Domains\u2019 operator \f18 Algorithm 4 Attacks Detection in DS Input: Seven tuple of preliminary calculation\u2019s result PreR, perturbation parameter R. Output: Alarm from detection A. 1: while 1 do 2: for \u2200preR \u2208PreR do 3: for \u2200r \u2208R do 4: fanlR = preR \u2212r. 5: Doing attacks detection by using FanlR. 6: get the detection result A by Algorithm 1. 7: return A to domains. will respond appropriately after receiving an alarm. The calculation results of CS are training data Dt minus the perturbed seven tuple \u2206T (Dt \u2212 \u2206T). Since DS has the perturbation parameters R, it can get the correct distance for attacks detection by using the perturbation parameters with the calculation results of CS (Dt \u2212\u2206T \u2212R) subtracted. Finally, the improved kNN calculates the results of DDoS attacks detection. VI. SECURITY ANALYSIS As described in Section III-C, our security goal is to protect the privacy of each input peers. Predis uses TLS to protect privacy in data transmission process. TLS is generally accepted as secure for data transfer across a network. Besides the correct data receiver, any external eavesdropper cannot eavesdropping and tampering data. Therefor, we don\u2019t analysis the security of TLS here. A scheme is secure if any PPT adversary succeeds in breaking the scheme with at most negligible probability [42]. In other words, PPT adversary succeeds in the indistinguishable experiment which is showed in Table III with at most negligible probability, we could say that the scheme is secure. It is the Asymptotic Approach in model cryptography to prove the security of a scheme and we use this idea in the following. In this section, we would use the idea of the Asymptotic Approach and present the proofs by showing the indistinguishability in the following two situations. That is, for CS and DS, input peers\u2019 private information is indistinguishable, and for domains, other input peers\u2019 private information is indistinguishable. Before formal security analysis, we \ufb01rst set out the meaning of each representation: T is private information mentioned in Section III-C; \u25b3T is the set of encrypted T; R is the disturbance \f19 parameter of each domains; PreR is preliminary calculation\u2019s result output by CS. As for domains, what the legal data domains have is their own data and detection result. When they try to gain privacy from others, such as when through means of external eavesdropper, privacy is indistinguishable. As for CS, the legal data it has is \u25b3T = T + R. We construct an encryption scheme \u03a0CS as shown in Table IV. We give a theorem (Theorem 1) for it and prove it. If CS does not collude with domains, it is merely a ciphertext-only eavesdropping adversary at this point. If CS colludes with one or more domains, this attack would be a chosen-plaintext attack (CPA) in construction \u03a0CS\u2019 s encryption scheme. In a ciphertext-only attack, the only thing the adversary needs to do is eavesdrop on the public communication channel over which encrypted messages are sent [42]. In the chosen-plaintext attack the adversary is assumed to be able to obtain encryptions and/or decryptions of plaintexts/ciphertexts of its choice [42]. Chosen-plaintext adversary has more useful information than the ciphertext-only adversary, and chosen-plaintext adversary is harder to prevent than the ciphertext-only adversary. When we stopped the chosen-plaintext adversary, we can stopped the ciphertext-only adversary. By Proof 1, we demonstrate Construction \u03a0CS is a CPA-secure private-key encryption scheme for messages of length l. Thus, input peers\u2019 private information is indistinguishable for CS. Theorem 1: If G is a pseudorandom function, then Construction \u03a0CS is a CPA-secure privatekey encryption scheme for messages of length l. Proof 1: Let \u03a0 = (Gen, Enc, Dec) be an encryption scheme that is exactly the same as \u03a0CS, except that a truly random function g is used in place of Gk. Fix an arbitrary ppt adversary A, and let q(n) be an upper bound on the number of queries that A (1n) makes to its encryption oracle. We show that there is a negligible function \u03b5(n) as follow and prove this by reduction. \f \f \fPr \u0002 PrivKcpa A\u00b7\u03a0CS (n) = 1 \u0003 \u2212Pr h PrivKcpa A\u00b7\u03a0CS (n) = 1 i\f \f \f = \u03b5(n) (2) We use A to construct a distinguisher D for the pseudorandom function G. The distinguisher D is given oracle access to some function O, and its goal is to determine whether this function is \u201cpseudorandom\u201d (i.e., equal to Gk for uniform k \u2208{0, 1}n or \u201crandom\u201d). To do this, D emulates experiment PrivKcpa for A in the manner described below, and observes whether A succeeds or not. If A succeeds then D guesses that its oracle must be a pseudorandom function, whereas if A does not succeed then D guesses that its oracle must be a random function. D runs in polynomial time since A does. The key points are as follows: \f20 TABLE IV CONSTRUCTION OF \u03a0CS Let G be a pseudorandom function. De\ufb01ne a private-key encryption scheme for messages of length l. Gen: on input 1n, choose uniform K \u2208{0, 1}n and output it. Enc: on input a key K \u2208{0, 1}n and a massage m \u2208{0, 1}l(n), output the ciphertext. C := \u27e8r, G(K) + m\u27e9 Dec: on input a key K \u2208{0, 1}n and a ciphertext c \u2208{0, 1}l(n), output the plaintext message. M := \u27e8G(K) \u2212s\u27e9 If D\u2019s oracle is a pseudorandom function, then the view of A when running as a subroutine by D is distributed identically to the view of A in experiment PrivKcpa A\u00b7\u03a0CS (n). This is because, in this case, a key k is chosen uniformly at random and then every encryption is carried out by choosing a uniform r, and setting the ciphertext equal to \u27e8r, G(K) + m\u27e9, exactly as in Construction \u03a0CS. If D\u2019s oracle is a random function, then the view of A when running as a subroutine by D is distributed identically to the view of A in experiment PrivKcpa A\u00b7\u03a0CS (n). This can be seen exactly as above, with the only difference being that a uniform function is used instead of Gk. Pr [C = c|M = m] = Pr [M + K = c|M = m] = Pr [m + K = c] = Pr [K = c \u2212m] = 1 2l (3) Through Formula (3), we know Pr h PrivKcpa A\u00b7\u03a0CS (n) = 1 i = 1 2. Combining the above and the assumption that G is a pseudorandom function, there exists a negligible function \u03b5(n) for which Pr \u0002 PrivKCS A\u00b7\u03a0CS (n) = 1 \u0003 = 1 2 +\u03b5(n). From the De\ufb01nition 2, we have proved Construction \u03a0CS is a CPA-secure private-key encryption scheme for messages of length l. \u25a0 As for DS, the legal data it has is R and PreR. Since PreR = Dt\u2212\u25b3T and \u25b3T = T +R, DS has legal data Dt \u2212T. We construct an encryption scheme \u03a0DS as shown in Table V. If DS does not collude with one or more domains, it is a ciphertext-only eavesdropping adversary at this point for encryption scheme \u03a0DS. If DS colludes with one or more domains: having no other CS\u2019s private key, they would be unable to get other input peers\u2019 \u25b3T. DS owns perturbation parameter PreR. Therefore, this situation is CPA-secure in encryption scheme \u03a0DS, which \f21 TABLE V CONSTRUCTION OF \u03a0DS Gen: choose K \u2208{0, 1}n and output it. Enc: on input a key K \u2208{0, 1}n and a massage m \u2208{0, 1}l(n), output the ciphertext. C := \u27e8K \u2212m\u27e9 Dec: on input a key K \u2208{0, 1}n and a ciphertext c \u2208{0, 1}l(n), output the plaintext message. M := \u27e8K \u2212s\u27e9 is stated in Theorem 2. By Proof 2, we demonstrate that input peers\u2019 private information is indistinguishable for DS. Theorem 2: The encryption scheme \u03a0DS is a CPA-secure private-key encryption scheme for messages of length l. Proof 2: Through Formula (4), we learn that Pr \u0002 PrivKDS A\u00b7\u03a0DS (n) = 1 \u0003 = 1 2 + D(K) in ciphertext-only attack, where D(K) is the probability of guessing training set. Pr [C = c|M = m] = Pr [K \u2212M = c|M = m] = Pr [K \u2212m = c] = Pr [K = c + m] (4) In general, there are 2500 records in training data set for kNN, each of them being 32*5=160 bits in our scheme. Thus, D (k) = 1 22500\u00d7160. With the idea of asymptotic approach, we consider D (k) negligible. In chosen-plaintext attack, Pr \u0002 PrivKDS A\u00b7\u03a0DS (n) = 1 \u0003 could be equal with 1 2+ q(n) 22500\u00d7160, where q(n) is the number of queries to the Oracle. If Q(n) is a polynomial about n, \u03b5(n)\u2217Q(n) is still negligible. In encryption scheme \u03a0DS, q(n) is a polynomial about the number of collusive domians, so q(n) 22500\u00d7160 is negligible. Encryption scheme \u03a0DS has indistinguishable encryptions under a chosen-plaintext attack. \u25a0 VII. EVALUATION This section evaluates Predis in terms of accuracy, expansibility, time consumption, and compatibility. A. Preliminary Dataset. Since simulating attack scenarios has a major defect in terms of traf\ufb01c diversity, we employ \ufb01ve sets of public traf\ufb01c traces for our experiments, including the CAIDA \u201cDDoS attacks \f22 TABLE VI STATISTICS OF DATASET 1 Domains 1999 DARPA LLDOS 1.0 LLDOS 2.0.2 Packets Flows Packets Flows Packets Flows 172.16.112.* 1573963 427056 1237 1104 376 354 172.16.113.* 585996 236122 338 328 255 254 172.16.114.* 835099 311354 344 258 24 16 172.16.115.* 5090 3838 2428 1336 632 611 131.84.1.31(Victim) 35645 17830 108509 107465 2100 2003 202.77.162.213(Attacker) 52606 24498 3722 3174 1724 1634 Domains Merge 2502403 1020698 116578 107667 5111 560 2007\u201d traces [46], the CAIDA Anonymized 2008 Internet traces [47], the 2000 DARPA LLDOS 1.0 and LLDOS 2.0.2 traces [4], the 1999 DARPA traces [4], and the KDD Cup 1999 traces [48]. Besides, we deployed a DDoS attacks experiment and captured relevant traf\ufb01c traces for our experiments. The \ufb01le format of these datasets is .pcap which pertains every packets\u2019 detail. We parse these .pcap \ufb01les by \ufb02ow statistics to simulate the \ufb02ow table collected by a controller in SDNs. Using the combinations of these traces, we de\ufb01ne three datasets for experiments. Dataset 1. The 1999 DARPA and 2000 LLDOS traces were collected from the same network topology. Thus, in Dataset 1, we use the 1999 DARPA traces as normal traf\ufb01c, and use the 2000 LLDOS traces as anomaly traf\ufb01c. We segment domains by the IP address segment. Victims and attackers are located in different domains. Statistics of Dataset 1 are shown in Table VI. Dataset 2. All traf\ufb01c in the CAIDA were collected from both directions of an OC-192 Internet backbone link by CAIDA\u2019s equinix-chicago monitor. Thus, in Dataset 2, we use the CAIDA Anonymized 2008 Internet traces as normal traf\ufb01c, and use the CAIDA \u201cDDoS attacks 2007\u201d traces as anomaly traf\ufb01c. Dataset 3. We used Python and Scapy4 to achieve the simulation of synchronous (SYN) \ufb02ood attack. To simulate DDoS attacks, we used 5 hosts to launch SYN \ufb02ood attacks against a host, and then collected 5 minutes of abnormal traf\ufb01c on this victim host. To obtain the abnormal traf\ufb01c as clean as possible, when collecting abnormal traf\ufb01c, we closed all the applications on 4Scapy is a python library used for interactive packet. \f23 TABLE VII STATISTICS OF DATASET 3 Packets Flows Anomaly traf\ufb01c 114214 79440 Normal traf\ufb01c 941904 18582 TABLE VIII STATISTICS OF CROSS VALIDATION USING DATASET 2 Domains CAIDA Anonymized 2008 CAIDA DDoS attacks 2007 Packets Flows Packets Flows Sample 1 1370524 243997 435428 63093 Sample 2 1377329 243724 426769 62574 Sample 3 1286528 237956 445796 63749 Sample 4 1299980 234976 431176 63349 Sample 5 1340870 246775 398453 59467 Sample 6 1338945 243518 413624 61057 the victim host. We collected another 45 minutes normal traf\ufb01c in this victim host when there is no attacks. Statistics of Dataset 3 are shown in Table VII. In addtion, the KDD Cup 1999 traces are used alone to evaluate performance of Predis in part of compatibility. Statistics of the KDD Cup 1999 traces are shown in Table IX. Cross-Validation. To evaluate the performance difference between Predis and others, we employ cross-validation for each dataset. Dataset 1. To protect traf\ufb01c characteristics of DDoS attacks of per phase in LLDOS, we do not partition LLDOS\u2019s data. When LLDOS 1.0 is used as the training dataset, LLDOS 2.0.2 will be used as the test dataset. When LLDOS 2.0.2 is used as the training dataset, LLDOS 1.0 will be used as the test dataset. DARPA1999 traces always act as background traf\ufb01c, selecting 50% of which to create the training dataset and the remaining 50% for validation. Dataset 2. As network traf\ufb01c data is time-dependent, we divide traces on a time basis. When performing cross validation, we divide both the CAIDA Anonymized 2008 Internet traces and the CAIDA \u201cDDoS attacks 2007\u201d traces into 6 partitions per 3 seconds. Each time we take one of them as the test dataset, the remainder as the training dataset. Cross validation statistics of Dataset 2 are shown in Table VIII. \f24 TABLE IX STATISTICS OF KDD CUP 1999 TRACES Type of Attacks Normal DoS Prob U2R Number of Connections 972781 391502 4107 218 Methods to Compare. Predis is a privacy-preserving cross-domain detection in SDNs. To evaluate the performance of Predis in a comprehensive way, we select three methods as the state-of-the-art for comparison, i.e., SVM, SOM, and PSOM. Kokila et al. [20] leverage SVM to perform DDoS attacks detection in SDNs whereby high accuracy rate has been achieved. Braga et al. [30] use SOM to perform DDoS attacks detection in SDNs. PSOM is a cross-domain DDoS detection scheme using SOM as the classi\ufb01er and introduces privacy-preserving proposed by Bian et al. [22]. Besides, liner kNN (kNN) is implemented to clear the improvement towards kNN in Predis in term of speed. We disable the privacy-preserving function in Predis and name it as PkNN, and Naive Bayes (NB) is also implemented to have a better view. Comparison Criteria. The fundamental goal of attacks detection is accuracy (i.e., identifying more anomalies in the ground truth and avoiding false alarms) [49]. We use precision ( #correctly divided into attack flows #correctly and falsely divided into attack flows) and recall ( #correctly divided into attack flows #all attack flows ) to measure the detection accuracy. B. Evaluation of Classi\ufb01er Performance (1) Selection of The Best k Value. To \ufb01nd the best k value for the improved kNN in Predis, we observe the changes in time consumption, precision, and recall, when k increases from 5 to 35 gradually, where the privacypreserving component in Predis is temporarily disabled. Subsequently, we determine and select the best k value for our scheme. The experimental data for evaluation is the Sample 1 in Dataset 2. The training dataset size is 2400, including 1200 normal traf\ufb01c instances and 1200 abnormal traf\ufb01c instances, whose scale remains unchanged in the following experiments. Experimental results are depicted in Figure 5, where the vertical coordinates are changes in the k value. Figure 5(a) and (b) exhibit the evaluation results of precision (recall) and time consumption, respectively. We can \ufb01nd that an appropriate k value lies between 20 and 25, where \f25 (a) Precision (b) Time Consumption Fig. 5. Precision and Time Consumption by Varying k. Predis achieves relatively high accuracy without introducing heavy time overhead. Thus, we choose the k value as 23 in the following experiments. (2) Classi\ufb01er Performance. To better comprehend the performance of the classi\ufb01er in Predis in speed and accuracy, we conduct a comparison between Predis, PkNN, kNN, PSOM, SOM, SVM and NB by using Dataset 3, which results is depicted in Figure 6. It can be seen from the Figure 6(a), compared to other algorithms, kNN has a higher accuracy, but its speed has no advantage. Although we use some algorithms (KD-tree and BBF) to improve its speed, it is still not the least time consumption algorithm as shown in the Figure 6(b) by the PkNN speed. An important reason for choosing kNN as the classi\ufb01er in Predis is that kNN is easy to calculate (cf., Section IV-A) which facilitates embedding the encryption steps into it, and another reason is that kNN has relatively higher accuracy which have been con\ufb01rmed in this experiment. Besides, Predis and PSOM have relatively high time consumption because of the privacy protection process. C. Evaluation of Accuracy (1) Accuracy evaluation between single-domain and cross-domain scenarios. Cross-validation is conducted using Dataset 1. From the results in Table X, we can see that the precision and recall of the single-domain detection is lower than those of the cross-domain detection, which undoubtedly proves our stance that DDoS attacks detection in cross-domain is truly necessary. We also observe that Predis is superior to PSOM in terms of presicion and recall. In domain 172.16.115.*, Predis and PSOM both have low precision and recall. The \f26 (a) Evaluation of Accuracy (b) Evaluation of Time Consumption Fig. 6. Comprehensive Evaluation of the Classi\ufb01er in Predis. TABLE X ACCURACY COMPARISON BETWEEN SINGLE-DOMAIN AND CROSSDOMAIN APPROACHES LLDOS 1.0 as Training Dataset LLDOS 2.0.2 as Training Dataset Precision Recall Precision Recall Domains Predis PSOM Predis PSOM Predis PSOM Predis PSOM 172.16.112.* 0.9720 0.9713 0.9010 0.5558 0.9730 0.9700 0.9000 0.6734 172.16.113.* 0.9973 0.9600 0.9930 0.6700 0.9914 0.9651 0.9916 0.8100 172.16.114.* 0.9900 0.9843 0.9874 0.7800 0.9255 0.7630 0.8500 0.7180 172.16.115.* 0.8980 0.8741 0.8865 0.8700 0.8690 0.8053 0.8500 0.8156 Victim 0.9710 0.8160 0.9750 0.7071 0.8320 0.8086 0.7020 0.6700 Attacker 0.9200 0.7753 0.9200 0.7200 0.9052 0.4133 0.8700 0.6400 Domains Merge 0.9985 0.9780 0.9923 0.9653 0.9920 0.8986 0.9812 0.8200 reason lies in that fewer hosts are invaded by attackers in domain 172.16.115.*, and invaded hosts have not generated many abnormal traf\ufb01c. The lack of training dataset results in not so outstanding detection results. But Predis\u2019s precision and recall is still above 0.88. (2) Accuracy evaluation of detecting DDoS attacks at early stages. It is desirable to detect DDoS attacks at the \ufb01rst and second stages. We conduct cross-validation in Dataset 1 and divided Dataset 1\u2019s traces into three stages (scanning, intrusion, and attacking). At both the attack scanning and intrusion stages, Predis delivers excellent detection results as shown in Table XI, which means that Predis can identify attacks at early stages. In contrast to PSOM, Predis achieves better detection results at any stage of the attack, and its detection result at stages of scanning and intrusion is suboptimal. Moreover, the precision of Predis is \f27 TABLE XI DDOS ATTACKS DETECTION ACCURACY AT EACH STAGE LLDOS 1.0 as Training Dataset LLDOS 2.0.2 as Training Dataset Precision Recall Precision Recall Domains Predis PSOM Predis PSOM Predis PSOM Predis PSOM Scanning 0.9734 0.8730 0.8645 0.7630 0.8612 0.8053 0.9251 0.8945 Intrusion 0.9920 0.8740 0.9900 0.8821 0.9400 0.8392 0.8830 0.8755 Attacking 0.9919 0.9733 0.9614 0.9200 0.9808 0.9472 0.8792 0.8740 (a) Precision (b) Recall Fig. 7. The Results of Precision and Recall of n-th Cross-Validation Using Dataset 2. 0.9919 when LLDOS 1.0 as the training dataset at the attacking stage. (3) Accuracy evaluation with privacy-preserving or without. Using Dataset 2 for cross-validation, we make a comparison between Predis, the SVM and SOM methods. To evaluate the impact of privacy-preserving in Predis on detection accuracy, we also disable the privacy-preserving function in Predis and refer to this variation as CAD in comparison. Experimental results are plotted in Figure 7, where the precision and recall are exhibited in two sub\ufb01gures, respectively. The x-axis indicates the serial number in cross-validation. When we detail Predis in Section V-D, we have proved through theoretical analysis that the detection result of introducing privacy protection will not have any impact on detection accuracy. This conclusion is validated in Figure 7, where Predis and CAD obtain the same detection accuracy. In addition, we can \ufb01nd that Predis outperforms the other two methods in terms of both precision and recall. \f28 TABLE XII EVALUATION OF DETECTION ACCURACY WITH VARIED NUMBERS OF DOMAINS USING DATASET 1 LLDOS 1.0 as Training Dataset LLDOS 2.0.2 as Training Dataset Precision Recall Precision Recall Number of domains Predis PSOM Predis PSOM Predis PSOM Predis PSOM 1 0.9720 0.9713 0.9010 0.5558 0.9730 0.9700 0.9000 0.6734 2 0.9840 0.9672 0.9769 0.6530 0.9207 0.9270 0.9501 0.9468 3 0.9912 0.9760 0.9800 0.6734 0.9232 0.9105 0.9543 0.9208 4 0.9914 0.9613 0.9900 0.7133 0.9308 0.9256 0.9683 0.9660 5 0.9920 0.9514 0.9913 0.8320 0.9591 0.8512 0.9537 0.9201 6 0.9880 0.9438 0.9864 0.7689 0.9508 0.8380 0.9517 0.9106 Average 0.9864 0.9618 0.9709 0.6994 0.9424 0.9037 0.9463 0.8896 (a) LLDOS 1.0 as Training Dataset (b) LLDOS 2.0.2 as Training Dataset Fig. 8. Evaluation of Time Consumption with Varied Numbers of Domains Using Dataset 1. D. Evaluation of Scalability Using Dataset 1, we record the changes of time consumption and accuracy when the number of domains goes up from one to six, as shown in Table XII and Figure 8. When the number of domains increases, time consumption is only determined by the amount of traf\ufb01c instances and, the detection effect remains almost unchanged. The time complexity of the improved kNN is O(n), where n is the number of traning instances. As can be seen from the experimental results, the time consumption of Predis does not surge and meets linear variations as the number of domains increases. \f29 (a) Time Consumption with Varied Numbers of Flows (b) Evaluation of Time Consumption Using Dataset 2 Fig. 9. Evaluation of Time Consumption. E. Evaluation of Time Consumption First, from Figure 8, we can see that with the increasing number of domains, Predis has obvious advantages in terms of time-consumption compared to PSOM. We analyze the MAWI dataset [50] which are based on the collected network traf\ufb01c during 7 years of a speci\ufb01c link between Japan and the USA. The backbone generates about 6,000 KB (130,000 \ufb02ows) traf\ufb01c per second. If we can process 13,000 \ufb02ows per second (1/10 of the traf\ufb01c generated by this backbone line), it shows that Predis can meet the time-consuming requirement. The time spent is the sum of the time spent between CS and DS. We record the time spent on two server when the amount of test instances increase from 1,000 to 10,000, where Dataset 2 is used. From Figure 9(a) we can see that when 10,000 \ufb02ows for testing, the total time does not exceed 1 second. With privacy-preserving, the time consumption of Predis is also acceptable. In addition, using Dataset 2, we record the time spent in 6 cross-validation experiments, where PSOM is the control group and the results are shown in Figure 9(b). We can see in Figure 9(b), compared to a similar scheme PSOM, Predis has a lower time consumption. F. Evaluation of Detecting Other Attacks We hope that the attacks detection scheme will detect not only DDOS attacks but also other attacks. We testify through evaluation that Predis is not only suitable for detecting DDOS attacks, but also capable to detect a variety of attacks and retains an excellent accuracy after changing the feature selection model properly. We conduct experiments using the KDD Cup 1999 \f30 TABLE XIII TIME CONSUMPTION ON DETECTING OTHER ATTACKS DOS Prob U2R Criterion Predis PSOM Predis PSOM Predis PSOM Precision 0.9161 0.8872 0.9901 0.8753 0.8834 0.8810 Recall 0.9003 0.8706 0.9874 0.9644 0.7900 0.7650 Total Time 616ms 707ms 785ms 833ms 569ms 640ms TABLE XIV EVALUATION OF ACCURACY IN DETECTING OTHER ATTACKS DOS Prob U2R Criterion Predis SOM SVM Predis SOM SVM Predis SOM SVM Precision 0.9161 0.8872 0.9024 0.9901 0.8753 0.9732 0.8834 0.8310 0.8604 Recall 0.9103 0.8706 0.9041 0.9874 0.9644 0.9566 0.7900 0.7650 0.7622 traces, which have several other types of attacks besides DDoS attacks. The feature selection model here is a four-tuple (Count, Src bytes, Dst bytes, Logged in). (1) Time consumption evaluation when detecting other attacks. We detect three types of attacks in the KDD Cup 1999 traces, such as DOS, Prob, and U2R, and record the time it takes as well as accuracy. Results are depicted in Table XIII. (2) Accuracy evaluation when detecting other attacks. We detect three types of attacks in the KDD Cup 1999 traces, such as DOS, Prob, and U2R, and record the accuracy in Table XIV, where SOM and SVM are compared. When detecting attacks of DoS, Prob, and U2R, the precision of Predis is no less than 90%. Compared to the same privacy-preserving scheme PSOM, Predis is better in terms of time consumption (as shown in Table XIII). Because in the KDD Cup 1999 traces, U2R attacks have very few abnormal traf\ufb01c instances, therefore recall is relative low when testing U2R attacks. Compared with SVM and SOM, Predis wins out as far as precision and recall are concerned (as shown in Table reftable:Time-Accuracy evaluation when detect other attack). Through these two experiments, it has been proven that Predis not only can detect DDoS attacks excellently, but also can detect other attacks very well when appropriately selected features are incorporated. \f31 VIII. DISCUSSION If SDNs controllers can know the DDoS attacks in it early stages in time and make corresponding measures (e.g., limiting the SYN / ICMP traf\ufb01c, \ufb01ltering speci\ufb01c IP addresses, traf\ufb01c cleaning, etc.), SDNs controllers can prevent the DDoS attacks before it causes damage. SDNs uses centralized control for traf\ufb01c forwarding mechanism that makes it easier to stop DDoS attacks. Predis has been demonstrated that it can detect DDoS attacks in the early stages of an attack (as show in Table XI). Once the server detects a DDoS attacks, it alerts the controller in time. The controller immediately responds to the alert, and prevents any further damage from the attack. The roles in Predis include two servers and SDNs controllers. Predis can prevent the collusion between one or more domains with one server, so the two servers can be respectively deployed in any one of the participating domains, or wherever providing secure communications with the domains over the TLS protocol. The data plane and the control plane of the SDNs communicate by using a control-data-plane interface (CDPI). The main use of the uniform communication standard is OpenFlow protocol. Flow table operations that include \ufb02ow table pretreatment, communicate with the server, proper handling for DDoS alerts or other operation can be deployed and implemented through the use of the southbound interfaces (i.e., COPI). Due to the development of different network access technologies and different communication systems, resource scheduling and fusion in heterogeneous networks have become hot topics. SDNs can achieve uni\ufb01ed management in con\ufb01guration heterogeneous network equipment and it open a variety of interfaces. But these interfaces perhaps is exploited by attackers, such as tapping, interception and DDoS attacks. We can regard the heterogeneous networks as a domain under the uni\ufb01ed management of a SDNs. Using Predis, Users can achieve secure crossdomain DDoS attacks detection and resist the threats from DDoS attacks in heterogeneous networks. In addition, Predis\u2019s idea of combining data perturbation with data encryption to provide cross-domain privacy protection may also be transplanted to other application scenarios in the future to achieve other secure multi-party computing. Overlay networks such as P2P (Peerto-Peer) add virtual channels to physical networks to enhance network \ufb02exibility. Each node in P2P networks may be the data provider. When considering monitoring the traf\ufb01c of multiple nodes without compromising the privacy, each node in the P2P can be considered as a domain, and the idea of Predis in cross-domain detection can be used to provide security monitoring \f32 service. IX." + } + ] + }, + "edge_feat": {} + } +} \ No newline at end of file