Dance Fitness Action Recognition Method Based on Contour Image Spatial Frequency Domain Features and Few-Shot Learning

In recent years, the research work of artificial intelligence technology has progressed rapidly, and various classic Few-Shot learning models have achieved unprecedented success in many artificial intelligence application fields. These include face recognition, object classification detection and tracking, speech recognition, and natural language processing, which greatly facilitate our lives. This paper aims to identify dance fitness movements based on contour image spatial frequency domain features and Few-Shot learning technology. This paper proposes a Few-Shot learning method based on contrastive average loss for Few-Shot learning. This method makes the learned model more representative by improving the loss function and performing a normalization process, and it proposes a feature extraction algorithm that combines improved LBP and HOG for action recognition technology. The experimental results show that the recognition accuracy of the algorithm in this paper is 93.10%, 90.30%, and 92.70% for walking, opening hands, and running, respectively. This illustrates the effectiveness of the fusion feature algorithm.

Introduction
In the early days, research based on images and videos was an important part of human action recognition methods. With the continuous development of computer technology, intelligent machines and equipment have gradually attracted widespread attention from human beings. ese methods mainly take the RGB information collected by the camera equipment as the research object and use the features such as texture and color information in the two-dimensional image to perform action recognition. However, the changes of lighting conditions, background interference, and occlusion and self-occlusion problems cannot be solved well, which has become the bottleneck of this type of research method. In order to enable deep learning models to overcome the problem of relying on large-scale data and obtain the ability to quickly learn new categories of things similar to humans, Few-Shot learning came into being. e general action recognition method works by extracting features from the original input and then training a classifier using those features. Robust feature representations must be obtained to ensure the accuracy of the final algorithm, which necessitates a significant amount of computational and testing effort. Massive labeled data are usually difficult to obtain in real-world applications. On the one hand, some industries find it difficult to collect image data for a variety of reasons, including privacy and security; on the other hand, even if image data are collected, labelling it is often costly. ese disadvantages severely limit the application of image classification models. As a result, for dance fitness action recognition, it is necessary to investigate the spatial frequency domain features of contour images as well as Few-Shot learning technology.
On the basis of predecessors, this paper has the following two innovations for human body recognition research: (1) a contrastive average loss-based Few-Shot learning method is proposed. Few-Shot learning is a commonly used method in human action recognition research, but the traditional Few-Shot learning method will be hampered by the action's noise and background processing.
is problem can be solved using the Few-Shot learning method based on contrastive average loss proposed in this paper. (2) e three movements of running, walking, and opening hands are used to research dance fitness movement recognition. Because these three movements are the most common in dance and fitness, and because other movements are based on their extensions, research on these three movements can better represent the entire movement.

Related Work
ere are numerous studies on human action recognition that are related. To compensate for the flaws of traditional algorithms, Tarn C et al. used the Few-Shot learning method to fit data online. eir proposed method was tested on ten datasets using different collision energy settings and instruments such as Velos, QE, Lumos, and Sciex. eir findings show that Few-Shot learning can improve prediction accuracy while using virtually no computational resources [1]. Research performed by Szcs and Németh aims to aid medical workers' work by analyzing pathological X-ray recordings with only a few images. ey propose the Deep Neural Network-based Dual View Matching Network (DVMN), an improved method that addresses the problem of Few-Shot learning and different views of pathological records in images. Its main contribution is the use of convolutional neural networks in image representation for feature extraction and multiview processing [2]. Li et al. proposed Joint Distance Maps, a simple and effective method for encoding the spatiotemporal information of skeleton sequences into color texture images, based on the good performance of deep learning (JDMs). ey also used convolutional neural networks to extract distinguishing features from JDMs for recognizing human action and interaction. e proposed method has been validated by stateof-the-art results in single-view and cross-view settings on the large RGB + D dataset and the small UTD-MHAD dataset [3]. SkeletonNet, a deep learning framework for skeleton-based 3D action recognition, was investigated by Ke et al. ey begin by extracting features based on body parts from each frame of the skeleton sequence. When compared to the original coordinates of the skeletal joints, the proposed features are translation, rotation, and scale invariant [4]. Wang et al. analyzed human activity recognition from videos using multimedia and convolutional neural network features. ey feed frame-level CNN sequence features to a long short-term memory (LSTM) model for video activity recognition, treating video as a sequence of frames [5]. To process video data, Ullah et al. proposed an action recognition method using convolutional neural networks and deep bidirectional LSTM-LSTM networks. First, every six frames of video are analyzed for deep features, which helps to reduce redundancy and complexity. en, using a DB-LSTM network, order information between frame features is learned, with multiple layers stacked together in the forward and reverse passes to increase the depth of the network. By analyzing features within specific time intervals, the method can learn long-term sequences and process lengthy videos. On three benchmark datasets, UCF-101, YouTube 11 Actions, and HMDB51 [6], their experimental results show that the proposed method achieves significant improvement in action recognition compared to existing action recognition methods.
Many studies on human actions are based on machine learning methods, and the extraction of video information is emphasized, as evidenced by a review of related research. ese kinds of processing methods are quite complicated.

Introduction to Few-Shot Learning.
In recent years, Few-Shot learning is a subfield of machine learning [7,8]. e definition of machine learning is that a computer program learns from experience (experiences, E) to solve a certain task (task, T) and perform a certain performance measure (performance, P). Performance P on task T improves with experience E. While Few-Shot learning is a class of machine learning problems (specified by E, T, and P), where E contains little supervision information for the target T. Specific to the image classification [9,10] task based on Few-Shot learning, T is the image classification task, E is a small number of labeled pictures and prior knowledge used for the classification task, and the performance measure P is the accuracy rate. According to the definition of machine learning, the classification task should be to improve the experience E based on the measured accuracy, while the few labeled images are fixed. erefore, only the part corresponding to the prior knowledge can be improved. Specifically, the prior knowledge may be some original images of other categories or a pretrained model. Figure 1 is an example of rooster single-sample recognition. e model only needs to judge which birds on the right are roosters based on the rooster image on the left. erefore, the training method of Few-Shot learning is different from the training method of conventional deep learning models [11][12][13]. Specific to the image classification problem, the training process usually contains two datasets, namely the support dataset and the query dataset. Formally, the training set learned by Few-Shot contains multiple samples of different classes. e model is required to learn how to distinguish the c classes from the Few-Shot with the number of training sets ck. Such a task is called a c-way k-shot classification task. e value of k is usually 1 or 5. When k is 1, this Few-Shot learning is called one-shot learning, as shown in Figure 2: e core problem of Few-Shot learning is insufficient sample size. In order to "learn" from a small number of samples to a deep learning model that can be generalized, the current main solutions can be divided into three categories: Few-Shot learning methods based on data augmentation, metric learning, and meta-learning. As stated in Chapter 1, the current research status at home and abroad, the probability-based generative model in the nondeep learning stage is the mainstream of the Few-Shot classification task; and the current mainstream is the deep learning-based discriminative model. So far, there are three main methods for using discriminative models to solve the Few-Shot classification problem: data augmentation, metric learning, and metalearning. ey solve the problem of Few-Shot image classification from three aspects: directly expanding the diversity of label samples, using prior knowledge (training set data) to learn better feature models, and optimizing hyperparameters to make the model learn quickly. e following three methods are briefly introduced.

