1 Introduction

Propagation of communication over public channels becomes very much popular and ensures that authorized access is essential [1]. The rapid growth in multimedia technology, and digital contents such as images, video, audio, etc. play imperative role in communication [2]. To fulfill the privacy prerequisite of such contents, worthy security tools have to be developed [3]. The traditional number theory-based algorithms, such as AES and DES, projected for encryption, but these algorithms rely on higher computational power and time complexity, so these found to be not suitable for digital images. Images possess resistance and redundancy among neighboring pixels, which mark difficulties for number theory-based procedures to tackle the real-time protection performance due to necessity of high computational complexity. In literature review, AES is vulnerable to square, side-channel, and differential attacks [4].

Different algorithms have been developed in the literature to provide the security to digital contents based on confusion and diffusion with multiple rounds and chaos theory [5,6,7,8,9,10,11,12,13,14,15,16,17]. The idea of quantum computers evolves nowadays and it is a serious threat for classical number theory-based algorithms. The conventional communication is a fine submission of 0 or 1 through public channels and several algorithms [18,19,20,21,22, 23] have been proposed that prevent the leakage of information as well as provide defense against information attacks. These algorithms were considered to be secure as long as quantum computers not available publically. In the age of quantum information, the idea of fast computation with several complication levels gets more legalistic due to quantum parallelism. The performance of a single-quantum computing machine is much better than hundreds of classical computers perform operation parallel. Quantum parallelism is performed by spin operations of quantum mechanics and this leads to a new paradigm of computing. The cryptography of prime factorization will fall as the computational complexity resolved by quantum machines in m-seconds [24]. Thirty classical machines having CPU 2.2 Ghz perform parallel operations for a year to factor 193 digits, while a single-quantum computer with the same specification as classical machine to calculate factors 193 digits in 0.1 s [25]. Quantum calculations allied in several branches of science nowadays and a novelty in image processing, computational complications, and pattern recognition. The feasibility of quantum mechanics properties of superposition and entanglement applied on the traditional cryptosystem at fundamental level has been discovered in scientific ages.

The first key distribution using quantum protocol was published in 1984 by Charles Bennet and Gilles Brassard named as BB84 [26]. Further advancement took place in 1991, when Ekert proposed the Einstein–Podolsky–Rosen (EPR) entanglement theory, whose security was based on Bell’s inequality [27, 28]. To transfer a qubit into an elementary particle form one side to another, either on free-space or fiber optics utilized by quantum channels, whereas both sides cannot be protected from illegitimate attempts [29]. Quantum channels are considered to be useful for traditional system security in the light of quantum standards of uncertainty principle by Heisenberg and no-cloning theorem that keeps the whole communication system unbroken [30,31,32,33,34,35,36,37,38,39,40].

Quantum algorithms processed into two channels; one is ERP (entangled state) channel and the second is qubit channel. In this article, we perform entanglement phenomenon on spin matrices to provide security to digital contents. Section 2 of this article provides the basic concept of spin matrices and their entanglement, and finite-state machine at which the entangled matrices applied. Section 3 demonstrates the experimentation of algorithm on standard images. Section 4 comprises of different analyses’ measures and comparison with the existing techniques. The final remarks about the article are presented in Sect. 5.

2 Initiations

The brief demonstration of spin matrices specified in this section, which have been devised in the light of rotation operators in quantum dynamics literature [41,42,43]. We pass the entangled matrices through finite-state machine [43, 44]. The spin matrices for rotation operators x, y, and z are as follows:

$$\begin{array}{*{20}{c}} {{R_x}(\theta )=\left( {\begin{array}{*{20}{c}} {\cos \tfrac{\theta }{2}}&{i\sin \tfrac{\theta }{2}} \\ {i\sin \tfrac{\theta }{2}}&{\cos \tfrac{\theta }{2}} \end{array}} \right),}&{{R_y}(\theta )=\left( {\begin{array}{*{20}{c}} {\cos \tfrac{\theta }{2}}&{\sin \tfrac{\theta }{2}} \\ { - \sin \tfrac{\theta }{2}}&{\cos \tfrac{\theta }{2}} \end{array}} \right),}&{{R_z}(\theta )=\left( {\begin{array}{*{20}{c}} {{e^{i\tfrac{\theta }{2}}}}&0 \\ 0&{{e^{ - i\tfrac{\theta }{2}}}} \end{array}} \right).} \end{array}$$

