# Spreading-Based Voice Encryption by Means of OVSF Codes
## 3 Proposed Method
### Voice Encryption  
The goal of the voice encryption stage is to convert a secret voice signal (\(S(n);1\leq n\leq N\)) in a noise signal (\(T(m);1\leq m\leq M\)), where \(N\) and \(M\) are the number of samples of the input signal and the ciphered signal, respectively. The number of bits per sample in the input signal will be referred as \(b\), whereby the value of each sample of the input signal may have \(2^{b}\) possible amplitude values.  
The proposed process to cipher the voice signal involves the spreading and scrambling of the signal. The spreading consists of replacing each sample of the input signal with a binary code. For this to be possible, there must be as many codes as sample amplitude values. To achieve this goal, the first step is to generate \(2^{b}\) OVSF codes using Equations (1)-(3), and \(SF=2^{b}\). This results in \(2^{b}\) different codes of \(2^{b}\) bits each, that will be called \(C_{SF,k}\), where \(0\leq k\leq 2^{b}-1\). In other words, \(C_{SF}\) is a \(2^{b}\times 2^{b}\) matrix, where each row corresponds to an OVSF code.  
The scrambling of the signal is made directly in the OVSF code matrix. To achieve this, the position of each bit in the OVSF code matrix is reordered. First, a \(2^{b}\)-element vector (\(P\)), which contains the position of each bit, is generated and obtained as follows:  
\[P_{0}=\begin{bmatrix}0&1&2&\ldots 2^{b}-1\end{bmatrix}, \tag{4}\]  
and,  
\[P=perm\left(R_{0}\right), \tag{5}\]  
the \(perm(P_{0})\) function reallocate the \(P_{0}\) vector, and returns a vector containing a pseudo-random permutation of the elements in \(P\). The seed to initialize the pseudo-random process is an input of the system (given by, for example, a cryptographically secure pseudo-random number generator).  
To randomize the bits in the \(C_{SF}\) matrix according to the pseudo-randomly permuted vector, every value of \(P\) is used as the index to extract the values in the \(C_{SF}\) matrix, as follows:  
\[SC\left(i\right)=C_{SF}\left(P\left(i\right)\right), \tag{6}\]  
Accordingly, the \(i\)th element in the \(SC\) matrix is the \(P(i)\)th position of \(C_{SF,k}\) matrix. The scrambled codes (\(SC\)) is a matrix of size \(2^{b}\).  
To spread the \(S(n)\) voice signal using the scrambled OVSF codes, each sample value of the voice signal will be replaced by a row of the \(SC\) matrix. Since the value of the sample can take one of \(2^{b}\) values, its integer value (\([0\ \ 2^{b}-1]\)) is used to select the corresponding row number in the \(SC\) matrix.  
In other words, if the sample value is 200, this sample value will be replaced by the row number 200 (a 2\({}^{b}\) bits vector). Following, the input voice signal will be converted to a spread binary signal (\(SB\)), as follows:  
\[SB=\left[SC_{S(1),*}\ \ SC_{S(2),*}\ \ \ldots SC_{S(N),*}\right], \tag{7}\]  
where \(SC_{i,*}\) denotes the \(i\)th row of \(SC\).  
After this stage, the voice input has been converted to a 2\({}^{b}\)\(*\)\(N\) bits vector.  
To obtain the samples of the output signal, the binary vector is divided into words of \(w\) bits. Each of this words, will be obtained as follows:  
\[T_{b}\left(m\right)=\left\{SB\left(w*m+j\right),\ \ \ 1\leq j\leq w,\ \ \ 0\leq m\leq M-1\right\}, \tag{8}\]  
where \(M\) is the number of samples of the covert signal, and is given by:  
\[M=\frac{2^{b}*N}{w}, \tag{9}\]  
where \(N\) is the number of samples of the input signal, \(b\) is the number of bits per sample of the input signal, and \(w\) is the number of bits per sample of the output signal. Therefore, the relationship between the signal time of the output and that of the input signal, maintaining the sampling frequency, is given by \(M/N\).  
Samples of the binary signal \(T_{b}\) can be converted to a floating point value, whose amplitude is normalized to a standard value (for example [\(-\)1 1]). After the voice encryption process, a signal with unintelligible content (\(T\)) is obtained. This signal can be transmitted without raising suspicion of its content.