Few-Shot Learning Based on Data Augmentation.
e data augmentation method based on Few-Shot learning is a method to enhance data and improve data diversity through prior knowledge.
ere are two types of data augmentation methods, one is a generative model that generates new samples through transformation; the other is a transduction model that uses the model to label unlabeled samples and then further trains the model. e specific working method is shown in Table 1. e converter inputs the unlabeled image u and the reference sample image x, and its label y and outputs the synthesized image x and label y, which are used to enhance the training dataset of Few-Shot. Image processing [14,15], zoom-in and zoom-out, random cropping, adding noise, mirror flipping, and other  basic data augmentation methods based on generative models are among the most basic. ese manual transformers can create new images that have the same tags as the old ones. e amount of data generated above for Few-Shot learning is far insufficient to improve the model's generalization ability. Many new methods have been developed as a result of the development of deep learning, the majority of which are based on autoencoders (AE) or adversarial generative networks (GAN) [16]. DAGAN learns on the training set using a generator that combines U-Net and ResNet, as well as a discriminator that uses DenseNet. is trained GAN model is then used to generate new sample images for Few-Shot image classification on the test set [17,18].
It can be seen that the difference between this type of data expansion method and other Few-Shot learning methods is that there are two more steps before training image classification, as shown in Figure 3, which are training converters (generators), and then synthesizing new data.

Metric-Based Few-Shot Learning.
Metric learning refers to extracting features from samples and embedding them into a feature space with a small dimension, and then using the distance between two features to measure the similarity of two samples. Commonly used distances in feature space include Euclidean Metric and Cosine similarity [19,20].
(1) Siamese Network. Siamese network is the first to introduce metric learning into Few-Shot learning. As shown in Figure 4, the network structure consists of two convolutional neural networks (CNNs), which input a pair of samples (x i , y i ). At the same time, the two CNNs share the convolution kernel weight, then output two feature vectors through the fully connected layer, and finally output the similarity score p(x i , y i ) of the two samples according to the distance between the two vectors. e distance metric function of the two features is directly a weighted 1 function, and the loss function of the network structure is shown in the following equation: Among them, y ij � 1 when x i and x j belong to the same category. After the model is trained, the parameters of the Siamese network are fixed and tested on the Few-Shot task, and then, the nearest neighbor classifier (NearestNeighborClassifier) is used for classification.
(2) Matching Network. Unlike Siamese networks, which share parameters for training and test sets, matching networks are the first to design a piecemeal training mechanism.
e matching network adds a support set attention model. Specifically, in the training process, the convolutional neural network is used to extract features for the support set and the query set, and then, the attention weight corresponding to each support set is calculated according to the sample features of the query set, and then calculate the possible labels of the query set samples according to the attention weights, and finally use the cosine similarity to measure the matching degree of the support set samples and the query set where x represents the query set sample, x i represents the ith support set sample, c(,) represents the cosine distance, and f() and g() represent the feature extraction function of the query set and support set, respectively.
(3) Prototype Network. Since the matching network studies the single-sample problem, the number of each sample learned by Few-Shot is less than 20. In order to solve the problem of solving the similarity of feature space in the case of multiple samples of each type, the prototype network has designed the concept of prototype. First, the support set samples are embedded in the feature space, and then, the center of each class of the support set is designed as a prototype. e prototype calculation formula is shown in the following equation: Among them, f φ (x i ) represents the feature extraction function, and S k represents the support set containing k samples for each class. en, the similarity is calculated by calculating the Euclidean distance d(,) between the query set and the prototype. In the test, the normalized exponential function is used to calculate the distance between the test sample and the prototype of the support set. e specific formula is shown in the following equation.
Prototype networks do not suffer from class imbalance since there is only one prototype per class. Also since the prototype can only capture the mean of the support set, naturally its variance information will be lost. e features extracted from the support set are updated by extracting the features from the query set of the task as environmental features, so that each task has its own different feature output, so as to solve the problem that the variance information will be lost.
(4) Relationship Network. As shown in Figure 5, the relational network model mainly includes two modules: an embedded module and a relational module. e former is the feature extraction module that every metric learning must have; and the relational module is the metric module, which directly connects the sample features of the query set and the support set, and then input into a convolutional neural network and directly classify and score through the fully connected layer. e classification scoring formula is shown in the following equation: Among them, x i and x j represent the support set and query set samples, respectively; f φ (x i ) represents the embedding function; c(,) represents the concatenation of the embedded feature maps; and g ϕ (x i ) represents the relation function. Computational Intelligence and Neuroscience methods are frequently combined with metric learning and hyperparameter optimization meta-learning. As a result, the following sections focus on hyperparameter optimizationbased meta-learning methods. e core idea of MAML (Model-Agnostic Meta-Learning) model is to set initialization parameters suitable for fast learning for basic learning model parameters through crosstask training strategy. In this way, the base learning model can generalize well to new tasks using only a few samples of the support set. Specifically, the parameter update formula for the basic learner of task T is shown in the following equation:

Few-Shot
where α is the learning rate, L(D T , θ b ) is the loss function of task T on the support set, and θ b is the initialization parameter of the basic learner.
In the meta-learning stage, MAML optimizes the metalearner model by balancing the loss corresponding to parameter θ T b of the basic learning model on multiple tasks. e specific formula is shown in the following equation: It is worth noting that the meta-learning model and the basic learning model in MAML in Table 2 are the same model, that is, parameter θ m � θ b . In fact, there are many MAML-based variant models. e MAML-based variant models and their improvement points in recent years are shown in Table 2.

Few-Shot Learning Based on Contrastive Average Loss.
In metric learning, a prototype network is a representative algorithm framework. It uses the feature embedding module to process the data and represent it as a prototype for a specific category. e metric module is a parameter-free module that compares query set samples to all prototypes and chooses the prototype category with the shortest distance as its own category. When the algorithm creates category prototypes, however, it only takes into account the relationship between samples and similar prototypes, which can cause issues in more complex situations. is paper proposes a new loss function based on the prototype network. In comparison with the average loss (CDM), the loss function compares the difference between the sample and different prototypes at the same time, reducing the difference between Few-Shot and the same type of prototype while increasing the differences between samples and different types of samples. is will improve the feature embedding function's ability to represent features, making the learned prototypes more representative. Prototypes of various categories are more differentiated, which improves the model's generalization ability. e method is tested on a benchmark dataset for image classification, and Relational score predicted value

MT-net
Simplify the parameter space of MAML meta-learning model into a subspace composed of each layer of activation space, thus reducing the difficulty of fast learning.

TAML
Unbiased task unknowable experience is added to the initial model to solve the problem of poor performance of MAML framework in meta-training.

