# Novel Stream Ciphering Algorithm for Big Data Images Using Zeckendorf Representation

Authors: Liangshun Wu; Hengjin Cai
Journal: Wireless Communications and Mobile Computing
 (2021)

---

## Abstract

Big data is a term used for very large data sets. Digital equipment produces vast amounts of images every day; the need for image encryption is increasingly pronounced, for example, to safeguard the privacy of the patients’ medical imaging data in cloud disk. There is an obvious contradiction between the security and privacy and the widespread use of big data. Nowadays, the most important engine to provide confidentiality is encryption. However, block ciphering is not suitable for the huge data in a real-time environment because of the strong correlation among pixels and high redundancy; stream ciphering is considered a lightweight solution for ciphering high-definition images (i.e., high data volume). For a stream cipher, since the encryption algorithm is deterministic, the only thing you can do is to make the key “look random.” This article proves that the probability that the digit 1 appears in the midsection of a Zeckendorf representation is constant, which can be utilized to generate the pseudorandom numbers. Then, a novel stream cipher key generator (ZPKG) is proposed to encrypt high-definition images that need transferring. The experimental results show that the proposed stream ciphering method, with the keystream of which satisfies Golomb’s randomness postulates, is faster than RC4 and LSFR with indistinguishable performance on hardware depletion, and the method is highly key sensitive and shows good resistance against noise attacks and statistical attacks.


---

## Body

## 1. Introduction

The development of digital sensor technology and storage device leads to the rapid expansion of the digital image library, and all kinds of digital equipment produce vast amounts of images every day. Though image compression reduces the bandwidth, transferring compressed images alone is still not secure. Thus, how to effectively and securely transfer these images has become a hot research direction in recent years. A variety of encryption algorithms have been investigated to image cryptosystems. Most of them are based on permutation and diffusion architecture [1]. The permutation process alters the location of image pixels, and the diffusion process changes the pixel values so that a small change in one pixel can spread to almost all pixels in the entire image [2]. These two procedures are independent. Modern cryptography includes symmetric encryption, asymmetric encryption, and hash function, among which symmetric encryption is divided into two types: block ciphers and stream ciphers. Block ciphers such as DES, AES, and IDEA, are not suitable for practical image encryption because of intrinsic features of some images such as mass data capacity, strong correlation among pixels, and high redundancy [3].A stream cipher is a symmetric key encryption where the crypto keys used to encrypt the binary image is randomly changed so that the cipher image produced is mathematically impossible to break. Also, each bit of data is encrypted with each bit of key. The random keys are changed so that it will not allow any pattern to be repeated, giving a clue to the cracker to break the cipher image. The advantage of using stream cipher is that the execution speed is higher when compared to block ciphers and has lower hardware complexity. Unlike block ciphers, stream cipher will not produce the same ciphertext even for repetitive blocks of plaintext, since the keys are changed constantly for every bit of plaintext. Basically, in stream ciphers, for simplicity, the manner you encrypt is by bitwise XOR, and if you intend to decrypt a ciphertext, you simply do XOR once more. The exclusive or (XOR or⊕) operation, which is simple to implement on hardware, gives a ray of hope for fast image encryption.However, if multiple data are encrypted with the same key, the attacker can decrypt the data without guessing the key. For example, suppose that two strings of plaintext data,P1 and P2, are encrypted using the same key, K. The ciphertexts are as follows: E1=P1⊕K and E2=P2⊕K. Because E1⊕E2=P1⊕K⊕P2⊕K=P1⊕P2⊕K⊕K=P1⊕P2, if XOR P2 on both sides, then E1⊕E2⊕P2=P1⊕P2⊕P2=P1. At this point, it is clear that the attacker recovered the plaintext without obtaining the key.Therefore, in stream ciphering, the difficulty of cracking depends on the randomness and unpredictability of the keystream. Alternatively, a keystream generated by a specified generator should at least “look random.” The motivation of this paper is to generate such pseudorandom keystreams to resist chosen plaintext attacks and statistical attacks.This paper is organized as follows: Section2 introduces preliminary knowledge. Section 3 reviews the related work. Section 4 elaborates on generating a pseudorandom keystream that satisfies Golomb’s randomness postulates. Section 5 proves the randomness of the keystream theoretically. Section 6 does some experiments. Finally, Section 7 draws the conclusion.


## 2. Preliminaries

### 2.1. Golomb’s Randomness Postulates

Golomb’s randomness postulates [4] defines the requisite properties to be sufficiently random looking. Those properties are given as follows: the runs of 0’s are called “gaps”; runs of 1’s are called “blocks”.
(1)
In a cycle, the number of 1’s differs from that of 0’s by at most 1(2)
At least half the runs have length 1, at least one-fourth have length 2, at least one-eighth has length 3, and so forth. Moreover, for each of these lengths, there are (almost) equally many gaps and blocks. In other words, the number of any possiblen-runs is approximately equal to Λ/2n, where Λ denotes the length of the keystream(3)
The autocorrelation functionΓτ:(1)Γτ=∑i=1Λcici+τ=Λ2,τ=0,Λ4,0<τ<Λ


### 2.2. Zeckendorf Representation

It is known from Zeckendorf’s theorem [5] that each nonnegative integer can be addressed as a sum of distinct Fibonacci numbers. For instance, 17 is the sum of the 7th, 4th, and 1st Fibonacci numbers, viz. 17=F7+F4+F1. Every nonnegative integer N admits a representation:
(2)M=Fm1+Fm2+⋯+Fmr,withm1>m2>⋯≥mr, and as usual, F0=0, F1=1, and Fn+2=Fn+1+Fn for all n≥0. We call this a Zeckendorf representation or F-addend representation of N. It is convenient to write this representation as a word/sequence εL−1,εL−2,⋯,ε0 of length L with each εi oscillating over the alphabet 0,1, where 1 indicates the respective Fibonacci addend appears in the sum, and 0 otherwise. Let
(3)SLN=εL−1,εL−2,⋯,ε0,be the aforementioned Zeckendorf representation, for instance,17=F7+F4+F1; then,
(4)S917=0,1,0,0,1,0,0,1,0.If imposing the additional requirement that consecutive 1 are not allowed (viz.mi≥mi+1+2) and ε1 cannot be ‘1’ (F1=F2=1, provided only F2=1 admissible), then we obtain the canonical version of the definition [6–9]. Such a “canonical Zeckendorf representation” always exists and is unique [5].


## 2.1. Golomb’s Randomness Postulates

Golomb’s randomness postulates [4] defines the requisite properties to be sufficiently random looking. Those properties are given as follows: the runs of 0’s are called “gaps”; runs of 1’s are called “blocks”.
(1)
In a cycle, the number of 1’s differs from that of 0’s by at most 1(2)
At least half the runs have length 1, at least one-fourth have length 2, at least one-eighth has length 3, and so forth. Moreover, for each of these lengths, there are (almost) equally many gaps and blocks. In other words, the number of any possiblen-runs is approximately equal to Λ/2n, where Λ denotes the length of the keystream(3)
The autocorrelation functionΓτ:(1)Γτ=∑i=1Λcici+τ=Λ2,τ=0,Λ4,0<τ<Λ


## 2.2. Zeckendorf Representation

It is known from Zeckendorf’s theorem [5] that each nonnegative integer can be addressed as a sum of distinct Fibonacci numbers. For instance, 17 is the sum of the 7th, 4th, and 1st Fibonacci numbers, viz. 17=F7+F4+F1. Every nonnegative integer N admits a representation:
(2)M=Fm1+Fm2+⋯+Fmr,withm1>m2>⋯≥mr, and as usual, F0=0, F1=1, and Fn+2=Fn+1+Fn for all n≥0. We call this a Zeckendorf representation or F-addend representation of N. It is convenient to write this representation as a word/sequence εL−1,εL−2,⋯,ε0 of length L with each εi oscillating over the alphabet 0,1, where 1 indicates the respective Fibonacci addend appears in the sum, and 0 otherwise. Let
(3)SLN=εL−1,εL−2,⋯,ε0,be the aforementioned Zeckendorf representation, for instance,17=F7+F4+F1; then,
(4)S917=0,1,0,0,1,0,0,1,0.If imposing the additional requirement that consecutive 1 are not allowed (viz.mi≥mi+1+2) and ε1 cannot be ‘1’ (F1=F2=1, provided only F2=1 admissible), then we obtain the canonical version of the definition [6–9]. Such a “canonical Zeckendorf representation” always exists and is unique [5].


