 Research
 Open Access
 Published:
Periodic characteristics of the Josephus ring and its application in image scrambling
EURASIP Journal on Wireless Communications and Networking volume 2018, Article number: 162 (2018)
Abstract
This paper proposes a new image scrambling algorithm based on the periodic characteristics of the Josephus ring. The algorithm composes the pretreatment part of the entire image encryption system and scrambles the rows and columns of the plain image. The Josephus scrambling algorithm is adjustable by using three kinds of parameters: step, m_{0}, and n. Different values affect the size of the periodic value of the Josephus ring. In this paper, we focus on the method of determining the period of the Josephus cycle when the parameters are set and the Josephus rule space under arbitrary parameters. Because the Josephus ring is a mathematical problem, we analyze it using the group theory of modern algebra. After the Josephus scrambling, the plain image is encrypted. Because a CA is suitable for image encryption, the encryption part adopts a CA encryption algorithm using a onedimensional, fourneighbor CA, which has chaotic behavior at the rules of 9d62 (hex). Finally, the number of pixels change rate, the unified averaged changed intensity test, and correlation detection are carried out on the experimental results. The results show that the use of the Josephus scrambling algorithm greatly improves the security of the entire encryption system.
Introduction
The remarkable growth in computational power has made the use of digital images over open networks more popular than ever before. However, this widespread use and the growth of the amount of data are also a great challenge for the security design of image encryption algorithms, especially for such private images as medical images [1, 2]. Traditional encryption methods such as the Data Encryption Standard, the International Data Encryption Algorithm (DES) [3], and the Advanced Encryption Standard (AES) [4] are not suitable for image encryption; those methods including chaotic encryption method perform poorly due to their low efficiency [5]. Therefore, improving the security and efficiency of image encryption algorithms has become a key issue.
It is known that a cellular automaton (CA) can be used to encrypt images efficiently [6,7,8,9,10,11], and using an image scrambling algorithm can make the entire encryption system safer and more reliable [12,13,14]. In computer science and mathematics, the Josephus problem is a theoretical problem related to a certain countingout game [15]. The scrambling algorithm becomes an important part of the entire encryption system if the particular periodic characteristics of the algorithm are based on a Josephus ring [16,17,18].
The proposed algorithm is a row and column scrambling method based on transformation sequences. A plain image’s row and column configuration is called the original sequence, and new sequences are generated by particular times of a Josephus cycle. The following is a brief introduction to the Josephus ring and Josephus problem.
The Josephus ring is a classic problem in mathematics: A known number of individuals (designated 1, 2, 3, ..., n) sit around a round table. One by one, players call out numbers in increments of 1 beginning at the one whose serial number is m_{0}. The number X is the step number in the game, when someone’s number is X they leave the table. The next player then counts from 1 again; this rule is repeated until only one player remains. The problem is to determine in advance what the serial number of the last player will be in a sequence of length n. Usually, we assign a number from 0 to n − 1 as a solution to such a problem. For a digital image, the final column number is f(n) + 1: it is also the original problem’s solution:
Periodic characteristics of Josephus ring
Experimental methods
The Josephus problem has been solved by the recursion method, but the focus of this study is the periodic characteristics of the Josephus ring. We propose a new image scrambling algorithm with the following characteristics:
m_{0} starting position  step interval step 
n length of the original sequence  A_{ n } original sequence 
Josephus displacement: a_{ out } = f(m_{0}, step, A_{ n }). This operation chooses an element from the original sequence as output, represented as a_{ out }. In Eq. (2), A_{ n }^{'}is the state of the original sequence after a Josephus replacement operation and m^{'} is the starting position for the next Josephus replacement:
Josephus cycle: First, set the length of the original sequence as n. Then multiply n by the Josephus displacement in the original sequence and place each a_{ out } in order. The new sequence B_{ n } emerges:
\( {B}_{n_j} \): A new sequence generated by j times the Josephus cycle from the original sequence. It is commonly used in the sections of this paper that discuss the periodicity of the Josephus problem.
At first, the original sequence takes the Josephus replacement (F), and every replacement generates an element. Put each element in order until all the elements are out. This obtains a new sequence. This operation is called one Josephus cycle, denoted t. Then determine the period of the Josephus cycle when m_{0} and step are given. Also, determine the change of t when m_{0} = 1 and step = 1, 2, 3,. .. . Then, explore whether the change of t is periodic with the change of step. If so, call it the “period step,” or the period of the Josephus rule, denoted as T. Finally, this paper discusses a scrambling algorithm based on a ring structure, for which the location of the starting point can be arbitrary. Here, for the sake of narration and argumentation, the starting point is m_{0} = 1. When m_{0} takes other values, its nature and the general rules described in the article do not change.
To facilitate the presentation, we define a new operation as a Josephus cycle, which can also be regarded as a kind of computation. Apparently, the Josephus cycle is composed of N times the Josephus displacement, so the Josephus ring in this problem contains only one regular operation: Josephus displacement f. Therefore, the problem belongs to the category of abstract algebra group theory: in group theory the analysis method is reasonable.
Meanwhile, to observe the periodic characteristics of the Josephus ring, we use natural numbers 1, 2, 3, ... to represent the original sequence; these numbers are only the element subscript number that shows the position information. They do not represent the content of the element as do other new sequences transformed from the original sequence.
Figure 1 is a schematic diagram of the entire encryption system. As shown in the figure, the Josephus scrambling algorithm is a pretreatment element for entering the encryption algorithm system.
The period of the Josephus cycle
The period of the Josephus cycle is represented by t. To determine the period of each Josephus cycle, we need to multiply j by the Josephus cycle on the original sequence (A_{ n }).
If the following equation is established:
then we have
The period of this Josephus cycle is the value of j.
Experiment 1: When n = 4, m_{0} = 1, and step = 2, the Josephus cycle states are shown in Table 1.
For \( {A}_n={B}_{n_3} \), the period of the Josephus cycle is 3.
In Table 1, element 1 corresponds to element 2, element 2 corresponds to element 4, element 4 corresponds to element 1, and element 3 corresponds to itself.
So under these n, m_{0}, and step values, n is countable: this Josephus cycle has two cycle sets,
{1,2,4} and {3}.
Experiment 2: When n = 20, m_{0} = 1, and step = 3, each Josephus cycle state is shown in Table 2.
It can be found in Table 2 that \( {A}_n={B}_{n_{30}} \), so the period of this Josephus cycle is 30.
Table 2 shows that in the same way as experiment 1, this Josephus cycle has six cycle sets:
{1,3,9,10,14,17,8,5,15,7}, {2,6,18}, {4,12}, {19,13,11}, {20}, and {16}.
By observing many results with different n, m_{0}, and step values, a calculation method for the Josephus cycle’s period can be found. To use this method based on experiment 2 (n = 20, m_{0} = 1, and step = 3):
{1,3,9,10,14,17,8,5,15,7}: total number of elements is 10; {2,6,18}: total number of elements is 3; {4,12}: total number of elements is 2; {19,13,11}: total number of elements is 3; {20}: total number of elements is 1; {16}: total number of elements is 1.
Record each different total number of elements in each cycle set: A = {10,3,2,1}. The minimum common multiple of the elements in the A set is calculated, that is, the period of the Josephus cycle under these parameter values.
The least common multiple of 10,3,2,1 is 30, so t = 30.
This period calculation method is consistent with some properties of the norder symmetric group S_{ n } and its rcycles in abstract algebra [19], so this problem can be analyzed from the point of view of abstract algebra, especially the part of the symmetric group and its rcycles.
This n degree symmetric group can be represented in rcycles formed as 10cycles {1,3,9,10,14,17,8,5,15,7}; 3cycle, {2,6,18}; 2cycle {4,12}; 3cycle {19,13,11}; 1cycle {20}; and 1cycle {16}.
With the three parameters n, m_{0}, and step determined, calculating the period of this Josephus cycle is equivalent to determining the order of one certain permutation group of this ndegree symmetric group, which is equal to the order of the product of all its disjoint rcycles.
In experiment 2, all the rcycles are disjoint. Obviously, each rcycle’s order equals r. Furthermore, the rcycles of S_{ n } have this property: the order of the product of disjoint rcycles equals the minimum common multiple of each factor’s order.
So in summary, the order of this certain permutation group equals the order of {1,3,9,10,14,17,8,5,15,7}{2,6,18}{4,12}{19,13,11}{20}{16}. Then, determining the lowest common multiple of all the factor’s orders, the LCM of 10,3,2,3,1,1 is 30.
The results of this calculation coincide with the calculated results obtained by the observation, and the theorems and properties quoted in this analysis are well proved mathematically. Therefore, when the parameter values of n, m_{0}, and step are fixed, the periodic problem of the Josephus cycle is effectively a problem of solving the order of a specific n permutation group of the certain n order symmetric group S_{ n }.
The period of the Josephus rule
Josephus rule: For each of the original sequences, certain n, m_{0}, and step values correspond to a certain period of the Josephus cycle. For simplicity, we use J(n, m_{0}, step) to represent the Josephus rule. Figure 2 shows the structural levels among the Josephus displacement, the Josephus cycle, the Josephus rule, and the final scrambling algorithm.
Periodic analysis of the step parameter
We find that a change in step changes the Josephus cycle. Does this change also show periodicity? That is to say, whether there is a T to make Eq. (6):
To analyze the effect of the step value in the Josephus rule, keep parameter settings like m_{0} unchanged (the value of m_{0} can be any positive integer); for example, m_{0} = 1, step = 1, 2, 3,..., and then observe changes in the Josephus cycle and the Josephus rule. We may pay more attention to the Josephus rule’s periodic characteristics caused by step’s change.
After the parameters n, m_{0}, and step are determined, according Eq. (2), the subscripts of a_{ out } (the value of out) are determined after it. Also, the launch of the new series \( {B}_{n_1} \) to \( {B}_{n_j} \) is determined, so we use \( {B}_{n_1} \) obtained by one Josephus cycle to represent all the states of that Josephus cycle. Because for \( {B}_{n_1} \) to \( {B}_{n_j} \), they all correspond to the same Josephus rule.
Experiment 3: m_{0} = 1, n = 4, and the original sequence is A_{ n } = (1, 2, 3, 4):
As the value of step increases from 1, \( {B}_{n_1} \) changes with it. According to Table 3, a different \( {B}_{n_1} \) means a different Josephus rule. Record the value of step when J(n, m_{0}, step) is consistent with J(n, m_{0}, 1), and then we obtain T = step − 1 (T is the period of step).
In experiment 3, when step = 13, \( {B}_{n_1} \)returns to the original state, as the first line shows (step = 1). That means the value of step has gone through a cycle, and it is easy to see that the period of step’s cycle is 12:
Experiment 4: m_{0} = 1, n = 7, and the original sequence is A_{ n } = (1, 2, 3, 4, 5, 6, 7) (Table 4).
Experiments 3 and 4 show a change in the step value, which leads to a periodic change of \( {B}_{n_1} \), representing the J(n, m_{0}, step):
When we explore the general method of computing the value of T, we notice that there is some relation between that value and the sequence length n. Therefore, we set up a sequence of length N, redefine its step’s cycle T as T_{ n }, and then do the following analysis:
The T_{4} = 12 of experiment 3 and the T_{7} = 420 of experiment 4 are solved by the programming method of cyclic traversal. The periods of the step’s cycle T_{1} to approximately T_{11} and of n = 1 to approximately n = 11’s sequence are solved by the same method. The results are as follows:
First, express each N’s factorial in the form of n ! = n × (n − 1)! (n ≥ 1), and then change the form of every N from an integer to the product of several certain prime factors. The results are:
Now observe the relation between T_{ n } and T_{n − 1}:
As shown in Eq. (6), n is the sequence length. First, we do the prime factor decomposition for n and obtain the prime factors x_{ i }, keeping x_{ i } ≤ n. In the equation, p is the number of different qualitative factors and a_{ i } is the exponent of x_{ i }:
The following inference is made from the above experimental data:
When p = 1, that is to say, n can be represented only as the power of a certain prime number, there are
When p > 1, that is, n can be expressed as the product of the power of several prime factors, there are
Formula generalization of step’s period
In Section 3.1, we researched the period of step (T_{ n }), and T_{ n } was found to have a direct relation with the sequence’s length. Step and m_{0} are two parallel parameters of the Josephus cycle, so it could be asked whether T_{ n } is also the period of m_{0}, or whether T_{ n } is related only to the sequence’s length.
It has been found that, for a sequence of length N, step’s periodic characteristic is also suitable for m_{0}. The research method is the same as what Section 3.1 shows. The difference is only that keeping the value of step unchanged, we increase m_{0} from 1 to n.
Therefore, we get
With the conclusion of Section 3.1, we can get the following relation:
In conclusion, T_{ n } is the period of both step and m_{0}, and it is related only to the sequence’s length. Therefore, we propose that T_{ n } is the period of the Josephus rule.
Space of the Josephus rule
A different J(n, m_{0}, step) means a different Josephus cycle: each Josephus cycle corresponds to a certain different Josephus rule. Now we discuss the question of how many different rules exist; the scrambling algorithm should have a very large space of rules. Because T_{ n } is the period of both step and m_{0} according to Section 3.2, we can easily find that the space of the Josephus rule is the square of T_{ n }. So we get
Results and discussion
Number of pixels change rate and unified averaged changed intensity tests
Number of pixels change rate (NPCR) and the unified averaged changed intensity (UACI) are two important parameters for judging the strength of an encryption algorithm [20]. The values of NPCR and UACI are computed using the following equations:
where N and M denote the image’s width and height respectively. C_{1}[i,j] is the obtained cipher image from the original plain image, whereas C_{2}[i,j] is obtained after one bit of the plain image is modified. For each (i,j) position, if C_{1}[i,j] = C_{2}[i,j], then D[i,j] = 0, else D[i,j] = 1.
We incorporated the Josephus scrambling algorithm into the encryption algorithm system, and then tested the Josephus scrambling algorithm’s ability to enhance the effect of the partial X cell automaton encryption algorithm. We used the 256 × 256 cameraman as an example. In Fig. 3, the pictures from left to right are the plain image, the direct CAencrypted image, the scrambled image, and the cipher image after scrambling. Figure 4 are gray histograms of above images. As we can see from Fig. 4, the cipher image’s pixel distribution is more uniform than plain image, which proves this encryption system can protect the information of plain image.
To analyze the security of the entire encryption algorithm intuitively [21,22,23,24,25], we took 1 × 10^{4} pixel points of each experimental image as samples. Next, we should demonstrate that using the scrambling algorithm can improve the security of the entire encryption algorithm.
Figure 5 shows several standard images used as experimental materials. To prove the hypothesis above, we did NPCR and UACI tests on pairs of plain images, comparing each encrypted image before scrambling, with the same encrypted image after scrambling. We called them the sample image pairs.
At the same time, we used the hypothesis testing method to calculate the p value of the NPCR test results. If the proposed algorithm was able to encrypt images that were indistinguishable from random images under the NPCR and UACI measures, the p values simply represented the possibility that our tested images were indeed randomlike. Take the significance level α = 0.05, and then judge the randomness and credibility of the sample image pairs according to the sizes of the p value and α. When the p value is less than α, the sample image pair is strongly randomlike, but when the p value is greater than or equal to α, the sample image pair has low randomness. Figure 6 shows the p value test results. Table 5 shows NPCR, UACI, and p value testing results of standard images. As shown in Fig. 7, in this encryption system, the NPCR value of the scrambled images is generally higher than that of the nonscrambled images. UACI results for both of the two series are similar: as Fig. 8 shows, the red line is just slightly higher than the blue line. It is a normal test result.
Confidence intervals
Due to the normal distribution of the cipher image samples, we get X ~ N(μ,σ^{2}), X is the average value of NPCR, under significance level α = 0.05, and confidence degree is 1−α = 0.95.
Confidence intervals:
Lookup the normal distribution table with the confidence degree of 0.95, we get:
So confidence intervals is [0.984347,1.008183]. Details are displayed in the (Table 6).
Correlation detection
Correlation detection is a conventional detection method for encrypted images [26, 27]. It is also used to evaluate the performance of encryption or scrambling algorithms. Table 7 shows the details, and Figs. 9, 10, and 11 show the correlation detection results of the cameraman picture.
Conclusions
In this study, starting from the classic Josephus problem we used the Josephus loop algorithm to generate scrambled sequences from the original sequences. These new sequences were then applied to the image scrambling of columns and rows. The scrambling operation is the preprocessing part of the entire encryption system, which has a great influence on the security of the encryption algorithm. Then we focused on the period of the Josephus cycle (t) and the period of the Josephus rule (T_{ n }), both of which are the core of the Josephus scrambling algorithm and guarantee the reversibility and rule space complexity of that algorithm. Different selections of m_{0} and step also have a direct impact. To obtain a general conclusion, we encrypted experimental group images with the Josephus scrambling treatment and a control group of images without it. Both image groups used the cameraman, Lena, and other standard images. Then we did NPCR and UACI tests and correlation detection for two sets of samples. The experimental data show that compared with the control group, the images encrypted with Josephus scrambling had better randomness and higher NPCR values; the lower p value also shows the reliability of the experimental results. Therefore, we found that the Josephus scrambling algorithm can improve the randomness of image enciphering and the reliability of an encryption system.
Abbreviations
 AES:

Advanced Encryption Standard
 CA:

Cellular automaton
 CI:

Confidence intervals
 DES:

Data Encryption Algorithm
 LCM:

Least common multiple
 NPCR:

Number of pixels change rate
 UACI:

Unified averaged changed intensity
References
 1.
Z Hua, S Yi, Y Zhou, Medical image encryption using highspeed scrambling and pixel adaptive diffusion. Signal Process. 144, 134–144 (2018).
 2.
A Kanso, M Ghebleh, An efficient and robust image encryption scheme for medical applications. Commun. Nonlinear Sci. Numer. Simul. 24(1), 98–116 (2015).
 3.
Data encryption standard, National Bureau of Standards. Gaithersburg: Information Technology Laboratory, National Institute of Standards and Technology; 1999.
 4.
FIPS PUB 197: Avanced encryption standard, Announcing the Advanced Encryption Standard (AES). Gaithersburg: Information Technology Laboratory, National Institute of Standards and Technology; 2001.
 5.
M Yang, N Bourbakis, S Li, Dataimagevideo encryption. IEEE Potentials 23(3), 28–34 (2004).
 6.
J Jun, in Southeaston, 2009. Image encryption method based on elementary cellular automata, vol 50 (IEEE, Southeastcon, 2009), pp. 345–349.
 7.