LEO
Combining MAML with metric learning, the model can quickly learn hyperparameters in low-latitude embedded space. 6 Computational Intelligence and Neuroscience the results show that it can effectively improve the model's performance. e loss function proposed in this paper will consider the relationship between samples and prototypes of different categories at the same time.
rough the adjustment of hyperparameters, it can flexibly convert between the overall category and some categories. Experiments show that this method can improve the performance of the model on the dataset. Note the training dataset D � (x i , y i ) N i�1 . For a support set sample, the number of categories is k, and the prototype of a category is denoted as C k . e class prototype to which sample x i belongs is C i , and the distance between sample x i and class prototype C j is denoted by d. e measurement method of distance can be selected by yourself.
e distance contrast is recorded as l, and the optimization goal is to minimize it, as shown in the following equation: In the formula, m is an adjustable hyperparameter. Its function is to adjust the number of comparisons between a single sample and different types of prototypes, and its maximum value is k − 1. In machine learning, gradient descent is a commonly used optimization algorithm. According to the amount of data used to update the parameters each time, it is divided into batch gradient descent, mini-batch gradient descent, and stochastic gradient descent (SGD). After the model training is completed, given a query set sample, the corresponding prediction is as shown in the following equation: at is, the sample will be marked as the class of the closest prototype to it. e distance metric part of this loss function consists of two parts. Considering that the proportion of the difference between the two may have a certain impact on the results, parameters can be added before the two parts to control, such as the following formula: e value range of α is between 0 and 1. By adjusting the value, the numerical proportion of different parts in the loss can be adjusted. However, after experiments, the effect of α is very limited, and the addition or not has little effect on the experimental results. And α is a hyperparameter, and the adjustment of the parameters must be considered after adding it. Taking it into consideration, it is more secure to remove it; that is, the part of the lost contrast remains unchanged.

HOG Feature Extraction
Algorithm. e essence of HOG is to rely on the statistics of gradients in the image. is gradient information is usually at the edge of the image, and the directional density distribution at the edge can better reflect the information and shape of the local target in the image. e primary basis of HOG is to segment the image and divide it into connected regions called cell units; next, we need to collect the edge or gradient direction histogram of each pixel in the segmented cell unit above, and finally combine them to obtain the feature descriptor we need. ese combined directional gradient histograms need to be diffused from the local area, and the contrast normalization operation is performed in a larger area in the image. is larger area is called a block, which is an interval. e main operation steps are to first calculate the density of the histogram of each direction in the whole area, and then normalize the whole cell unit according to the calculated density, so as to reduce the influence of light and shadow on the detection result. e concept of directional gradient histogram (HOG) was proposed earlier, and it has many advantages compared with other algorithms. First, it is not very sensitive to the effects of optical and geometric distortions in the image, because all its operations are performed in local grid cells. e second point is that under the condition that the local optical normalization is relatively high, the sampling in the spatial domain is relatively coarse, and the sampling in the direction is relatively fine, and some relatively small movements of the human body can be allowed. Usually, these relatively small actions are ignored and have little effect on the final result. rough the above content, we can find that the directional gradient histogram will have a wide range of applications in human body recognition in images.

Calculate the Image Gradient.
e gradients of the horizontal and vertical coordinates in the image are calculated, respectively, to obtain the value of the gradient direction of each pixel in the image. rough this derivation method, we can reduce the sensitivity to light and obtain information such as human contours and textures in the image. e gradient component of the pixel point (x, y) is shown in following equations: e gradient magnitude and direction of the (x, y) point are as shown in following equations: In the directional gradient histogram, the following methods are often used: in the first step, the gradient operator is used to perform convolution calculation to obtain Computational Intelligence and Neuroscience the gradient component in the horizontal direction; the second step is to use the gradient operator to perform convolution calculation to obtain the gradient component in the vertical direction; and finally, formula (13) and (14) are used to calculate the gradient direction and size at the pixel position.

Construct the Gradient Direction Histogram for Each Unit.
is step is mainly to provide a code to the local area, but without destroying the weak sensitivity to human targets while encoding. First, the processed image is divided into several units called cells. Here, we assume that a cell contains 36 pixels, that is, 6 × 6, and the gradient information of these 36 pixels is counted through the histogram. A cell has a gradient direction of 360 degrees, and we divide it into 9 parts, as shown in Figure 6.

4.2.
Classifier. Now add the following explanation: SVM is an effective method to solve the problem of Few-Shot pattern recognition. Finding the generalized optimal classification hyperplane is in high-dimensional space. In order to realize the recognition of multiple categories, it is necessary to make corresponding improvements to the SVM.
At present, many researchers have extended SVM and proposed many excellent algorithms to solve multiclass classification problems. For example, using multiple twoclass classifiers and other methods in action recognition, the commonly used kernel functions of SVM include linear kernel and histogram. In this paper, the two factors of SVM classification accuracy and computational complexity are comprehensively considered, and through experimental comparison, the histogram cross-kernel is used as the kernel function of the classifier. Its expression is as in the following equation: min a n , b n . (15) Among them, X i , X j is two arbitrary eigenvectors, a n , b n is the eigenvalue of the nth dimension, and m is the dimension of the eigenvector. Compared with the other two kernel functions, the histogram cross-kernel has the characteristics of low computational complexity and good classification effect. en, we input the previously obtained feature vector based on the histogram cross-kernel SVM to obtain the final classifier. After obtaining the test set features, we use the classifier just obtained to make corresponding predictions on the results, and finally achieve action recognition.

Improved LBP Algorithm.
When the improved LBP encodes, firstly, the difference between the gray value of the pixel at the center position and the gray value of its adjacent pixels is taken separately, and then, the difference is added and the average value is obtained to obtain the threshold M, as shown in the following equation: en, we use the gray value of the neighboring pixels and the gray value of the center pixel to perform a subtraction operation in a certain order (clockwise or counterclockwise) to get the absolute value, and then add it compare with the threshold M. If the value is greater than M, it is coded as 1; otherwise, it is coded as 0. Its coding formula is shown in the following equation: Finally, we convert the encoding. Since the computer encoding system uses binary data, we convert it into decimal data that are easy to calculate, as shown in the following equation: e SIFT feature is a scale-invariant feature transform. SIFT features remain invariant to rotation, scale scaling, brightness changes, etc., and maintain a certain degree of stability for viewing angle changes, affine transformations, occlusions, and noise, and are relatively stable local features. However, it detects too few feature points for blurred images and images with smooth edges, resulting in a low recognition accuracy. In the follow-up experiments, the proposed algorithm is also compared with these existing fusion methods.
Due to the above shortcomings of a single feature, this paper proposes a method based on the fusion of HOG features and improved LBP features. Feature fusion first needs to extract a large amount of feature information and then compares the information. Although this can enhance real-time performance, it will lead to missing information and inaccurate results. However, if we adopt serial fusion, although the recognition accuracy can be improved, it will lead to an increase in the amount of data and reduce the detection efficiency. Select a video from Weizmann and YouTube, respectively, and then extract the video frame image, and perform grayscale and normalization processing on the image. It is mainly to standardize Gamma and color space and also to reduce the influence of lighting and other factors on the detection results. erefore, this paper adopts the method of weighted fusion of HOG features and improved LBP features. e algorithm flowchart is shown in Figure 7.
(1) In an image, the exposure of the local surface layer accounts for a large proportion of the texture intensity. By normalizing the image, we can greatly reduce the lighting and the effect of shadows on the local part of the image. Typically, we first convert the image to grayscale. e Gamma compression formula is shown in equation (19), and Gamma is represented by 1. In this experiment, the value of 1 is taken as 0.5.
(2) Normalize the scale of the two feature sets obtained.
(3) Use a weighted method to perform feature fusion to obtain the final feature set, as shown in equation (20). Among them, α, β ≥ 0 is the weight, which satisfies α + β � 1.