## 3. Related Work

### 3.1. Stream Ciphers and PRNG

Stream cipher is a symmetric key cryptography in which the key is randomly altered in a way that the cipher image created is mathematically impossible to break. The benefit of using stream cipher is that when it is compared to block ciphers, the execution speed is higher and has less hardware complexity. Unlike block ciphers, stream ciphers, even for repetitive blocks of plain text, will not generate the same ciphertext, since the keys are changed constantly for every element of plaintext [10].Image encryption using some of the existing standard stream cipher methods such as RC4 and Vernam cipher methods have drawbacks. The RC4 algorithm is vulnerable to analytic attacks of the state table. In every 256 keys, there can be a weak key [11]. These keys are identified by cryptanalysis that is able to find circumstances under which one of more generated bytes are strongly correlated with a few bytes of the key [12]. Also, the same sequence of keys is repeated which would enable the hacker to break the ciphertext. Also, the first three words of the secret key can be found, and by iteration, each word of the key used in RC4 can be obtained. The Vernam cipher considered a perfect cipher is a type of one-time pad cipher. The drawback in this method is the need for the unlimited number of keys and the distribution of large number of random keys becomes a problem [13]. Recently, the use of a chaotic system in cryptography to encrypt images has emerged for its random characteristics [14].As the core component of stream ciphers, the generation of random numbers is essential. There are two basic types of generators used to produce random sequences: random number generators (RNGs) and pseudorandom number generators (PRNGs). For cryptographic applications, both of these generator types produce a stream of zeros and ones that may be divided into substreams or blocks of random numbers. A random bit sequence could be interpreted as the result of the flips of an unbiased “fair” coin with sides that are labeled “0” and “1.” Obviously, the use of unbiased coins for cryptographic purposes is impractical. An RNG considers a nondeterministic source (i.e., the entropy source). The source typically consists of some physical quantity, such as the noise in an electrical circuit, the timing of user processes (e.g., keystrokes or mouse movements), or the quantum effects in a semiconductor. The outputs of an RNG may be used directly as a random number or may be fed into a PRNG. However, producing high-quality random numbers may be so time-consuming. Inputs to PRNGs are called seeds. The outputs of a PRNG are typically deterministic functions of the seed, which is the origin of the term “pseudorandom.” Ironically, pseudorandom numbers often appear to be more random than RNGs, because a series of transformations can eliminate statistical autocorrelations between input and output [10].


### 3.2. Applications of Zeckendorf Representation

Zeckendorf representation works well in certain situations. For example, Leroy et al. [15] count the number of distinct (scattered) subwords occurring in a given word. More precisely, it considers the generalization of the Pascal triangle to the binomial coefficients of words and the Zeckendorf representation counting the number of positive entries on each row. Epifanio et al. [16] proved that Zeckendorf representation has deep connections with the Sturmian graph, and Bernat [17] connected Zeckendorf representation with continued fractions.In addition, the research of stream ciphers that resorts to Zeckendorf representation has long been done. For example, feedback with carry shift registers (FCSRs) plays a vital role in the hardware design of stream ciphers besides LFSRs. Galois representation is often considered the first choice for FCSRs, howbeit, recently, a new representation that generalizes both Galois and Zeckendorf representations for FCSR automata was presented [18]. It is immune to previous attacks and can dramatically improve internal diffusion. Later, Lin [19] further improved the aforementioned FCSR circuit.Similarly, the U-Quark hash function with FCSRs of Zeckendorf representation [20]. Fish (Fibonacci shrinking), a fast software stream cipher, was proposed to achieve solid performance simulated on an Intel 486 processor [21]. Nevertheless, these researches do not focus on the generation of keystream of the stream cipher at the software level but the hardware level. Our research is suggested adding a small stone to the wall of the application of Zeckendorf representation. Recently, several studies apply Zeckendorf representation in blockchain and big data encryption [22, 23].


## 3.1. Stream Ciphers and PRNG

Stream cipher is a symmetric key cryptography in which the key is randomly altered in a way that the cipher image created is mathematically impossible to break. The benefit of using stream cipher is that when it is compared to block ciphers, the execution speed is higher and has less hardware complexity. Unlike block ciphers, stream ciphers, even for repetitive blocks of plain text, will not generate the same ciphertext, since the keys are changed constantly for every element of plaintext [10].Image encryption using some of the existing standard stream cipher methods such as RC4 and Vernam cipher methods have drawbacks. The RC4 algorithm is vulnerable to analytic attacks of the state table. In every 256 keys, there can be a weak key [11]. These keys are identified by cryptanalysis that is able to find circumstances under which one of more generated bytes are strongly correlated with a few bytes of the key [12]. Also, the same sequence of keys is repeated which would enable the hacker to break the ciphertext. Also, the first three words of the secret key can be found, and by iteration, each word of the key used in RC4 can be obtained. The Vernam cipher considered a perfect cipher is a type of one-time pad cipher. The drawback in this method is the need for the unlimited number of keys and the distribution of large number of random keys becomes a problem [13]. Recently, the use of a chaotic system in cryptography to encrypt images has emerged for its random characteristics [14].As the core component of stream ciphers, the generation of random numbers is essential. There are two basic types of generators used to produce random sequences: random number generators (RNGs) and pseudorandom number generators (PRNGs). For cryptographic applications, both of these generator types produce a stream of zeros and ones that may be divided into substreams or blocks of random numbers. A random bit sequence could be interpreted as the result of the flips of an unbiased “fair” coin with sides that are labeled “0” and “1.” Obviously, the use of unbiased coins for cryptographic purposes is impractical. An RNG considers a nondeterministic source (i.e., the entropy source). The source typically consists of some physical quantity, such as the noise in an electrical circuit, the timing of user processes (e.g., keystrokes or mouse movements), or the quantum effects in a semiconductor. The outputs of an RNG may be used directly as a random number or may be fed into a PRNG. However, producing high-quality random numbers may be so time-consuming. Inputs to PRNGs are called seeds. The outputs of a PRNG are typically deterministic functions of the seed, which is the origin of the term “pseudorandom.” Ironically, pseudorandom numbers often appear to be more random than RNGs, because a series of transformations can eliminate statistical autocorrelations between input and output [10].


## 3.2. Applications of Zeckendorf Representation

Zeckendorf representation works well in certain situations. For example, Leroy et al. [15] count the number of distinct (scattered) subwords occurring in a given word. More precisely, it considers the generalization of the Pascal triangle to the binomial coefficients of words and the Zeckendorf representation counting the number of positive entries on each row. Epifanio et al. [16] proved that Zeckendorf representation has deep connections with the Sturmian graph, and Bernat [17] connected Zeckendorf representation with continued fractions.In addition, the research of stream ciphers that resorts to Zeckendorf representation has long been done. For example, feedback with carry shift registers (FCSRs) plays a vital role in the hardware design of stream ciphers besides LFSRs. Galois representation is often considered the first choice for FCSRs, howbeit, recently, a new representation that generalizes both Galois and Zeckendorf representations for FCSR automata was presented [18]. It is immune to previous attacks and can dramatically improve internal diffusion. Later, Lin [19] further improved the aforementioned FCSR circuit.Similarly, the U-Quark hash function with FCSRs of Zeckendorf representation [20]. Fish (Fibonacci shrinking), a fast software stream cipher, was proposed to achieve solid performance simulated on an Intel 486 processor [21]. Nevertheless, these researches do not focus on the generation of keystream of the stream cipher at the software level but the hardware level. Our research is suggested adding a small stone to the wall of the application of Zeckendorf representation. Recently, several studies apply Zeckendorf representation in blockchain and big data encryption [22, 23].