AA Abdo, S Lian, IA Ismail, M Amin, H Diab, A cryptosystem based on elementary cellular automata. Commun. Nonlinear Sci. Numer Simul. 18, 136–147 (2013).
 8.
T Chen, M Zhang, W J, C Yuen, Y Tong, Image encryption and compression based on kronecker compressed sensing and elementary cellular automata scrambling. Opt. Laser Technol. 84, 118–133 (2016).
 9.
Y Zhou, W Cao, CL Philip Chen, Image encryption using binary bitplane. Signal Process. 100, 197–207 (2014).
 10.
A Bakhshandeh, Z Eslami, An authenticated image encryption scheme based on chaotic maps and memory cellular automata. Opt. Lasers Eng. 51, 665–673 (2013).
 11.
L Shili, C Zongqian, Image encryption method based on partial X type cellular automaton. J. Jilin Univ. (Eng. Technol. Ed.) 47, 1653–1660 (2017).
 12.
X Desheng, X Yueshan, Digital image scrambling based on Josephus traversing. Comput. Eng. Appl 10, 44–46 (2005).
 13.
S Liu, C Guo, JT Sheridan, A review of optical image encryption techniques. Opt. Laser Technol. 57, 327–342 (2014).
 14.
G Ye, Image scrambling encryption algorithm of pixel bit based on chaos map. Pattern Recogn. Lett. 31, 347–354 (2010).
 15.