T(l) � αL(I) + βH(I).
(4) Use the SVM classifier to identify in which the SVM kernel function adopts the histogram cross-kernel.

Recognition and Analysis of Dance Fitness Movements
Dance fitness movements are complex, especially under high-speed movement, various movements are difficult to capture and cannot achieve good results. In this paper, three common movements in dance fitness are selected for identification and analysis. e three movements are walking, opening hands, and running. e feature extraction structure of a single frame is shown in Figure 8.
As shown in Figure 8, in different actions, the contours extracted from the two feature maps are relatively clear, but some details are still blurred. erefore, the action recognition for dance fitness still needs to be optimized.
For the Omniglot dataset, the training epoch � 100, the learning rate is 0.001, and the dynamic adjustment strategy is adopted, and the learning rate is adjusted to one-half of the original every 20 rounds. e value of episode is set to 100 in one epoch, and the number of categories in each episode is set to 60. By adjusting the number of samples for each category in the support set to 1 and 5, and the number of categories to 5 and 20, the corresponding n-way k-shot training is completed. For the miniImageNet dataset, due to the large amount of data, the total number of training rounds is set to 200, that is, epoch � 200, and the learning rate is 0.001. e dynamic adjustment strategy of the learning rate is the same as above, and the value of episode in each epoch is also 100. When the image is input, it will be scaled to a size of 84 * 84. In order to speed up the convergence, the RGB channels of the image will be normalized. During SeProtNet training, the value of c is set to 16. e training process under the 5-way 5-shot setting is shown in Figure 9. When the number of iterations is 161,000, the image classification model based on Transformer Few-

Computational Intelligence and Neuroscience
Shot learning achieves the highest accuracy rate of 85.28% on the validation set. It can be seen from Figure 9 that the image classification model based on Transformer Few-Shot learning in the case of 5-shot, when the accuracy rate and loss basically converge, the fluctuation range is much smaller than the 1-shot setting. As shown in Table 3, in the testing phase, the trained model performance is measured by randomly building 600 segment tasks. e accuracy of the Transformer Few-Shotbased learning model is better than the other methods in both settings, with 66.75% accuracy under 1-shot setting and 82.05% under 5-shot setting. Among them, the prototype network, that is, the model without Transformer and group regularization, is the basic network of this model. Compared with the prototype network, the accuracy of this model has been greatly improved, with an increase of 6.43% under the 1-shot setting and 4.03% under the 5-shot setting.
As shown in Figure 10, the three actions of walking, opening hands, and running are analyzed under the dataset. e accuracy of different algorithms is different, but the recognition efficiency of the feature extraction algorithm that combines HOG and improved LBP algorithm has always been high. e recognition accuracy rates of walking, opening hands, and running are 93.10%, 90.30%, and 92.70%, respectively. is illustrates the effectiveness of the fusion feature algorithm.

Conclusions
Few-Shot and data imbalance are frequently symbiotic in practical applications. Data augmentation, knowledge transfer between similar categories, data synthesis, structured knowledge graph, domain adaptive learning, and model solvability are all strategies that can help Few-Shot learn better. At the moment, Few-research Shot's is primarily focused on image data modeling and processing.
Many fields of supervised learning, such as video object detection and semantic segmentation, have an urgent need for Few-Shot learning, and other directions are also worth exploring. Furthermore, in the future, directions such as natural language processing and recommendation systems will be important application scenarios for Few-Shot learning.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.    Computational Intelligence and Neuroscience 11


Quantum blockchain based on asymmetric quantum encryption and a stake vote consensus algorithm

As emerging next-generation information technologies, blockchains have unique advantages in information transparency and transaction security. They have attracted great attentions in social and financial fields. However, the rapid development of quantum computation and the impending realization of quantum supremacy have had significant impacts on the advantages of traditional blockchain based on traditional cryptography. Here, we propose a blockchain algorithm based on asymmetric quantum encryption and a stake vote consensus algorithm. The algorithm combines a consensus algorithm based on the delegated proof of stake with node behaviour and Borda count (DPoSB) and quantum digital signature technology based on quantum state computational distinguishability with a fully flipped permutation (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\text{QSC}}{\text{D}}_{\text{ff}}$$\end{document}QSCDff) problem. DPoSB is used to generate blocks by voting, while the quantum signature applies quantum one-way functions to guarantee the security of transactions. The analysis shows that this combination offers better protection than other existing quantum-resistant blockchains. The combination can effectively resist the threat of quantum computation on blockchain technology and provide a new platform to ensure the security of blockchain.