## 4. The Proposed Method

### 4.1. Probability Structure of Zeckendorf Representation

Suppose there existm ones in a canonical Zeckendorf representation, denoted as SL,m, it is known from [15] that the quantity of SL,m is given by
(5)NL,m=L−m+1m,0≤m≤L+12,0,m>L+12,where· is the ceiling function.LetNL,mk be the number of representations that own 1 in the kth position. Filipponi and Wolfowicz [24] proves the fact that
(6)NL,mk=NL,mL−k+1,(7)NL,mk=∑i=0k−1−1iL−m−im−1−i,where1≤k≤L+1/2, or
(8)NL,mk=1−−1k2L−m−k+1m−k+∑i=0k−2/2L−m−2i−1m−2i−1,resting on the assumption [25]:
(9)a−b=0.It can be easily inferred from (7) that the addend disappears for i>m+1. And, from (6), the following are found.Theorem 1.
NL,mk=NL,mm, and it is constant for any m<k<L−m+1.Proof.
By using (7), we compute
(10)NL,0k=0NL,1k=1,NL,2k=L−2,k∈1,L,L−3,k∉1,L,and using (8), we get
(11)NL,mm=1−−1m2L−m−m+1m−m+∑i=0m−2/2L−m−2i−1m−2i−1,then
(12)N2m−1,mm=1,2∤m,0,2∣m,N2m,mm=m+12,N2m+1,mm=m+124,2∤m,mm+24,2∣m.Therefore, the probability that thekth position of a Zeckendorf representation containing m 1 s locates the digit 1 is
(13)PrL,mk=NL,mkNL,m.In a similar fashion of (10) and (12), we have
(14)PrL,m1=PrL,mL=mL−m−1,PrL,m2=PrL,mL−1=mL−2m+1L−m−1L−m,Pr2m−1,mm=1,2∤m,0,2∣m,N2m,m=12,2∤m,m2m+2,2∣m,N2m+1,m=m+12m+4,2∤m,m2m+2,2∣m.LetL=30, m=9, then, the value of PrL,mk is shown as Figure 1, where the straight line in the midsection means that the probability is constant.Figure 1
The diagram ofPr30,9k.


### 4.2. Pseudorandom Keystream Generation

The following procedures could generate a reasonably satisfying keystreamC:Suppose that both the sender and the receiver know a pair of keyse1,e2, each of which consists of three integers:
(15)e1=an,cn,μn,e2=am,cm,μm,whereμn and μm are primes of the same order of magnitude. There exist pseudorandom integral sequences
(16)ℕ=N1,N2,⋯,NH,M=M1,M2,⋯,MH,with starting valuesN0,M0 satisfying
(17)N0>0,an,cn<μn,M0>0,am,cm<μm,and each item ofℕ and M is obtained by the algorithm described in [26] that
(18)Nh+1=anNh+cnmodμn,0≤h≤H−1,Mh+1=amNh+cmmodμm,0≤h≤H−1,whereH is decided by the message length. The integers Ni, Mi (i=1,2,⋯,H) are converted into canonical Zeckendorf representations:
(19)uLNi=n1,n2,⋯,nL,uLMi=m1,m2,⋯,mL.Then, we carry out the bitwise logical addition (OR) on their midsection (where the probability is constant) in this way acquiringCi of length t:
(20)Ci=c1,c2,⋯,ct,wheret is given by (see next section for the value of UL)
(21)t=L−2UL+2,cj=nk+mk,j=1,2,⋯,t;k=UL+j−1.By juxtaposingCi, we finally obtain the keystream sequence C of length Ht:
(22)C=C1,C2,⋯,CH.The sequenceC is exactly what we need. Just for the sake of convenience narration, we refer to this kind of pseudorandom keystream generation algorithm as “ZPKG” hereinafter, and the pseudocode is shown as Algorithm 1.


## 4.1. Probability Structure of Zeckendorf Representation

Suppose there existm ones in a canonical Zeckendorf representation, denoted as SL,m, it is known from [15] that the quantity of SL,m is given by
(5)NL,m=L−m+1m,0≤m≤L+12,0,m>L+12,where· is the ceiling function.LetNL,mk be the number of representations that own 1 in the kth position. Filipponi and Wolfowicz [24] proves the fact that
(6)NL,mk=NL,mL−k+1,(7)NL,mk=∑i=0k−1−1iL−m−im−1−i,where1≤k≤L+1/2, or
(8)NL,mk=1−−1k2L−m−k+1m−k+∑i=0k−2/2L−m−2i−1m−2i−1,resting on the assumption [25]:
(9)a−b=0.It can be easily inferred from (7) that the addend disappears for i>m+1. And, from (6), the following are found.Theorem 1.
NL,mk=NL,mm, and it is constant for any m<k<L−m+1.Proof.
By using (7), we compute
(10)NL,0k=0NL,1k=1,NL,2k=L−2,k∈1,L,L−3,k∉1,L,and using (8), we get
(11)NL,mm=1−−1m2L−m−m+1m−m+∑i=0m−2/2L−m−2i−1m−2i−1,then
(12)N2m−1,mm=1,2∤m,0,2∣m,N2m,mm=m+12,N2m+1,mm=m+124,2∤m,mm+24,2∣m.Therefore, the probability that thekth position of a Zeckendorf representation containing m 1 s locates the digit 1 is
(13)PrL,mk=NL,mkNL,m.In a similar fashion of (10) and (12), we have
(14)PrL,m1=PrL,mL=mL−m−1,PrL,m2=PrL,mL−1=mL−2m+1L−m−1L−m,Pr2m−1,mm=1,2∤m,0,2∣m,N2m,m=12,2∤m,m2m+2,2∣m,N2m+1,m=m+12m+4,2∤m,m2m+2,2∣m.LetL=30, m=9, then, the value of PrL,mk is shown as Figure 1, where the straight line in the midsection means that the probability is constant.Figure 1
The diagram ofPr30,9k.


## 4.2. Pseudorandom Keystream Generation

The following procedures could generate a reasonably satisfying keystreamC:Suppose that both the sender and the receiver know a pair of keyse1,e2, each of which consists of three integers:
(15)e1=an,cn,μn,e2=am,cm,μm,whereμn and μm are primes of the same order of magnitude. There exist pseudorandom integral sequences
(16)ℕ=N1,N2,⋯,NH,M=M1,M2,⋯,MH,with starting valuesN0,M0 satisfying
(17)N0>0,an,cn<μn,M0>0,am,cm<μm,and each item ofℕ and M is obtained by the algorithm described in [26] that
(18)Nh+1=anNh+cnmodμn,0≤h≤H−1,Mh+1=amNh+cmmodμm,0≤h≤H−1,whereH is decided by the message length. The integers Ni, Mi (i=1,2,⋯,H) are converted into canonical Zeckendorf representations:
(19)uLNi=n1,n2,⋯,nL,uLMi=m1,m2,⋯,mL.Then, we carry out the bitwise logical addition (OR) on their midsection (where the probability is constant) in this way acquiringCi of length t:
(20)Ci=c1,c2,⋯,ct,wheret is given by (see next section for the value of UL)
(21)t=L−2UL+2,cj=nk+mk,j=1,2,⋯,t;k=UL+j−1.By juxtaposingCi, we finally obtain the keystream sequence C of length Ht:
(22)C=C1,C2,⋯,CH.The sequenceC is exactly what we need. Just for the sake of convenience narration, we refer to this kind of pseudorandom keystream generation algorithm as “ZPKG” hereinafter, and the pseudocode is shown as Algorithm 1.