The image encryption algorithm design appeared in Fig. 1 and entanglement of spin matrices in two dimensions are as follows:

Fig. 1
figure 1

Proposed encryption algorithm

Fig. 2
figure 2

Layer-wise encryption analyses of pepper image. a Plain pepper image, bd red, green, and blue layers of plain image. e Encrypted pepper image, fh red, green, and blue layers of encrypted image

Fig. 3
figure 3

Layer-wise encryption analyses of airplane image. a Plain airplane image, bd red, green, and blue layers of plain image. e Encrypted airplane image, fh red, green, and blue layers of encrypted image

$$\begin{array}{*{20}{c}} {I=\left( {\begin{array}{*{20}{c}} 1&0 \\ 0&1 \end{array}} \right),}&{X=\left( {\begin{array}{*{20}{c}} {\cos \tfrac{\theta }{2}}&{\sin \tfrac{\theta }{2}} \\ {\sin \tfrac{\theta }{2}}&{\cos \tfrac{\theta }{2}} \end{array}} \right),}&{\,Y=\left( {\begin{array}{*{20}{c}} {\cos \tfrac{\theta }{2}}&{\sin \tfrac{\theta }{2}} \\ { - \sin \tfrac{\theta }{2}}&{\cos \tfrac{\theta }{2}} \end{array}} \right),}&{Z=\left( {\begin{array}{*{20}{c}} {{e^{\tfrac{\theta }{2}}}}&0 \\ 0&{{e^{ - \tfrac{\theta }{2}}}} \end{array}} \right)} \end{array}.$$

Entangle these \(2 \times 2\) spin matrices to produce a set F of \(4 \times 4\) entangled matrices, \(F=\{ {F_i} \in {F_{4 \times 4}}(I,X,Y,Z\,),i=1,2,...,24\}\).

We will get 24 matrices \(F=\{ {F_1},{F_2},{F_3},...,{F_{24}}\} .\)

The phase and key were kept secret. FSM or FSA (finite-state automation) used here with a limited number of conditions. The input symbols are digits defined by key. String belongs to image can be treated by deterministic finite-state or non-deterministic finite-state automaton (NDFA). We considered here NDFA whose output depends on the transitions [43].

3 Experimentation

The dimension of plain image \(P(i,j)\) is \(M \times N\), where \(P(i,j)\) is the ith row and jth column pixel value.

  1. 1.

    Transform the image layers dimension into \(4 \times n\) direction.

  2. 2.

    Specify the criteria for the selection of phase or simply phase kept secret between two parties for encryption and decryption and resolve the entangled matrices by placing phase information.

  3. 3.

    Distribute the key secretly to encrypt or decrypt the data. Different spin matrices operated by FSM with respect to key.

  4. 4.

    Transform the encrypted layers direction into plain image dimension.

  5. 5.

    All the encrypted layers combine together to form a single ciphered image.

We consider here the phase value \(\theta =365.86\) and key K = 68. FSM converts the key into bits and performs encryption under 24 spin matrices, as shown in Table 1.

Table 1 Finite-state machine operation perform spin matrices at given key
$${\text{Key}}={\text{Binary}}\left( {68} \right)=1000100.$$

where P is the plane image and the final cipher image at the output of FSM is C7.

The experimentation results of designed technique on miscellaneous images of size 512 × 512 of SIPI image database is as follows (Figs. 2, 3).

4 Performance analyses

We have accomplished a few trials on th standard images to affirm the performance and security for the proposed scheme. These trials involve the susceptibility enquiry, factual investigation, and loophole assessment for encoded images. Each of these trials deliberated in detail in the associated subsections.

4.1 Histogram consistency analyses

To estimate the security of digital contents, histogram consistency of enciphered images is necessary [30]. We compute the histograms of two 256 color-level images of size \(512 \times 512\) that have varied ingredient. Refer to Figs. 4 and 5, plain image histograms comprise extensive sharp rises after sharp decreases and the enciphered image histograms under projected structure are genuinely uniform and pretty much change from the plain image histograms, which mark assessable attacks difficult (Figs. 6, 7, 8).