Quantum blockchain based on asymmetric quantum encryption and a stake vote consensus algorithm Wusheng Wang, Yang Yu & Lingjie Du * As emerging next-generation information technologies, blockchains have unique advantages in information transparency and transaction security. They have attracted great attentions in social and financial fields. However, the rapid development of quantum computation and the impending realization of quantum supremacy have had significant impacts on the advantages of traditional blockchain based on traditional cryptography. Here, we propose a blockchain algorithm based on asymmetric quantum encryption and a stake vote consensus algorithm. The algorithm combines a consensus algorithm based on the delegated proof of stake with node behaviour and Borda count (DPoSB) and quantum digital signature technology based on quantum state computational distinguishability with a fully flipped permutation ( QSCD ff ) problem. DPoSB is used to generate blocks by voting, while the quantum signature applies quantum one-way functions to guarantee the security of transactions. The analysis shows that this combination offers better protection than other existing quantum-resistant blockchains. The combination can effectively resist the threat of quantum computation on blockchain technology and provide a new platform to ensure the security of blockchain.
The concept 1 of blockchain technology was first introduced by Satoshi Nakamoto in 2008. Blockchain is a decentralized block of data linked in a chronological chain network to provide a distributed shared ledger and database. For example, in the first blockchain system, i.e. Bitcoin, each block contains two parts, namely, the block header and block body. The block header contains the hash value of the current block, the hash value of the previous block, the timestamp, and information about the Merkel tree; the block body contains the transaction information and the corresponding digital signature. One advantage of the blockchain is the usage of a distributed network, which provides the transparency and security of transaction information. After more than ten years of rapid development, this technology is not limited to Bitcoin and other cryptocurrencies but also attracts intense attention from multidisciplinary areas, such as finance, energy, medical care, and government affairs.
At the core of blockchain technologies, the most important aspects are consensus algorithms and digital signatures. Consensus algorithms can be used to generate blocks, while digital signatures can secure transaction information. For example, the consensus algorithm used in the Bitcoin network is proof of work (PoW) 1 , which allows every miner to compete through computing power based on a hash algorithm. The miner with higher hash power tends to have larger probabilities to find the correct hash solution, and the first miner that finds the correct hash value will generate a new block. In addition, there are other consensus algorithms such as proof of stack (PoS) 2 , delegated proof of stack (DPoS) 3 , and delegated proof of stake with node's behaviour and Borda count(DPoSB) 4 . They do not rely on computing power and thus could lower the power consumption. There is also a Byzantine algorithm 5 that achieves consensus in communication in the presence of malicious nodes.
Digital signatures are an essential application of public-key cryptography. Encryption methods commonly used in the digital signatures of a classical blockchain are Rivest-Shamir-Adleman (RSA) 6 and elliptic curve cryptography (ECC) 7 . These well-developed encryption algorithms are too complex for classical computers to crack, ensuring the security of the digital signatures. However, Shor and others have found that a quantum algorithm can effectively solve the integer decomposition problem and the discrete logarithmic problem 8 , which are the critical parts of the encryption methods. In this case, the security of blockchain technology based on the digital signatures is under the threat of quantum computation.
Several physical systems have been developed to realize quantum computation. Quantum supremacy was demonstrated on a programmable superconducting quantum processor with 53 qubits by Google 9 . Pogorelov et al. 10 performed 50-qubit ion trap quantum computing. Moreover, Zhong et al. 11 demonstrated a 76-qubit quantum computer with photons for boson sampling and a programmable quantum nanophotonic chip with many photons 12 .
Therefore, it has become urgent to develop new methods to protect against the threat of quantum computing. One effective approach is to develop quantum cryptography techniques based on the unique nature of quantum physics. For example, the quantum signature technology based on quantum state computational distinguishability with fully flipped permutations ( QSCD ff ) problem, utilizing the complexity of QSCD ff problem for quantum computation, can guarantee the security of the signature process. In addition, there are also quantum key distribution (QKD) techniques used in quantum information, such as the most famous BB84 protocol 13 . These techniques help to improve security in communication processes even in the presence of quantum computation.
In this case, these algorithms can be involved in blockchain technologies, which further improve system securities. Several attempts have been made. For example, quantum key distribution (QKD) techniques, such as the most famous BB84 protocol 13 , used in quantum information have been applied to blockchains 14 ; quantum entanglement in time has been used to produce blocks 15 , which is combined with quantum signature algorithms 16 . However, quantum signatures are not used in the QKD blockchain algorithm; a blockchain generated by the use of entanglement in time cannot trace back the transaction information, and thus the improvement in the overall security of the blockchain is poor.
To guarantee blockchain network security under quantum supremacy, we propose a quantum blockchain method that combines the DPoSB consensus algorithm 4 and quantum signatures established with quantum signature technology based on quantum state computational distinguishability with a fully flipped permutation ( QSCD ff ) problem 17 . The former is developed from DPoS, which keeps the voting system and considers the influence of malicious behaviours in votes to improve security when malicious nodes are in a blockchain system. A quantum signature method using a quantum asymmetric cryptography approach is a signature method designed based on the complexity of the QSCD ff problem for quantum computation to guarantee the security of the signature process. Here we combine them together. The blockchain generates blocks by DPoSB and signs transactions by a quantum one-way function 18 based on the QSCD ff problem. Mining here is not necessary to make great savings on computing resources, which greatly saves computing resources and increases the speed of block generation. Different from other quantum signature methods 14,15,16 , this method is not constrained 19,20 by probabilities and does not require a large number of one-time pads, which thus saves substantial communication overheads. Discussions about security models and quantum information-theoretical security are introduced in the security analysis. It can be found that our blockchain is secure even in the malicious adversary model. Our results show that this signature method in quantum blockchain is more secure than other quantum signatures. In this paper, the data structure of blockchain network is introduced in "Data structure of the blockchain " and our quantum blockchain section algorithm is analyzed in "Quantum blockchain algorithm" section. Then, the security of the blockchain algorithm is analyzed in "Security analysis of the blockchain" section, and the blockchain algorithm is compared with other existing quantum blockchains in "Comparison with other quantum blockchain signature methods" section. The conclusion is given at the end.

Data structure of the blockchain
A block acting as a unit in our blockchain system is constructed by a block header and a block body, as shown in Fig. 1. The information in the block header contains the address of the current block, the address of the previous block and the timestamp. The block body contains the transaction information that has passed through the quantum signature verification process. Due to the vital point of DPoSB, blockchain nodes do not need to participate in mining; namely, there is no computing force competition; thus, the hash value in the block is not necessary and can be replaced with the explicit address. We can begin from the block in the end to find the desired information according to the block addresses. Figure 1. The data structure of the quantum blockchain. The block header contains the address of the current block, the address of the previous block and the timestamp. The block body contains the transaction that has passed through the quantum signature verification process. The arrows between two blocks indicate that we can find one block according to its next block.