## 5. Randomness Analysis

LetFn be the greatest Fibonacci number no greater than Ni, then the length of the shortest Zeckendorf representation SLNi will be L=n−1. It can be proved that
(23)L=logΦ5Ni+12−1,whereΦ=1+5/2 denotes the golden ratio. UL of 1’s in SLNi is most likely to be [15]:
(24)UL=5L+2−8−5L+22+41/210+1.Algorithm 1: Pseudorandom keystream generation algorithm.
Require: A pair of key, e1=an,cn,μn,e2=am,cm,μm; message length, H;Ensure: Keystream, C=C1,C2,⋯,CH;1: //initialize;2:N0⟵Random;3:M0⟵Random;4:forh=1 to Hdo5:/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗6:   Generate integral sequences7:∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/8:Nh+1⟵an∗Nh+cnmodμn;9:Mh+1⟵am∗Mh+cmmodμm;10:/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗11:  Convert into Zeckendorf representations12:∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/13:SLNh⟵EncodeNh;14:SLMh⟵EncodeMh;15:/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗16:  Intercept midsection17:∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/18:foru=SLNh,SLMhdo19:  //Count the number of 1 in sequence;20:m⟵u.Count1;21:  //Determine the middle-section;22:Lstart⟵m;23:Lend⟵L−m+1;24:  //Intercept;25:u⟵uLstart,Lend;26:end for27:/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗28:   Bitwise OR29:∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/30:s⟵SLNh OR SLMh31:/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗32:   Take random piece (of lengtht)33:∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/34:UL=5L+2−8−5L+22+41/2/10+1;35:t=L−2UL+2;36:Ch=c1,c2,⋯,ct⟵RandomSelects37:end for38:ReturnC=C1,C2,⋯,CH;The probability that a digit ‘1’ lies in thekth position in the midsection of SLNi is
(25)p1=PrL,ULUL=NL,ULULNL,UL.Similarly, it holds forSLMi.It draws from [15] that as L approaches infinity, even in this case, L>25 would be enough, p1 is expected to approach the limit of 1/Φ+2≈0.2764 (see Figure 2)Figure 2
The diagram ofPrL,ULUL.Then, the probability that a ‘0’ lies in thekth position in both SLNi and SLMi is readily given as below:
(26)Pr0=p20≈Φ25≈0.524,where
(27)p0=1−p1≈Φ+1Φ+2≈0.724.In this way,Pr1 is given by
(28)Pr1=1−Pr0=1−p20≈0.476.From (26) and (28), it follows that, for L>25, Golomb’s first postulate is enough fulfilled.Golomb’s second postulate does not seem, by all accounts, to be so all around fulfilled. In this paper, we are going to assess the probabilitiesPr00, Pr01, Pr10, and Pr11 of any conceivable pair in C.First, we think about the probabilitiesPr00, Pr01, and Pr10 and see that ‘1’ fundamentally preexists or is followed by ‘0’—the fact that there is no pair (11) at all that is blamed. Therefore, we have
(29)p01=p10=p1≈1Φ+2,(30)p00=1−p01+p10=1−2p1≈ΦΦ+2.We can apply some bitwise logical additions (OR or+) to get each pair of C:
(31)00=00+00,(1)
01=01+00 or 00+10 or 01+10(2)
10=10+00 or 00+10 or 10+10(3)
11=10+01 or 01+10Next, from (29), (30), and 1-4, we have
(32)Pr00=p200=15=0.2,Pr01=Pr10=2p00p01+p201≈Φ5≈0.324,Pr11=2p201≈25Φ2≈0.152.


## 6. Experiment

### 6.1. Randomness Test

#### 6.1.1. Golomb’s Postulate Testing

Given the initial valuese1=an=29,cn=4,712,321,103,μn=4,500,000,013, e2=am=31,cm=5,666,778,007,μm=5,127,312,451, N0=5,123,123,007, M0=4,901,976,445, H=100. Put them into the formula, we have L=47, Ul=13, and t=23. Therefore, Λ=Ht=23,000. The probability of n-runs is obtained by enumerating the occasions they appear in C and dividing Λ. Table 1 shows the results. The results of n=1 and n=2 prove that (26), (28), and (32) hold for relatively large L (L=47); in other words, the experimental estimations are near theoretical calculation when L⟶+∞.Table 1
The probability of then-runs that appear in C (n=1,2,3,4).
n=1n=2n=3n=4RunsProbabilityRunsProbabilityRunsProbabilityRunsProbability(0)0.525(00)0.201(000)0.078(0000)0.030(1)0.475(01)0.322(001)0.124(0001)0.047(10)0.322(010)0.225(0010)0.089(11)0.155(011)0.096(0011)0.036(100)0.124(0100)0.086(101)0.197(0101)0.138(110)0.096(0110)0.059(111)0.060(0111)0.037(1000)0.047(1001)0.076(1010)0.136(1011)0.060(1100)0.038(1101)0.058(1110)0.037(1111)0.023We extract a segment of lengthΛ′=1,000 randomly from C and then compute the estimation of Γτ=∑i=1Λcici+τ for τ=1,2,⋯,Λ′−1, and unquestionably:
(33)Γ0=0.47Λ′,Γ1=ΓΛ′−1=0.163Λ′,0.2Λ′≤Γτ≤0.247Λ′Γ¯τ=0.223Λ′,2≤τ≤Λ′−2,whereΓ¯τ=1/Λ′∑τ=0Λ′−1Γτ.A few more cases were acquired by alternating the parametersN0, M0, e1, and e2 rendered insignificant differences from the preceding cases, which prove that the ZPKG algorithm satisfies the Golomb randomness postulates.


#### 6.1.2. NIST-800-22 Statistical Testing

NIST-800-22 [27] is a statistical test suite for random and pseudorandom number generators for cryptographic applications. This test standard was enacted by the Information Technology Laboratory (ITL) at the National Institute of Standards and Technology (NIST). The test suite describes 16 statistical tests, including the longest run test, cumulative sums, and the linear complexity test, which are useful in detecting deviations of a binary sequence from randomness. The p value summarizes the strength of the evidence against the null hypothesis in each statistical test. If p value ≥ α (level of significance), then the null hypothesis is accepted; i.e., the sequence appears to be random. If p value < α, the null hypothesis is rejected; i.e., the sequence appears nonrandom. Typically, α is chosen in the range 0.001,0.01. Common values of α in cryptography are about 0.01 based on the NIST-800-22 test standard.We configured four sets of initial parameters ofN0, M0, e1, and e2.The experimental results of the NIST-800-22 test are shown in Table 2. Table 2 shows that the generated sequences of four sets of parameters passed all the tests. These sequences show good randomness and meet the requirements of the stream cipher.Table 2
NIST-800-22 statistical testing result of ZPKG algorithm.
Test itemParams 1Params 2Params 3Params 4ResultApproximate entropy0.0268530.0138290.0682050.034937PassBlock frequency0.0583780.8708310.7245840.297646PassCumulative sums0.4596420.0697170.9632100.328997PassFFT0.3587950.9198480.0812360.713570PassFrequency0.4353910.4472550.8886600.193601PassLinear complexity0.1865370.2036330.5695650.232544PassLongest run0.3596430.0871890.7899130.250387PassNonoverlapping template0.3480450.6809670.1061690.068529PassOverlapping template0.5128340.0632360.0206890.490518PassRandom excursions0.3195140.1811740.5246220.304589PassRandom excursion variant0.5793800.1779340.1082540.659874PassRank0.9495360.6483870.8624570.648387PassRuns0.3400970.0864690.0413690.027231PassSerial test-10.4079330.2134320.6486880.814738PassSerial test-20.4624900.8806170.5846150.512974PassMaurer’s universal0.0261520.5381430.1426800.600293Pass