Fig. 4
figure 4

Layer-wise histograms of pepper image. a Plain pepper image histogram, bd Red, Green and Blue layers’ histogram of pepper image. e Encrypted pepper image histogram, fh Red, Green and Blue layers’ histogram of encrypted pepper image

Fig. 5
figure 5

Layer-wise histograms of airplane image. a Plain airplane image histogram, bd red, green, and blue layers’ histogram of airplane image. e Encrypted airplane image histogram, fh red, green, and blue layers’ histogram of encrypted airplane image

Fig. 6
figure 6

Correlation of plain and encrypted Pepper image. ac Correlation of plain image in horizontal, vertical, and diagonal direction. df Correlation of encrypted image in horizontal, vertical, and diagonal direction

Fig. 7
figure 7

Correlation of plain and encrypted Airplane image. ac Correlation of plain image in horizontal, vertical, and diagonal direction. df Correlation of encrypted image in horizontal, vertical, and diagonal direction

Fig. 8
figure 8

Normalized cross-correlation surface plots of Pepper and Airplane image. ac Surface plot of plain, encrypted, and cross-correlation of plain and encrypted Pepper image. df Surface plot of plain, encrypted, and cross-correlation of plain and encrypted Airplane image

4.2 Randomness analyses

Entropy and NIST analyses are the most prominent feature of randomness. On the basis of random analysis, events from set of probable discrete events {x1, x2 ,…, xi} allied with probabilities {p(x1), p(x2),…, p(xi)}, then the average production of basis information is called entropy:

$$H= - \sum\limits_{{i=0}}^{{{2^N} - \,1}} {p({x_i}){{\log }_2}p({x_i})} ,$$

where xi is the basis image and \({2^N}\) is the collective data. The estimated Shannon entropy is 8 for perfectly indiscrimination of data. Several standard images and their ciphers entropies accounted in Table 2 and cipher images entropy esteem are very close the theoretical esteem 8. This indicates that the information leakage in encryption process is extraneous and the mechanism is protected upon entropy attacks [17]. We also compare the information entropies of enciphered images under the proposed scheme with latest developed techniques in Table 2.

Table 2 Entropy analyses of standard plain and ciphered images of size \(512 \times 512\)

The security of cryptosystem has a few possessions, e.g., extensive period, identical delivery, extraordinary complexity, and efficiency. With a definite aim to accomplish these requisites, we perform NIST analyses’ test. National Institute of Standards and Technology (NIST) develops Special Publication (SP) 1800 series and FIPS (Federal information Processing Standard) for cyber-security community to verify randomness introduced in their cryptosystems. We perform NIST SP 800-22 test to analyze the randomness in digital images. The enciphered Pepper image is utilized to analyze the results of NIST test and after effects of the test are appeared in Table 3.

Table 3 NIST analyses for encrypted Pepper image

4.3 Correlation analyses

It is prominent that adjoining pixels are extremely allied in directions either horizontal, vertical, or diagonal. Therefore, the strategy of encryption must abandon this bond to improve barrier contrary to assessable exploration. To affirm the affiliation among adjacent plain and ciphered image pixels, the associated technique is accomplished. Initially, 10,000 sets of two adjoining pixels from plain and corresponding ciphered image randomly selected [47]. The coefficients of correlation for each chain pairs determined by applying the following expression:

$${r_{x,y}}=\frac{{{\sigma _{x,y}}}}{{\sqrt {\sigma _{x}^{2}\sigma _{y}^{2}} }},$$

where \(x\,\,{\text{and}}\,y\) are the two adjacent pixel values at gray scale, \({\sigma _{x,y}}\) is the covariance, and \({\sigma _x}^{2}\) and \(\sigma _{y}^{2}\) are the variances of random variables \(x\,{\text{and}}\,y\) respectively.

The quantitative analysis of correlation coefficient for RGB layers is deliberated in Table 4, and presented the distribution in horizontal, vertical, and diagonal directions.

Table 4 Correlation coefficients of plain and encrypted images at RGB scale