Quantum blockchain algorithm
In the blockchain, the signer generates the transaction and then uses a private key to sign, and the receiver authenticates the transaction by using the signer's public key to ensure transaction security in the aspect of cryptography. First, our quantum blockchain network contains N nodes, and n ( N>2n) witness nodes are elected to generate blocks in turn by DPoSB 13 . Then the nodes sign transactions through a quantum one-way function based on the QSCD ff problem. The witness nodes verify the transactions signed by the nodes and package the transactions into blockchain network if it passes through the verification process.
Blocks created by DPoSB. One key characteristic of DPoSB is voting, which is developed from DPoS. By the application of voting, the computing source originally used for mining can be largely saved. In voting, the n nodes with the highest votes are elected as the witness nodes responsible to generate blocks in turn. Let us assume that there are N nodes in a blockchain system. First, 2n ( N>2n) candidate nodes are elected by voting, and then n witness nodes among the candidate nodes are elected. However, sometimes there are some malicious nodes appearing in the system, which hinder the generation of blocks.
There are four types of malicious behaviours denoted by r . Each r is distributed by a weight Q r and the maximum threshold T r is the largest number of times the behaviour r is accepted in the system. Then DPoSB introduces malicious behaviour punishment calculation in the algorithm to address this issue and the mechanism of the Borda score to fairly select the witness nodes. We calculate the malicious behaviour weight ratio N Bw i for the i th node: where t ir represents the number of times the behaviour r is performed by the i th node makes.
The valid vote to define the i th node is: where j indicates the number of votes by j th node for i th node in round t of block generation (all participants produce a block once as the end of one round).
Then, we sort the valid votes for all nodes, and 2n nodes with the highest votes are elected as the candidate nodes.
The next step is to select n witness nodes from these candidate nodes. We construct the preference matrix: Then we have the k th node's preference value for the i th candidate node: r k i = N j=1 r k ij and obtain the Borda score matrix: We calculate the cumulative Borda scores for each candidate node: r i = N k=1 r k i . The Borda scores are sorted for all candidate nodes, and the n candidate nodes with the highest scores are elected as the witness nodes.
The witness nodes can generate blocks in turn, as shown in Fig. 2.
Transaction signing and verification process. Then the nodes sign transactions through a quantum one-way function based on the quantum state computational distinguishability with fully flipped permutations QSCD ff problem. In quantum algorithms, quantum gate operations 21 can be performed on qubits, which include Hadamard ( H ), qubit flip ( X ), phase flip ( Z ) operations. The quantum state of a single qubit can be represented as |ϕ� = sinθ |0� + cosθ e ia |1� , where |0� and |1� are the counterparts of 0 and 1 in the classical computation. A In the quantum algorithm, signing and verification processes are necessary to ensure a transaction. Here, we use the quantum one-way function based on the QSCD ff problem to finish the signing process.
A brief introduction to the QSCD ff question. We define N * = { n ∈ N , n is even and n /2 is odd}. For each n ∈ N * , S n is used to represent a symmetric group of degree n . Then we use κ n = { π ∈ S n : π 2 =id and ∀i ∈ {1, 2, · · · , n} [ π(i) = i ], where id represents all the identity permutations. Each π can be represented as an odd permutation that is the product of n /2 disjoint transposition 22 .
Then we have |κ n | = n! √ 2 n and the following definition: For each π ∈ κ n , there are quantum states ρ + π (n) and ρ − π (n): For a symmetric group of degree n , each group element can be represented as an arrangement with n elements, such as a group element (1, 2, 3) in S 3 , which can be represented as quantum states: |1 �|10 �|0 �.
The QSCD ff problem is to distinguish the following two quantum states for each n ∈ N * :ρ + π (n) ⊗P(n) , ρ − π (n) ⊗P(n) , where the P(n) represents a polynomial. Ref. 22 has proven that if π ∈ κ n is random and unknown there is no quantum algorithm that can solve the QSCD ff problem with non-negligible advantage. However, this problem can be quickly solved with the solution of π so that π would serve as a trapdoor in the quantum signatures.
A distinguishing algorithm for the QSCD ff problem.
Step 1 The quantum circuit used here is shown in Fig. 3a.  (|0 � − |1 �) = |− � and π represents the π operation π|σ � = |σ π � . We perform the quantum circuit from left to right. (b) The quantum circuit of the ρ + π (n) generation algorithm, where "if π " means "if we read |π � from this register" and "random σ " means "perform a random permutation σ on this register". (c) The quantum circuit of the conversion algorithm, where we perform the following "convert" operation: convert[ 1 www.nature.com/scientificreports/ (a device used to preserve one or more quantum states) of the quantum circuit, and |x � is input into the second register. The Hadamard operation ( H ) is performed on |0 � , to obtain: Step 2 The C π operation is performed on the second register controlled by the first register to obtain: Step 3 The H operations is performed on the first register.
Step 4 The Z measurement is performed on the first register, and ρ + π (n) generating algorithm. ρ + π (n) can be generated by the following steps. The quantum circuit is shown in Fig. 3b.
Step 1 We prepare the quantum state |0 �|id � , input |0 � into the first register, and input |id � into the second register. Then, we perform the H operation on the first register, and obtain |+ � and the |id �.
Step 2 The C π operation is performed on the second register and controlled by the first register.
Step 3 If the second register reads |π � , we perform a qubit flip operation ( X ) 21 on the first register.
Step 4 A uniformly random permutation σ is performed on the second register.
Step 5 The final state of the second register is output.
Signing transaction process. Below we use an example to show the detailed processes. Alice serves as a signer and Bob as a verifier. Jack acts as the private key generator (PKG), which is a trusted node in the blockchain system, and never exposes the signer's private key or imitates the signer to sign messages. Alice is ready to send a transaction message that she encodes as a bit string TA(m 1 , m 2 , · · · , m n ) , m i ∈ {0, 1} . The transaction can be signed by following steps 17 .
Key generation phase.
Step 1 Alice randomly selects an odd permutation π ∈ κ n as the private key, where n is the length of the bit string. Then, the unconditionally secure deterministic secure quantum communication (DSQC) protocol 23 is used to write the private key in the blockchain to secretly share it. In this case, Jack secretly holds (ID, π) pair, where ID is Alice's identity code.
Signing phase.
Step 2 Through the conversion algorithm, Alice encrypts t as a quantum sequence: , as shown in Fig. 4b.
Step 4 After receiving {TA, ID, ρ ′ �, PK ′ �} , Alice exposes the location of the decoy particles. Bob checks the particles with the corresponding base. If there is no error, Bob takes the next step, and otherwise the signature generation phase is restarted.
Step 5 Bob performs an eavesdropping check, drops all the decoy particles and finally holds {TA, ID, |ρ �, |PK �} as the quantum signature of Alice.
Step 4 Jack discards all decoy particles and recovers ρ ′′ � PK ′′ � to |ρ �|PK m �. (a) Alice repeats the ρ + π (n) generation algorithm n times with her private key to obtain the public key, where the H, "if π " and "random σ " operations are the same as the operations in Fig. 3. (b) Alice uses this quantum circuit to obtain encrypted sequence |ρ � , where we perform a "C-convert" operation: if |t i � = 1 , we perform the "convert" operation shown in Fig. 3c; if |t i � = 0 , we do not perform any operation. (c) The red balls represent decoy particles, the white balls represent encrypted sequence |ρ � , and the yellow balls represent public key |PK � . Alice inserts decoy particles randomly into |ρ �|PK � and obtains the sequence |ρ ′ �|PK ′ � to check for eavesdropping. (d) Bob uses this quantum circuit to obtain |PK m � , where every "C-convert" operation is the same as the "C-convert" operation in (b). For every ρ i π,m , if |0 � is read from the first register, then m i = 0 ; if |1 � is read from the first register, then m i = 1 . (c) Jack uses this quantum circuit to obtain a bit string t ′ . For every ρ i , if |0 � is read from the first register, then t i = 0 ; if |1 � is read from the first register, then t i = 1. www.nature.com/scientificreports/ Step 5 Jack recovers the private key π according to the identity code ID , and obtains the bit string m by dis- , as shown in Fig. 5b. Then, permutation π is performed on m , and t = π(m) is obtained.
Step 6 Jack distinguishes ρ i , and obtains the bit string t ′ , where , as shown in Fig. 5 (c).
If t i = t ′ , Jack claims validation and Bob accepts the signature.
Package the transaction into blockchain. In actual applications, the witness codes elected under DPoSB should be considered trusted signature verifiers. After more than 2/3 of the witness nodes accept the signature, the generated transaction information TA is valid and packed into the block generated by the current witness node, as shown in Fig. 6. However, when the verifying phase is completed, if less than 2/3 of the witness nodes accept the signature, TA is discarded by the current witness node.

Security analysis of the blockchain
Security model. Before reviewing the security of our blockchain, we would explain two security models used in information theory and cryptography 24 .
Semi-honest adversary model Suppose there are some semi-honest adversaries in a system and they follow a protocol correctly but may keep some necessary information to infer additional information later.
Malicious adversary model Suppose there are some malicious adversaries in a system and they may not only keep necessary information to infer additional information, but also attempt to perform breaking-protocol malicious behaviours to get additional information.
In the block generation process, a semi-honest adversary can only keep public information of the block header and block body. Then he cannot infer any useful additional information, because there are no secrets in the public information. In the signing process, a semi-honest adversary can attempt to infer the private key of a signer (the only secret), which however cannot work as shown in "Security of private keys" Section. Therefore our blockchain can keep security in the semi-honest adversary model.
We will demonstrate the security in the malicious adversary model in the next three sections. Generally, when an algorithm or a protocol can keep security in the malicious adversary model it is safer.

Security of the generation of blocks.
Consensus algorithms are used in the generation of blocks, and different consensus algorithms have distinct security levels. There are three main breaking-protocol attacks in this process, which belong to the malicious adversary model: 1. Double-spending attacks 1 . 2. Attacks that crack the hash value in a short time 14 . 3. Nodes that disturb the generation of blocks on purpose 13 . Then we will explain how our blockchain has robustness in the block generation process to these attacks in the malicious adversary model.
Attacker nodes can forge another blockchain secretly to forge information in blocks, which is defined as double-spending attacks. The success rate of this attack is higher when the computing force is larger. The success rate becomes 100% when the computing force of one node is larger than half of the total computing force of the blockchain system. However, this attack can be defended against in our blockchain algorithm because it is based on the computing force that is not needed in our algorithm.
An attack that cracks the hash value in a short time is a special attack based on a quantum computer. The quantum computer can use quadratic acceleration to crack the hash value through the Grover algorithm 25 , which makes nodes that have quantum computers dominate the blockchain systems. However, this attack is still based on computing force, so it can be defended in our blockchain algorithm.
As shown in "Blocks created by DPoSB" Section, in blockchain systems, some nodes may intentionally disturb the generation of blocks. In the DPoSB algorithm, malicious behaviours can be recorded by blockchain systems, and these records have impacts on the nodes' scores during the elections. Because the chance that a Figure 6. Transactions verified by 2/3 of witnesses can be packaged into a blockchain by the present witness, where the data structure of the blocks is the same as the data structure in Fig. 1, and TA x is a valid transaction that needs to be packaged. www.nature.com/scientificreports/ node is elected as a witness is smaller when it has more malicious behaviours, our blockchain algorithm can also defend against this attack.
Quantum information-theoretical security. In quantum asymmetric encryption, an encryption has quantum information-theoretical security if the quantum cyphertexts have computational indistinguishability 26 . We can claim that two quantum ensembles ρ 1 and ρ 2 are computationally indistinguishable, if for every probabilistic polynomial algorithm A , every positive polynomial P(.) and sufficiently large positive integer n the following inequation can be satisfied 26 : where P r (.) represents the probability. In our blockchain algorithm, the cyphertexts are ρ + π (n) and ρ − π (n) . Then we define that ρ 1 = ρ + π (n) ⊗P(n) , ρ 2 = ρ − π (n) ⊗P(n) and need to prove: Assume that we have a probabilistic polynomial algorithm A l , which makes: It means we have an efficient algorithm to distinguish signature cyphertexts ρ + π (n) from ρ − π (n) efficiently, corresponding to solving the QSCD ff problem. However, according to the hardness of the QSCD ff problem as proved in ref. 22 , the problem cannot be solved in polynomial time. Thus, it can be claimed that our blockchain has quantum information-theoretical security.
Security of the signing process. The malicious attacks which can be used in this process are eavesdropping, forging, repudiation and interception. Then we will explain how our blockchain can have robustness in the signing process to these attacks in the malicious adversary model.
Security of private keys. The security of private keys should be assured in two ways.
First, it has been proven that no quantum algorithm can crack the private keys of signers in polynomial time when there is no private key π 22 because one cannot distinguish signature cyphertexts ρ + π (n) from ρ − π (n) efficiently, as discussed in "Quantum information-theoretical security" Section.
Second, because private keys are selected from κ n and |κ n | = n! √ 2 n , the attacker only has a chance of √ 2 n n! to obtain the private keys (note that the divergence of n! is far stronger than √ 2 n ). In this case, the success rate of brute attacks is sufficiently small, which means that the success rate of signatures randomly generated by attackers is negligible.
Security against eavesdropping. As mentioned above, we can use the BB84 13 protocol to defend against eavesdropping. Because of the particularity of quantum states, eavesdropping can result in the collapses of quantum states and destroy the decoy states. By the second checkout process in BB84, the verifier could determine if there is any eavesdropping through the measurement of decoy states. In addition, eavesdropping by cloning signatures is not possible because of the quantum no-cloning theorem 21 .
Security against forging. There are two forging attack approaches. The first is forging signatures by using the transaction information of signers, and the second is forging the transaction information of signers. In the first approach, a signer generates transaction information TA and public key |PK � and then uses the private key to generate signature |ρ 1 � . An attacker wants to forge a signature with TA and the signer's private key, which makes |ρ 1 � � = |ρ 2 � . According to the signature algorithm mentioned above in section "Transaction signing and verification process", because of the uniqueness of the output of the ρ + π (n) generating algorithm, we have |ρ 1 � = |ρ 2 � , and thus, the signatures cannot be forged.
In the second approach, a signer generates transaction information TA1 and public key |PK � . An attacker wants to forge the signer's transaction information by turning it into TA2 = TA1 to make the signature of TA2 pass the verification process. According to the security of the private keys mentioned in section "Security of private keys", attackers have no way to generate a valid signature when they have no signers' private keys. Therefore, transaction information cannot be forged. In Conclusion, the forging methods mentioned above cannot be performed.
Security against repudiation. Repudiation is that attackers repudiate signatures to make signers fail in the signing process.
According to the signature algorithm mentioned above in section "Transaction signing and verification process", an attacker has no access to verify the signatures when they are not a witness; hence, an attacker cannot repudiate signatures. When an attacker is a witness, Jack can automatically pass through the signature if verification succeeds. In this way, an attacker still cannot repudiate the signatures because Jack is a trusted node and determines whether a signature can pass through the verification process.
. www.nature.com/scientificreports/ Security against interception. Interception is that attackers forge information through intercepting information. According to the signature algorithm mentioned in section "Transaction signing and verification process", messages, including TA, ID, ρ ′ �, PK ′ �, ρ ′′ �, PK ′′ � and the location information of decoy particles, can be intercepted by an attacker.
In the signing phase,TA, ID, ρ ′ �, PK ′ � is first intercepted. Then, to avoid the suspects of the signer, the attacker has to forge a new message,TA1, ID, |ρ 1 �, PK ′ � , to pass the verification process, which is a man-inthe-middle attack. According to the analysis mentioned above in section "Security against forging", even if the attacker passes through the decoy particle check process, the forging messages still cannot pass through the verification process because the attacker has no signer's private key.
In the verification phase, the attacker first intercepts TA, ID, ρ ′′ �, PK ′′ � . Then, to avoid the suspicion of the signer, the attacker has to forge a new message TA2, ID, |ρ 2 �, PK ′′ � to pass through the verification process, which is a man-in-the-middle attack too. In this way, the reason for a forging failure is the same as that for a signing phase failure.
Security issues from actual applications. In actual applications, there are several other security problems for businesses, organizations and operations. According to recent research progresses 27−30 , some kinds of techniques, such as Process-Data-Infrastructure (PDI) model 27 , can be incorporated into blockchain systems to figure out these problems and secure blockchain applications.
According to the PDI model 27 , system security issues can be classified to three levels: process level, data level and infrastructure level. The blockchain security in the process level includes operation standards, smart contracts, implementation security and fraud detection. The data level is composed of consensus algorithms, encryption, authentication, key management and access control while the infrastructure level includes supernode server, terminal devices and network. In the above sections we have discussed the blockchain security issues in the data level, and our blockchain can be combined with the modern blockchain frame (such as the PDI model) to enhance the security of the blockchain system. In blockchain-secured smart manufacturing 28 , a specific PDI model can be realized like the following architecture: in the infrastructure level, a blockchain platform (such as Ethereum, Hyperledger, and EOS) is selected to manage terminals and networks. The platform should provide distributed data structure, interaction mechanisms, and computing paradigms. Then in the data level, our blockchain algorithm can be used to generate blocks (by consensus algorithm) and sign the transactions (by quantum digital signature) safely. More complex computations are performed safely with privacy computing (such as secured multi-party computation 24 , federated learning 31 and trusted execution environment 32 ), which makes blockchain compute functions on private data with them unexposed. Then a computer language supported by the blockchain platform is used to write smart contracts in the process level. Programmable manufacturing devices can be deployed in necessary places, and relevant data are collected through internet of things (IoT) 33 , which are transmitted to blockchain for next processing.

Comparison with other quantum blockchain signature methods
In actual applications of blockchain technology, security is of the most importance; thus, we would use the safest signature algorithm as much as possible. Then, we will demonstrate that the signature algorithm in our blockchain algorithm is safer than other quantum-resistant signature algorithms. We assume that the decoherences of quantum circuits with outside environments can be ignored.
Step 1 The signer selects a random quantum state from the four quantum states and distributes the nonorthogonal sets containing this quantum state according to the corresponding bit in the code. For example, if a 1 = 1 and the signer selects |0 � , we distribute the set {|−�, |0�} to the first quantum state; if a 1 = 0 and the signer selects |0 � , we distribute the set {|0�, |+�} to the first quantum state. This process is repeated n times; then, the signer sends the quantum states Q = (Q 1 Q 2 ...Q n ), Q i ∈ {|0�, |1�, |+�, |−�, } and single bit information m to the verifier and the authenticator by quantum channels.
Step 2 The verifier and the authenticator choose an X or Z basis randomly for every quantum state Q i and then take the measurements of these quantum states {Q i }.
Step 3 The signer sends sets to the verifier and the authenticator by traditional channels.
Step 4 The verifier and the authenticator compare every result of quantum state Q i with their sets. If one measurement result is orthogonal to one quantum state in the set, the conclusive bit a i can be obtained. For example, if we receive set {|0�, |+�} and the measurement result is |−� , we can know that the signer sends 0; however, if the measurement result is not orthogonal to any quantum state in the set, the code the signer sent is inconclusive.
Step 5 The signer sends a bit string a to the verifier and authenticator. After receiving the bit string a , the verifier and the authenticator compare it with their conclusive bit string and compute the error rates E(a ′ ) and E(a ′′ ) , respectively (we take inconclusive bits as right bits). If both E(a ′ ) and E(a ′′ ) are larger than threshold µ , the signature fails; otherwise the signature can succeed.
It can be demonstrated that this signature algorithm cannot defend against interception. An attacker can perform the next procedures to forge a signer's signature. www.nature.com/scientificreports/ Step 1 The signer generates single bit information m , bit string a and quantum state Q and then sends them to the verifier and the authenticator.
Step 2 The attacker intercepts the messages {m, a, Q} ; generates single bit information m ′ , bit string a ′ and quantum state Q ′ ; and then sends {m ′ , a ′ , Q ′ } to the verifier and the authenticator.
Step 3 The signer sends sets Q1 of Q to the verifier and the authenticator.
Step 4 The attacker incepts messages Q1 and sends sets Q2 of Q ′ to the verifier and the authenticator.
Step 5 The verifier and the authenticator perform step 5 in the signature algorithm.
Step 6 Now, the attacker forges a perfect signature of the signer because it is simple to generate {m ′ , a ′ , Q ′ } and Q2 , so the verifier and the authenticator can pass the signature forged by the attacker with overwhelming probability. A forging attack can work in this way.
As mentioned in section "Security against interception", we have demonstrated that the signature algorithm in our blockchain algorithm can resist interception and thus is safer than the algorithm in this section.
Comparison with a signature algorithm based on quantum entanglement. Suppose there are three characters that take part in this algorithm 16 : the signer, the verifier and a trusted node blockchain. They perform the next procedures to complete this signature algorithm.
Step 1 The blockchain generates sufficient Bell states: Step 2 The blockchain randomly selects a sufficiently long substring A 1 from (A 1 1 , A 1 2 , ..., A 1 n ) and sends it to the signer as his private key; the blockchain randomly selects a sufficiently long substring A 2 from (A 2 1 , A 2 2 , ..., A 2 n ) and sends it to the verifier as the signer's private key; the blockchain randomly selects a sufficiently long substring B 1 from (B 1 1 , B 1 2 , ..., B 1 n ) and sends it to the verifier as the private key; the blockchain randomly selects a sufficiently long substring B 2 from (B 2 1 , B 2 2 , ..., B 2 n ) and sends it to the signer as the verifier's private key.
Step 4 The signer performs controlled-NOT(CNOT) on the first x qubits of B 2 , the first y qubits of A 1 , quantum coin m and hash sequence h: where m i = 1 − m i andh i = 1 − h i . Then, the signer obtains quantum coin m ′ and hash sequence h ′ and sends m ′ and h ′ to the verifier.
Step 5 The verifier performs CNOT on the first x qubits of B 1 , the first y qubits of A 2 , quantum coin m and hash sequence h ′ : Then, the verifier obtains quantum coin m ′′ and hash sequence h ′′ , computes hash(m ′′ ) and judges if it is equal to h ′′ . If hash(m ′′ ) = h ′′ , the signature is accepted; otherwise, the signature is rejected.
It can also be demonstrated that this signature algorithm cannot defend against interception. An attacker can perform the next procedures to forge a signer's signature.
Step 1 As shown in the signature algorithm mentioned above, the blockchain generates substrings A 1 , A 2 , B 1 , and B 2 and sends A 1 and B 2 to the signer and A 2 and B 1 to the verifier.
Step 2 The attacker intercepts A 2 and B 1 through a man-in-the-middle attack, imitates the blockchain to generate substrings C 1 , C 2 , D 1 , and D 2 , retains substrings C 1 and D 2 , and then sends substrings C 2 and D 1 to the verifier.
Step 3 In this moment, the attacker's substrings entangle the signer's and the verifier's at the same time, so the attacker can forge any transaction messages and the signatures of the signer and the verifier.

Conclusion
We propose a quantum blockchain algorithm that generates blocks by DPoSB and signs the transaction information with a quantum one-way function based on the QSCD ff problem. By the stake vote and punishing the malicious behaviours of DPoSB and asymmetric quantum encryption, the fairness, efficiency and security of the blockchain system can be improved. Security in the semi-honest adversary model and the malicious adversary model can be realized in our blockchain based on quantum information-theoretical security. Furthermore, we demonstrate the security of our blockchain algorithm compared with other quantum blockchain algorithms. Our quantum blockchains provide a safe platform that could decrease the costs of various operations and transaction activities. We should mention that the trusted node used in our blockchain has a larger weight in the network www.nature.com/scientificreports/ and therefore the necessity of the trusted node may weaken decentralization. Quantum signatures which do not require the trusted node could be developed in future researches to solve this problem. Moreover, quantum blockchains could be based on quantum privacy computing, which would further enhance the security of actual blockchain applications. In the near future, quantum blockchains will play an important role in social and financial areas that have increasing demands for transaction securities.