### 6.2. Performance Evaluation

m-sequence based on linear feedback shift register (LFSR) is a widely used keystream generator for its long period, good statistical characteristics, easy to be analyzed by algebraic methods, and adapted for hardware implementation. Another type is word-based stream ciphers, for example, RC4 [28, 29]. RC4 has a variable key length and is based on the word-driven operation using random permutations. Unlike LFSR, RC4 works better with software implementation. RC4 consists of two parts: PRGA algorithm, which is for a pseudorandom number generator, and KSA algorithm, which is for key generation. RC4 is extensively used in the secure sockets protocol/transport layer security (SSL/TLS) and WEP protocols, part of the IEEE802.11 wireless LAN standard.In this section, the ZPKG algorithm, RC4 algorithm, and LFSR algorithm are successfully applied to the encryption of more than 50 images of CVG-UGR test image set, including gray image, biometric image, medical image, and magnetic resonance image (MRI). The experimental simulation platform is FPGA, and the simulation software is ModelSim SE-64 10.4.


#### 6.2.1. Hardware Depletion

As shown in Table3, the ZPKG circuit employs significantly more logic gates and registers than RC4 and LFSR; it occupies the same RAM as LFSR but is slightly higher than RC4. However, the I/O pins of the ZPKG circuit are only 1/3 of RC4, slightly more than that of LFSR. The number of PLLs is similar to that of RC4 but higher than LFSR. This shows that the ZPKG and RC4 circuits have different priorities regarding the disposal of hardware resources; ZPKG and RC4 occupied more hardware resources than LFSR. From a power distribution perspective, they are all primarily based on static power. ZPKG has the highest I/O power other than dynamic power (see Figure 3 and Table 4). However, as shown in Table 3, the number of ZPKG I/O pins is considerably lower than RC4, implying that ZPKG requires frequent I/O operations. In addition, the clock power consumption of RC4 is much higher than that of ZPKG and LFSR, which indicates that RC4 requires more clock cycles, which suggests that the generation speed of a pseudorandom keystream of RC4 is the slowest.Table 3
Hardware resource depletion comparison.
ZPKGRC4LFSRLogic elements1110375205Registers3038034Pins3710421RAM21B0B20BPLLs32300Figure 3
The power dissipation distribution.
(a)
ZPKG(b)
RC4(c)
LFSRTable 4
The power dissipation comparison.
ZPKGRC4LFSROn-chip power0.127 W0.144 W0.062 WTJ∗26.5∘C26.7∘C26.5∘CThermal margin58.5∘C58.3∘C26.2∘COff-chip power0 W0 W0 W∗TJ: junction temperature.


#### 6.2.2. Key Generation Speed

Under crystal vibration frequency of 50 MHz, the ZPKG circuit spends 4670 ns to generates a 64-bit pseudorandom keystream, while that of the RC4 is 9790 ns, and that of the LFSR is 25500 ns (see Table5). In other words, ZPKG is approximately one time faster than RC4; both ZPKG and RC4 are much slower than LFSR.Table 5
The key generation time.
ZPKGRC4LFSRCycles2334901275Time (ns)4670979025500Twenty simulations were completed, each generating a pseudorandom 64-bit key. Figure4 presents the statistics, suggesting that the results are stable with the simulations.Figure 4
Statistics of key generation time and clock cycle of repeated attempts.
(a)
Cycle(b)
Time


### 6.3. Security Analysis

Security is important not only for the encrypted objects but also for the encryption algorithms themselves.In what follows, we discuss some security issues of the ZPKG algorithm, such as scrambling effect, statistical histogram analysis, key sensitivity testing, robustness, and noise attacks.


#### 6.3.1. Scrambling Effect

Figure5 shows the results of ZPKG algorithm encrypting and decrypting different types of grayscale images. The encrypted images are visually close to noise images. The structural similarity (SSIM) index is a quantitative assessment method for measuring the similarity between two images [29]; it reflects whether the original images are completely reconstructed or not. A value 1 of the SSIM index indicates that two measured images are identical. SSIM is computed as
(34)SSIM=CovX,YX¯Y¯,where
(35)CovX,Y=N∑i=1Nxi,yi−∑i=1Nxi∑i=1Nyi,X¯=N∑i=1Nxi2−∑i=1Nxi2,Y=N∑i=1Nyi2−∑i=1Nyi2¯,Figure 5
Grayscale images encryption and decryption using ZPKG algorithm. (a–d) Original. (e–h) Encrypted images. (i–l) Decrypted images (SSIM=1).
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)wherexi represents the gray value of the ith pixel of the first image, and yi represents the gray value of the ith pixel of the second image.Figures5(i)–5(l) show the grayscale images decrypted by ZPKG, and its SSIM index equals to 1, which proves the correctness of the ZPKG algorithm.The 3D images such as color images contain several 2D data matrices called 2D components. Color images, for example, contain three color channels called R, G, and B. Each color channel is a 2D component. In this manner, the 3D images can be considered the combination of several 2D images. The 3D image encryption can be accomplished by encrypting all its 2D components one by one. Figure6 shows three examples of the ZPKG algorithm encrypting color images. The encrypted images (Figures 6(d)–6(f)) look like noise images visually.Figure 6
Color image encryption using ZPKG algorithm. (a–c) Original. (d–f) Encrypted images.
(a)(b)(c)(d)(e)(f)


#### 6.3.2. Histogram Analysis

An image histogram is a graphic representation of the pixel intensity distribution of an image. To overcome statistic attacks, the encrypted image should have a histogram with random behavior and uniform distribution.The encrypted image histograms using the ZPKG algorithm, LFSR algorithm, and RC4 algorithm are completely different from the original image (see Figure7). Nevertheless, the encrypted image of RC4 still retains some visual information of the original image, and the intensity distribution of the corresponding histogram is uneven. By contrast, the encrypted images generated by the LFSR and ZPKG algorithms follow a nearly uniform distribution, indicating that the ZPKG algorithm has better performance against statistical attacks than RC4.Figure 7
Color image histograms before and after encrypting with ZPKG, RC4, and LFSR.
(a)
Original LenaRGB(b)
RC4(c)
LFSR(d)
ZPKG(e)
Original BaboonRGB(f)
RC4(g)
LFSR(h)
ZPKG(i)
Original PeppersRGB(j)
RC4(k)
LFSR(l)
ZPKG


#### 6.3.3. Key Sensitivity

We flip one bit of keystream, then decrypt images with flipped key. We notice that the decoded picture is in a state of chaos (see Figure8) and deviates from the original image. The ZPKG algorithm shows good key sensitivity.Figure 8
Color image decryption using ZPKG with 1-bit flipped key. (a) Decrypt LenaRGB. (b) Decrypt BaboonRGB. (c) Decrypt PeppersRGB.
(a)(b)(c)


#### 6.3.4. Robustness

The communication and networking channels are generally in the presence of different types of noise. To test the robustness of the ZPKG algorithm against noise attacks, the salt and pepper noise with density 0.05 is added to the encrypted images. We then try to reconstruct the original image from these noised encrypted images. The SSIM index is used to quantitatively evaluate the similarity between the reconstructed images and the original images. The results are shown in Figure9. The SSIM index of ZPKG (0.9021) is higher than that of RC4 (0.7037 and 0.4548) and LFSR (0.5068), so we can say ZPKG is more robust when facing noise attacks.Figure 9
Encrypting and decrypting Lena image with noise overlap added.
(a)
ZPKG encrypt(b)
LFSR encrypt(c)
RC4-KDA encrypt(d)
RC4-XOR encrypt(e)
ZPKG decrypt,SSIM=0.9021(f)
LFSR decrypt,SSIM=0.5068(g)
RC4-KDA decrypt,SSIM=0.7037(h)
RC4-XOR decrypt,SSIM=0.4548


## 6.1. Randomness Test