The above-calculated coefficients among numerous pairs of enciphered images are very close to zero, and hence, the plain and ciphered images are significantly diverged from each other. The assessment of correlation coefficients calculated by anticipated scheme at gray scale with the modern techniques using the standard images are presented in Table 5.

Table 5 Correlation coefficients of plain and encrypted images at gray scale and comparison with the existing approaches
Table 6 Pixels’ similarity analyses between original and encrypted standard images

The outcomes of correlation analysis from anticipated scheme have smaller values than the projected techniques in the literature, which qualify the security measures for real-time applications.

4.4 Similarity analyses

Similarity analyses fundamentally expose the resemblance among different digital contents and the simplest digital content is image. The values of normalized cross-correlation and structure contents are quite closed to 1 for structurally similar digital contents. There are different sorts of similarity coefficient are utilized here to quantitatively find the structurally dissimilar digital contents. We investigated here different similarity measures between plain image \({P_{i,j}}\) and cipher images \({C_{i,j}}\) to approximate the structure dissimilarity among different digital contents from reference.

Structural similarity index metric (SSIM) compares the structure, luminance, and contrast between plain and cipher image. Consider the two images \({P_{i,j}}\,\) and \({C_{i,j}}\) with their mean values \({\mu _p}\), \({\mu _c}\), and the standard deviation \({\sigma _{{\text{pc}}}}\). If there is any similarity between images, the value approaches 1, while value away from 1 or approaches 0 represent the dissimilarity:

$${\text{SSIM}}=\frac{{(2{\mu _p}\,{\mu _c}\,+\,{C_1})\,(2{\sigma _{pc}}+{C_2})}}{{(\mu _{{_{p}}}^{2}\,+\mu _{c}^{2}\,+\,{C_1})\,(\sigma _{{_{p}}}^{2}+\sigma _{{_{c}}}^{2}+{C_2})}}.$$

Normalized cross-correlation (NCC) measures the similarity of pixels between two images. It is determined by the following expression:

$${\text{NCC}}=\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {\,\frac{{{P_{i,j}}\, \times \,\,{C_{i,j}}}}{{\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {{P^2}_{{i,j}}} } }}} } .\,$$

Structural content (SC) determines the amount of structural details as well as the quality of images in terms of sharpness and noise level. Higher value of SC shows the poor quality of image and it is calculated as follows (Table 6):

$${\text{SC}}=\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {\,\frac{{{P^2}_{{i,j}}}}{{\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {{C^{^{2}}}_{{i,j}}} } }}} } .$$

4.5 Difference analyses

The image quality evaluation based on pixel difference procedure executed here by calculating the mean absolute error, mean square error, and peak signal-to-noise ratio.

Mean absolute error (MAE) is the most common technique used to measure the accuracy for continues variables. It defines the average of absolute difference between plain and ciphered image. Higher the MAE esteem to enhance the security and it is defined as follows:

$${\text{MAE}}=\frac{1}{{M \times N}}\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {} \left| {{P_{i,j}} - {C_{i,j}}} \right|} .$$

MSE and PSNR compare the image encryption quality. MSE indicates the collective squared error among the plain and ciphered images, while PSNR indicates the measure of peak error:

$${\text{MSE}}=\frac{1}{{M \times N}}\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {} {{({P_{i,j}} - {C_{i,j}})}^2}} .$$

The encryption quality is acceptable by higher the MSE esteem and lower the PSNR or vice versa. The quality of ciphered images can be evaluated by utilizing the PSNR as follows:

$${\text{PSNR}}=20{\log _{10}}\left[ {\frac{{{I_{{\text{MAX}}}}}}{{\sqrt {{\text{MSE}}} }}} \right],$$

where \({I_{{\text{MAX}}}}\) is the greatest pixel approximation of image contents and the feasibility of anticipated scheme evaluated for MSE and PSNR presented in Table 7.

Table 7 Pixels’ difference analyses between plain and ciphered images and assessment with the existing approaches

4.6 Differential assault analyses

To affirm the image encryption scheme against differential assault, we require the impact of changing a single pixel in plain image and overall encrypted image and execute the number of pixels change rate (NPCR) and unified average intensity (UACI). We assumed two encoded images, whose source image just differs by a single pixel. The NPCR and UACI for two encoded images \({C_1}(i,j)\) and \({C_2}(i,j)\) can be assessed by the following expressions:

$${\text{NPCR}}=\frac{1}{{W \times H}}\sum\nolimits_{{i,j}} {x(i,j)} ,$$

where

$$x(i,j)=\left\{ {_{{1,\quad {C_1}(i,j) \ne {C_2}(i,j)}}^{{0,\quad {C_1}(i,j)={C_2}(i,j)}}} \right..$$
$${\text{UACI}}=\frac{1}{{W \times H}}\sum\limits_{{i=0}}^{{M - 1}} {\sum\limits_{{j=0}}^{{N - 1}} {\left| {\frac{{{C_1}(i,j)\, - \,{C_2}(i,j)}}{{255}}} \right|} }$$

To examine the sensitivity of plain image, we have to encrypt it first and then change one pixel randomly in the plain image. The experimental results of these assessments are provided in Tables 8 and 9.

Table 8 NPCR analyses between plain and ciphered images
Table 9 UACI analyses between plain and ciphered images

NPCR esteems using proposed technique are persistently correspondent to the perfect estimation of 1 and the assessment of differential assault analyses of anticipated process with modern approaches is also discussed in Tables 8 and 9.

This judgement illustrate that projected technique has extreme degree impatient to a trivial alteration in plain image, irrespective of two enciphered plain images which have 1− bit alteration, the two images are fairly dissimilar from each other. Hence, the anticipated strategy has greater ability to hostile the differential assaults.

4.7 Gray-level co− occurrence matrix analyses

To analyze the visual strength of proposed algorithm, gray-level co− occurrence matrix (GLCM) analyses exemplify homogeneity, contrast, and energy [53]. The homogeneity analysis for an image can be calculated using the following expression:

$${\text{Homogeneity}}=\sum\limits_{{i,j}} {\frac{{\rho \,(i,j)}}{{1+\left| {i - j} \right|}}} .$$

Homogeneity investigation accomplishes the closeness of distribution in GLCM to GLCM diagonally. Its range lies between 0 and 1, where 0 validates no variation and 1 validate large number of variation in image pixels.

The contrast analysis allows the observer to identify the object in the texture of an image and defined as follows:

$${\text{Contrast}}=\sum\limits_{{i,j}} {\,{{\left| {i - j} \right|}^2}\rho \,(i,j)} .$$

The rage of contrast lies between 0 and \({({\text{size}}({\text{image}}) - 1)^2}\). The constant image has 0 contrast and greater the contrast value illustrates the large number of variations in the image’s pixels.

The energy exploration proceeds the sum of squared elements in GLCM and it is expressed as follows:

$${\text{Contrast}}=\sum\limits_{{i,j}} {\,\rho \,{{(i,j)}^2}} .$$

Its range lies between 0 and 1 and the constant image has 1 energy. Table 10 exhibits the GLCM analyses for enciphered images.

Table 10 Gray-level co- occurrence matrix analyses

The corresponding homogeneity values for enciphered images are very close to 1 and contrast values are sufficiently large, which demonstrates the large number of variations in image pixels. The energy values for enciphered images approach 0, which proves that the image is not constant.

4.8 Time sensitivity analyses

The anticipated scheme in this article is very much effective than already existing techniques, because it uses minimum resources and least computation cost. To analyze the computational complication, we compare time complexity with the existing techniques in Table 11. The table demonstrates the time taken during encryption of plain images. Decryption time is almost equal to encryption time. The projected technique in Table 11 has less computational complexity than already existing approaches.

Table 11 Encryption execution time in seconds

5 Conclusion

We have designed a new scheme based on quantum spinning to provide the security to digital contents. We consumed the half-spin phenomenon to add the confusion and diffusion abilities in our proposed structure. Cracking of keys and messages is not possible without knowledge of phase and entangled matrices. Due to half spinning, there are infinite points which lie between \(- {720^ \circ }\) and \({720^ \circ }\), while possible combinations of spin matrices are 4!. By utilizing the statistical analyses, our proposed technique is appropriate for real-time applications due to small processing time and superior performance than the existing schemes.