P VanRoy, S Haridi, Concepts, techniques, and models of computer programming (MIT Press, Cambridge, 2004).
 16.
G Yang, H Jin, N Bai, Image encryption using the chaotic Josephus matrix. Math. Probl. Eng. 2014, 1–13 (2014) Article ID 632060.
 17.
X Wang, X Zhu, Y Zhang, An image encryption algorithm based on Josephus traversing and mixed chaotic map. IEEE Access 99, 1 (2018). https://doi.org/10.1109/ACCESS.2018.2805847.
 18.
B Xu, Z Hua, H Huang, in International Symposium on Cyberspace Safety and Security. A novel image encryption scheme using Josephus permutation and image filtering (Cyberspace Safety and Security, Xi’an, 2017), pp. 307–319. https://doi.org/10.1007/9783319694719_23.
 19.
JJ Rotman, Advanced modern algebra, 2nd edn. (American Mathematical Society, Providence, 2010).
 20.
Y Wu. NPCR and UACI Randomness Tests for Image Encryption. Cyber J. J. Selected Areas Telecommun. (2011).
 21.
P Refregier, B Javidi, Optical image encryption based on input plane and Fourier plane random encoding. Opt. Let. 20(7), 767769 (1995).
 22.
Q Zhang, L Guo, X Wei, Image encryption using DNA addition combining with chaotic maps. Math. Comput. Model. 52, 2028–2035 (2010).
 23.