### 6.1.1. Golomb’s Postulate Testing

Given the initial valuese1=an=29,cn=4,712,321,103,μn=4,500,000,013, e2=am=31,cm=5,666,778,007,μm=5,127,312,451, N0=5,123,123,007, M0=4,901,976,445, H=100. Put them into the formula, we have L=47, Ul=13, and t=23. Therefore, Λ=Ht=23,000. The probability of n-runs is obtained by enumerating the occasions they appear in C and dividing Λ. Table 1 shows the results. The results of n=1 and n=2 prove that (26), (28), and (32) hold for relatively large L (L=47); in other words, the experimental estimations are near theoretical calculation when L⟶+∞.Table 1
The probability of then-runs that appear in C (n=1,2,3,4).
n=1n=2n=3n=4RunsProbabilityRunsProbabilityRunsProbabilityRunsProbability(0)0.525(00)0.201(000)0.078(0000)0.030(1)0.475(01)0.322(001)0.124(0001)0.047(10)0.322(010)0.225(0010)0.089(11)0.155(011)0.096(0011)0.036(100)0.124(0100)0.086(101)0.197(0101)0.138(110)0.096(0110)0.059(111)0.060(0111)0.037(1000)0.047(1001)0.076(1010)0.136(1011)0.060(1100)0.038(1101)0.058(1110)0.037(1111)0.023We extract a segment of lengthΛ′=1,000 randomly from C and then compute the estimation of Γτ=∑i=1Λcici+τ for τ=1,2,⋯,Λ′−1, and unquestionably:
(33)Γ0=0.47Λ′,Γ1=ΓΛ′−1=0.163Λ′,0.2Λ′≤Γτ≤0.247Λ′Γ¯τ=0.223Λ′,2≤τ≤Λ′−2,whereΓ¯τ=1/Λ′∑τ=0Λ′−1Γτ.A few more cases were acquired by alternating the parametersN0, M0, e1, and e2 rendered insignificant differences from the preceding cases, which prove that the ZPKG algorithm satisfies the Golomb randomness postulates.


### 6.1.2. NIST-800-22 Statistical Testing

NIST-800-22 [27] is a statistical test suite for random and pseudorandom number generators for cryptographic applications. This test standard was enacted by the Information Technology Laboratory (ITL) at the National Institute of Standards and Technology (NIST). The test suite describes 16 statistical tests, including the longest run test, cumulative sums, and the linear complexity test, which are useful in detecting deviations of a binary sequence from randomness. The p value summarizes the strength of the evidence against the null hypothesis in each statistical test. If p value ≥ α (level of significance), then the null hypothesis is accepted; i.e., the sequence appears to be random. If p value < α, the null hypothesis is rejected; i.e., the sequence appears nonrandom. Typically, α is chosen in the range 0.001,0.01. Common values of α in cryptography are about 0.01 based on the NIST-800-22 test standard.We configured four sets of initial parameters ofN0, M0, e1, and e2.The experimental results of the NIST-800-22 test are shown in Table 2. Table 2 shows that the generated sequences of four sets of parameters passed all the tests. These sequences show good randomness and meet the requirements of the stream cipher.Table 2
NIST-800-22 statistical testing result of ZPKG algorithm.
Test itemParams 1Params 2Params 3Params 4ResultApproximate entropy0.0268530.0138290.0682050.034937PassBlock frequency0.0583780.8708310.7245840.297646PassCumulative sums0.4596420.0697170.9632100.328997PassFFT0.3587950.9198480.0812360.713570PassFrequency0.4353910.4472550.8886600.193601PassLinear complexity0.1865370.2036330.5695650.232544PassLongest run0.3596430.0871890.7899130.250387PassNonoverlapping template0.3480450.6809670.1061690.068529PassOverlapping template0.5128340.0632360.0206890.490518PassRandom excursions0.3195140.1811740.5246220.304589PassRandom excursion variant0.5793800.1779340.1082540.659874PassRank0.9495360.6483870.8624570.648387PassRuns0.3400970.0864690.0413690.027231PassSerial test-10.4079330.2134320.6486880.814738PassSerial test-20.4624900.8806170.5846150.512974PassMaurer’s universal0.0261520.5381430.1426800.600293Pass


## 6.1.1. Golomb’s Postulate Testing

Given the initial valuese1=an=29,cn=4,712,321,103,μn=4,500,000,013, e2=am=31,cm=5,666,778,007,μm=5,127,312,451, N0=5,123,123,007, M0=4,901,976,445, H=100. Put them into the formula, we have L=47, Ul=13, and t=23. Therefore, Λ=Ht=23,000. The probability of n-runs is obtained by enumerating the occasions they appear in C and dividing Λ. Table 1 shows the results. The results of n=1 and n=2 prove that (26), (28), and (32) hold for relatively large L (L=47); in other words, the experimental estimations are near theoretical calculation when L⟶+∞.Table 1
The probability of then-runs that appear in C (n=1,2,3,4).
n=1n=2n=3n=4RunsProbabilityRunsProbabilityRunsProbabilityRunsProbability(0)0.525(00)0.201(000)0.078(0000)0.030(1)0.475(01)0.322(001)0.124(0001)0.047(10)0.322(010)0.225(0010)0.089(11)0.155(011)0.096(0011)0.036(100)0.124(0100)0.086(101)0.197(0101)0.138(110)0.096(0110)0.059(111)0.060(0111)0.037(1000)0.047(1001)0.076(1010)0.136(1011)0.060(1100)0.038(1101)0.058(1110)0.037(1111)0.023We extract a segment of lengthΛ′=1,000 randomly from C and then compute the estimation of Γτ=∑i=1Λcici+τ for τ=1,2,⋯,Λ′−1, and unquestionably:
(33)Γ0=0.47Λ′,Γ1=ΓΛ′−1=0.163Λ′,0.2Λ′≤Γτ≤0.247Λ′Γ¯τ=0.223Λ′,2≤τ≤Λ′−2,whereΓ¯τ=1/Λ′∑τ=0Λ′−1Γτ.A few more cases were acquired by alternating the parametersN0, M0, e1, and e2 rendered insignificant differences from the preceding cases, which prove that the ZPKG algorithm satisfies the Golomb randomness postulates.


## 6.1.2. NIST-800-22 Statistical Testing

NIST-800-22 [27] is a statistical test suite for random and pseudorandom number generators for cryptographic applications. This test standard was enacted by the Information Technology Laboratory (ITL) at the National Institute of Standards and Technology (NIST). The test suite describes 16 statistical tests, including the longest run test, cumulative sums, and the linear complexity test, which are useful in detecting deviations of a binary sequence from randomness. The p value summarizes the strength of the evidence against the null hypothesis in each statistical test. If p value ≥ α (level of significance), then the null hypothesis is accepted; i.e., the sequence appears to be random. If p value < α, the null hypothesis is rejected; i.e., the sequence appears nonrandom. Typically, α is chosen in the range 0.001,0.01. Common values of α in cryptography are about 0.01 based on the NIST-800-22 test standard.We configured four sets of initial parameters ofN0, M0, e1, and e2.The experimental results of the NIST-800-22 test are shown in Table 2. Table 2 shows that the generated sequences of four sets of parameters passed all the tests. These sequences show good randomness and meet the requirements of the stream cipher.Table 2
NIST-800-22 statistical testing result of ZPKG algorithm.
Test itemParams 1Params 2Params 3Params 4ResultApproximate entropy0.0268530.0138290.0682050.034937PassBlock frequency0.0583780.8708310.7245840.297646PassCumulative sums0.4596420.0697170.9632100.328997PassFFT0.3587950.9198480.0812360.713570PassFrequency0.4353910.4472550.8886600.193601PassLinear complexity0.1865370.2036330.5695650.232544PassLongest run0.3596430.0871890.7899130.250387PassNonoverlapping template0.3480450.6809670.1061690.068529PassOverlapping template0.5128340.0632360.0206890.490518PassRandom excursions0.3195140.1811740.5246220.304589PassRandom excursion variant0.5793800.1779340.1082540.659874PassRank0.9495360.6483870.8624570.648387PassRuns0.3400970.0864690.0413690.027231PassSerial test-10.4079330.2134320.6486880.814738PassSerial test-20.4624900.8806170.5846150.512974PassMaurer’s universal0.0261520.5381430.1426800.600293Pass


## 6.2. Performance Evaluation

m-sequence based on linear feedback shift register (LFSR) is a widely used keystream generator for its long period, good statistical characteristics, easy to be analyzed by algebraic methods, and adapted for hardware implementation. Another type is word-based stream ciphers, for example, RC4 [28, 29]. RC4 has a variable key length and is based on the word-driven operation using random permutations. Unlike LFSR, RC4 works better with software implementation. RC4 consists of two parts: PRGA algorithm, which is for a pseudorandom number generator, and KSA algorithm, which is for key generation. RC4 is extensively used in the secure sockets protocol/transport layer security (SSL/TLS) and WEP protocols, part of the IEEE802.11 wireless LAN standard.In this section, the ZPKG algorithm, RC4 algorithm, and LFSR algorithm are successfully applied to the encryption of more than 50 images of CVG-UGR test image set, including gray image, biometric image, medical image, and magnetic resonance image (MRI). The experimental simulation platform is FPGA, and the simulation software is ModelSim SE-64 10.4.


### 6.2.1. Hardware Depletion

As shown in Table3, the ZPKG circuit employs significantly more logic gates and registers than RC4 and LFSR; it occupies the same RAM as LFSR but is slightly higher than RC4. However, the I/O pins of the ZPKG circuit are only 1/3 of RC4, slightly more than that of LFSR. The number of PLLs is similar to that of RC4 but higher than LFSR. This shows that the ZPKG and RC4 circuits have different priorities regarding the disposal of hardware resources; ZPKG and RC4 occupied more hardware resources than LFSR. From a power distribution perspective, they are all primarily based on static power. ZPKG has the highest I/O power other than dynamic power (see Figure 3 and Table 4). However, as shown in Table 3, the number of ZPKG I/O pins is considerably lower than RC4, implying that ZPKG requires frequent I/O operations. In addition, the clock power consumption of RC4 is much higher than that of ZPKG and LFSR, which indicates that RC4 requires more clock cycles, which suggests that the generation speed of a pseudorandom keystream of RC4 is the slowest.Table 3
Hardware resource depletion comparison.
ZPKGRC4LFSRLogic elements1110375205Registers3038034Pins3710421RAM21B0B20BPLLs32300Figure 3
The power dissipation distribution.
(a)
ZPKG(b)
RC4(c)
LFSRTable 4
The power dissipation comparison.
ZPKGRC4LFSROn-chip power0.127 W0.144 W0.062 WTJ∗26.5∘C26.7∘C26.5∘CThermal margin58.5∘C58.3∘C26.2∘COff-chip power0 W0 W0 W∗TJ: junction temperature.


### 6.2.2. Key Generation Speed

Under crystal vibration frequency of 50 MHz, the ZPKG circuit spends 4670 ns to generates a 64-bit pseudorandom keystream, while that of the RC4 is 9790 ns, and that of the LFSR is 25500 ns (see Table5). In other words, ZPKG is approximately one time faster than RC4; both ZPKG and RC4 are much slower than LFSR.Table 5
The key generation time.
ZPKGRC4LFSRCycles2334901275Time (ns)4670979025500Twenty simulations were completed, each generating a pseudorandom 64-bit key. Figure4 presents the statistics, suggesting that the results are stable with the simulations.Figure 4
Statistics of key generation time and clock cycle of repeated attempts.
(a)
Cycle(b)
Time


## 6.2.1. Hardware Depletion

As shown in Table3, the ZPKG circuit employs significantly more logic gates and registers than RC4 and LFSR; it occupies the same RAM as LFSR but is slightly higher than RC4. However, the I/O pins of the ZPKG circuit are only 1/3 of RC4, slightly more than that of LFSR. The number of PLLs is similar to that of RC4 but higher than LFSR. This shows that the ZPKG and RC4 circuits have different priorities regarding the disposal of hardware resources; ZPKG and RC4 occupied more hardware resources than LFSR. From a power distribution perspective, they are all primarily based on static power. ZPKG has the highest I/O power other than dynamic power (see Figure 3 and Table 4). However, as shown in Table 3, the number of ZPKG I/O pins is considerably lower than RC4, implying that ZPKG requires frequent I/O operations. In addition, the clock power consumption of RC4 is much higher than that of ZPKG and LFSR, which indicates that RC4 requires more clock cycles, which suggests that the generation speed of a pseudorandom keystream of RC4 is the slowest.Table 3
Hardware resource depletion comparison.
ZPKGRC4LFSRLogic elements1110375205Registers3038034Pins3710421RAM21B0B20BPLLs32300Figure 3
The power dissipation distribution.
(a)
ZPKG(b)
RC4(c)
LFSRTable 4
The power dissipation comparison.
ZPKGRC4LFSROn-chip power0.127 W0.144 W0.062 WTJ∗26.5∘C26.7∘C26.5∘CThermal margin58.5∘C58.3∘C26.2∘COff-chip power0 W0 W0 W∗TJ: junction temperature.


## 6.2.2. Key Generation Speed

Under crystal vibration frequency of 50 MHz, the ZPKG circuit spends 4670 ns to generates a 64-bit pseudorandom keystream, while that of the RC4 is 9790 ns, and that of the LFSR is 25500 ns (see Table5). In other words, ZPKG is approximately one time faster than RC4; both ZPKG and RC4 are much slower than LFSR.Table 5
The key generation time.
ZPKGRC4LFSRCycles2334901275Time (ns)4670979025500Twenty simulations were completed, each generating a pseudorandom 64-bit key. Figure4 presents the statistics, suggesting that the results are stable with the simulations.Figure 4
Statistics of key generation time and clock cycle of repeated attempts.
(a)
Cycle(b)
Time


## 6.3. Security Analysis

Security is important not only for the encrypted objects but also for the encryption algorithms themselves.In what follows, we discuss some security issues of the ZPKG algorithm, such as scrambling effect, statistical histogram analysis, key sensitivity testing, robustness, and noise attacks.


### 6.3.1. Scrambling Effect

Figure5 shows the results of ZPKG algorithm encrypting and decrypting different types of grayscale images. The encrypted images are visually close to noise images. The structural similarity (SSIM) index is a quantitative assessment method for measuring the similarity between two images [29]; it reflects whether the original images are completely reconstructed or not. A value 1 of the SSIM index indicates that two measured images are identical. SSIM is computed as
(34)SSIM=CovX,YX¯Y¯,where
(35)CovX,Y=N∑i=1Nxi,yi−∑i=1Nxi∑i=1Nyi,X¯=N∑i=1Nxi2−∑i=1Nxi2,Y=N∑i=1Nyi2−∑i=1Nyi2¯,Figure 5
Grayscale images encryption and decryption using ZPKG algorithm. (a–d) Original. (e–h) Encrypted images. (i–l) Decrypted images (SSIM=1).
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)wherexi represents the gray value of the ith pixel of the first image, and yi represents the gray value of the ith pixel of the second image.Figures5(i)–5(l) show the grayscale images decrypted by ZPKG, and its SSIM index equals to 1, which proves the correctness of the ZPKG algorithm.The 3D images such as color images contain several 2D data matrices called 2D components. Color images, for example, contain three color channels called R, G, and B. Each color channel is a 2D component. In this manner, the 3D images can be considered the combination of several 2D images. The 3D image encryption can be accomplished by encrypting all its 2D components one by one. Figure6 shows three examples of the ZPKG algorithm encrypting color images. The encrypted images (Figures 6(d)–6(f)) look like noise images visually.Figure 6
Color image encryption using ZPKG algorithm. (a–c) Original. (d–f) Encrypted images.
(a)(b)(c)(d)(e)(f)