Y Zhou, L Bao, CP Chen, A new 1D chaotic system for image encryption. Signal Process. 97, 172–182 (2014).
 24.
S Amina, FK Mohamed, An efficient and secure chaotic cipher algorithm for image content preservation. Commun. Nonlinear Sci. Numer. Simul. 60, 12–32 (2018).
 25.
MG Kechaidou, GC Sirakoulis, Game of life variations for image scrambling. J. Comput. Sci. 21, 432–447 (2017).
 26.
H Liu, X Wang, Color image encryption based on onetime keys and robust chaotic maps. Comput. Math. Appl. 59, 3320–3327 (2010).
 27.
L Xu, X Gou, Z Li, et al., A novel chaotic image encryption algorithm using block scrambling and dynamic index based diffusion. Opt. Lasers Eng. 91, 41–52 (2017).
Acknowledgements
Northeast Normal University and Changchun University of Science and Technology offer the experiment platform.
Funding
This work is supported by the following funding: Jilin Provincial Development and Reform Commission under Grant 2017c033–1 as well as the National defense research frontier exploration project of The Northeast Normal University.
Author information
Affiliations
Contributions
ZQC conceived and designed the experiments and wrote this paper. SLL and LZ helped to perform the analysis with constructive discussions. GRH provides mathematical and statistical guidance for this paper. YSW and CLC contributed to the structuring and reviewing of the manuscript. All authors read and approved the final manuscript.
Corresponding authors
Ethics declarations
Competing interests
The authors declare that they have no competing interests.
Publisher’s Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.
About this article
Cite this article
Chai, Z., Liang, S., Hu, G. et al. Periodic characteristics of the Josephus ring and its application in image scrambling. J Wireless Com Network 2018, 162 (2018). https://doi.org/10.1186/s1363801811675
Received:
Accepted:
Published:
Keywords
 CA
 Image scrambling
 Josephus problem
 Periodic characteristics