### 6.3.2. Histogram Analysis

An image histogram is a graphic representation of the pixel intensity distribution of an image. To overcome statistic attacks, the encrypted image should have a histogram with random behavior and uniform distribution.The encrypted image histograms using the ZPKG algorithm, LFSR algorithm, and RC4 algorithm are completely different from the original image (see Figure7). Nevertheless, the encrypted image of RC4 still retains some visual information of the original image, and the intensity distribution of the corresponding histogram is uneven. By contrast, the encrypted images generated by the LFSR and ZPKG algorithms follow a nearly uniform distribution, indicating that the ZPKG algorithm has better performance against statistical attacks than RC4.Figure 7
Color image histograms before and after encrypting with ZPKG, RC4, and LFSR.
(a)
Original LenaRGB(b)
RC4(c)
LFSR(d)
ZPKG(e)
Original BaboonRGB(f)
RC4(g)
LFSR(h)
ZPKG(i)
Original PeppersRGB(j)
RC4(k)
LFSR(l)
ZPKG


### 6.3.3. Key Sensitivity

We flip one bit of keystream, then decrypt images with flipped key. We notice that the decoded picture is in a state of chaos (see Figure8) and deviates from the original image. The ZPKG algorithm shows good key sensitivity.Figure 8
Color image decryption using ZPKG with 1-bit flipped key. (a) Decrypt LenaRGB. (b) Decrypt BaboonRGB. (c) Decrypt PeppersRGB.
(a)(b)(c)


### 6.3.4. Robustness

The communication and networking channels are generally in the presence of different types of noise. To test the robustness of the ZPKG algorithm against noise attacks, the salt and pepper noise with density 0.05 is added to the encrypted images. We then try to reconstruct the original image from these noised encrypted images. The SSIM index is used to quantitatively evaluate the similarity between the reconstructed images and the original images. The results are shown in Figure9. The SSIM index of ZPKG (0.9021) is higher than that of RC4 (0.7037 and 0.4548) and LFSR (0.5068), so we can say ZPKG is more robust when facing noise attacks.Figure 9
Encrypting and decrypting Lena image with noise overlap added.
(a)
ZPKG encrypt(b)
LFSR encrypt(c)
RC4-KDA encrypt(d)
RC4-XOR encrypt(e)
ZPKG decrypt,SSIM=0.9021(f)
LFSR decrypt,SSIM=0.5068(g)
RC4-KDA decrypt,SSIM=0.7037(h)
RC4-XOR decrypt,SSIM=0.4548


## 6.3.1. Scrambling Effect

Figure5 shows the results of ZPKG algorithm encrypting and decrypting different types of grayscale images. The encrypted images are visually close to noise images. The structural similarity (SSIM) index is a quantitative assessment method for measuring the similarity between two images [29]; it reflects whether the original images are completely reconstructed or not. A value 1 of the SSIM index indicates that two measured images are identical. SSIM is computed as
(34)SSIM=CovX,YX¯Y¯,where
(35)CovX,Y=N∑i=1Nxi,yi−∑i=1Nxi∑i=1Nyi,X¯=N∑i=1Nxi2−∑i=1Nxi2,Y=N∑i=1Nyi2−∑i=1Nyi2¯,Figure 5
Grayscale images encryption and decryption using ZPKG algorithm. (a–d) Original. (e–h) Encrypted images. (i–l) Decrypted images (SSIM=1).
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)wherexi represents the gray value of the ith pixel of the first image, and yi represents the gray value of the ith pixel of the second image.Figures5(i)–5(l) show the grayscale images decrypted by ZPKG, and its SSIM index equals to 1, which proves the correctness of the ZPKG algorithm.The 3D images such as color images contain several 2D data matrices called 2D components. Color images, for example, contain three color channels called R, G, and B. Each color channel is a 2D component. In this manner, the 3D images can be considered the combination of several 2D images. The 3D image encryption can be accomplished by encrypting all its 2D components one by one. Figure6 shows three examples of the ZPKG algorithm encrypting color images. The encrypted images (Figures 6(d)–6(f)) look like noise images visually.Figure 6
Color image encryption using ZPKG algorithm. (a–c) Original. (d–f) Encrypted images.
(a)(b)(c)(d)(e)(f)


## 6.3.2. Histogram Analysis

An image histogram is a graphic representation of the pixel intensity distribution of an image. To overcome statistic attacks, the encrypted image should have a histogram with random behavior and uniform distribution.The encrypted image histograms using the ZPKG algorithm, LFSR algorithm, and RC4 algorithm are completely different from the original image (see Figure7). Nevertheless, the encrypted image of RC4 still retains some visual information of the original image, and the intensity distribution of the corresponding histogram is uneven. By contrast, the encrypted images generated by the LFSR and ZPKG algorithms follow a nearly uniform distribution, indicating that the ZPKG algorithm has better performance against statistical attacks than RC4.Figure 7
Color image histograms before and after encrypting with ZPKG, RC4, and LFSR.
(a)
Original LenaRGB(b)
RC4(c)
LFSR(d)
ZPKG(e)
Original BaboonRGB(f)
RC4(g)
LFSR(h)
ZPKG(i)
Original PeppersRGB(j)
RC4(k)
LFSR(l)
ZPKG


## 6.3.3. Key Sensitivity

We flip one bit of keystream, then decrypt images with flipped key. We notice that the decoded picture is in a state of chaos (see Figure8) and deviates from the original image. The ZPKG algorithm shows good key sensitivity.Figure 8
Color image decryption using ZPKG with 1-bit flipped key. (a) Decrypt LenaRGB. (b) Decrypt BaboonRGB. (c) Decrypt PeppersRGB.
(a)(b)(c)


## 6.3.4. Robustness

The communication and networking channels are generally in the presence of different types of noise. To test the robustness of the ZPKG algorithm against noise attacks, the salt and pepper noise with density 0.05 is added to the encrypted images. We then try to reconstruct the original image from these noised encrypted images. The SSIM index is used to quantitatively evaluate the similarity between the reconstructed images and the original images. The results are shown in Figure9. The SSIM index of ZPKG (0.9021) is higher than that of RC4 (0.7037 and 0.4548) and LFSR (0.5068), so we can say ZPKG is more robust when facing noise attacks.Figure 9
Encrypting and decrypting Lena image with noise overlap added.
(a)
ZPKG encrypt(b)
LFSR encrypt(c)
RC4-KDA encrypt(d)
RC4-XOR encrypt(e)
ZPKG decrypt,SSIM=0.9021(f)
LFSR decrypt,SSIM=0.5068(g)
RC4-KDA decrypt,SSIM=0.7037(h)
RC4-XOR decrypt,SSIM=0.4548


## 7. Conclusion

Stream ciphers cannot really work without the keystream randomness. We proved that the probability of occurrence of the number 1 in the middle part of Zeckendorf coding is constant, which can generate pseudorandom numbers. The pseudorandom numbers generated by the proposed algorithm satisfy the Golomb randomness hypothesis. Experimental results show that our method is three times faster than the RC4 and LSFR algorithms, has no significant difference in hardware occupation, and has high key sensitivity and good resistance to noise attacks and statistical attacks. There is no doubt that our research has its limitations, for example, the lack of theoretical analysis of the characteristics of cryptography, and the lack of comparison with recent research such as chaotic stream ciphering algorithms. We will spend more time devoting on theoretical research on Zeckendorf representation in the future. Furthermore, more experimental investigations are needed to evaluate the performance of ZPKG by comparing it with other stream ciphers such as RC4A, VMPC, and Spritz.



---

*Source: 4637876-2021-10-21.xml*