3.2. Main stages of NN encryption
The encryption uses a key consisting of neurons in the NN, a weight matrix and masking operations. The main stages of message encryption are considered below.
Choice of NN architecture. The number of neuro elements
, the number of inputs
and the bit inputs
determine the architecture of the NN. The number of neural elements is defined according to the following formula:
where
is the bit length of the message, and
—the bit length of the inputs.
The incoming messages which are encrypted can have different bit length () and different inputs number (), which is equal to the number of neuroelements . The architecture of the NN depends on the value of the bit length of the message n and the number of inputs k. Such configuration of the NN architecture is available to encrypt the bit message: , , ; , , ; , , , in case of they are: , , ; , , ; , , ; , , ; , , ; , , .
Calculation of the weight matrix. For data encryption-decryption we will use an auto-associative NN, which learns non-iteratively using the principal components analysis (PCA), which performs a linear transformation following the formula:
According to formula (2), the matrix is used to convert the input vector into the output vector . The conversion is as follows. System of linearly independent vectors selects an orthonormal system of eigenvectors corresponding to the eigenvalues of the covariance matrix of the input data.
The input data is a set of
vectors
, with dimension
,
:
For
N vectors the autocovariance matrix
is:
where each of the elements is expressed by:
where
, and
,
—mathematical expectations of vectors
,
.
The eigenvalues of
symmetric non-negative matrix are real and positive numbers. They are arranged in descending order
. Similarly, the eigenvectors corresponding to
are placed. Therefore, a linear transformation (2) is defined by the matrix
W. Here
is a vector of the PCA principal components corresponding to the input data vector
. The number of principal components vectors
N conforms with the number of input data vectors
[
29]. The matrix of weights used to encrypt the data is as follows:
The basic operation of the NN used to encrypt data is the operation of calculating the scalar product. This operation should be implemented using the tabular-algorithmic method because the matrix of weights , where , , is pre-calculated.
Calculation of the table of macro-partial products for data encryption. The specificity of the scalar product calculation operation used in data encryption is that the weights are pre-calculated (constants) and set in floating point format, and the input data X_j is in fixed point format with its fixing before the high digit of a number. The scalar product is calculated by means of the tabular-algorithmic method according to the formula:
where
—number of products,
—input data,
—
-th weight coefficient,
—bit length of the input data,
—partial product,
—macro-partial product, formed by adding
partial products
, as follows:
.
Formation of the tables of macro-partial products for floating-point weights (where —mantissa of weight coefficient, —order of weight coefficient) foresees the following operations to be performed:
-
defining the largest common order of weights ;
calculation of the order difference for each weight coefficient: ;
shift the mantissa to the right by a difference of orders ;
calculation of macro-partial product for the case when ;
determining the number of overflow bits q in the macro-partial product for the case when ;
obtaining scalable mantissas by shifting them to the right by the number of overflow bits;
adding to the largest common order of weight the number of overflow bits q, as per formula .
The table of macro-partial products is calculated by the formula:
where
—address inputs of the table,
—mantissa of
weight coefficient brought to the greatest common order.
The possible combinations number of
macro-partial products and the table size is as follows:
Dividing all products by parts and we can reduce the table size. For each of these parts separate tables of macro-partial products and are formed and stored in separate memory blocks or a single memory block. When using two memory blocks, parts of the macro-partial products and are read in one clock cycle, and in one memory block - in two clock cycles. The sum of two macro-partial products and gives us the macro-partial product .
NN tabular-algorithmic data encryption. During the training of the NN the matrix of weights
W is determined.
Figure 2 shows the structure of auto-associative NN used for data encryption. Here
is the mask for the
-th input,
is the
-th input data, XOR is the masking operation using the exclusive OR elements.
To perform the NN data encryption we multiply the
matrix by the input data vector
according to the formula:
The multiplication of the matrix of weights
by the vector of input data
is reduced to performing
scalar product calculations:
where
—number of products,
.
The calculation of scalar products will be achieved using the tabular-algorithmic method, where the weights
are set in floating-point format, and the input data
—in a fixed-point format with fixation before the highest digit. Tabular-algorithmic calculation of the mantissa of the scalar product is reduced to reading the macro-partial product
from the j-th table (memory) at the address corresponding to the i-th bit slice of N input data, and adding it to the before accumulated sums according to:
where
,
,
—bit length of the input data. The number of tables of macro-partial products corresponds to
—the number of rows of the matrix (10). The result of calculating of the scalar product
consists of the mantissa
and the order
.
The time required to compute the mantissa of the scalar product (SP) is determined by the formula:
where
is the time of calculation of the scalar product,
is the time of reading from the table (memory),
is the time of reading (writing) from the register,
is the time of adding.
Data encryption can be performed either sequentially or in parallel, depending on the speed required. In the case of sequential encryption, the encryption time is the result of the formula:
where
—time required for encryption. The encryption time can be reduced by performing N operations of calculating the scalar product in parallel.
As a result of NN data encryption, we obtain encrypted data in the form , where —mantissa at the -th output, —order value at the -th output. It is advisable to bring all encrypted data to the highest common order for transmission and such reduction to the greatest common order is performed in three stages:
-
define the greatest order ;
for each encrypted data calculate the difference between the orders ;
by performing shift of the mantissa to the right by the difference of orders we obtain mantissa of the encrypted data reduced to the greatest common order.
The mantissa of the encrypted data reduced to the largest common order and the largest common order are sent for decryption.
3.3. The main stages of NN cryptographic data decryption
Now the encrypted data presented by mantissa , reduced to the largest common order need to be decrypted. The encrypted data will be decrypted according to the following procedure.
Configuration of the NN architecture for the decryption of encrypted data. The architecture of the NN for the decryption of encrypted data, in terms of the number of neural elements, is the same as the architecture of the NN used for the encryption of data. In this NN, the number of inputs and the number of neurons corresponds to the number of the encrypted mantissa
. The NN architecture used to decrypt encrypted data is presented in
Figure 3.
The bit rate of the inputs during decryption corresponds to the bit rate of the encrypted mantissa . Its value determines the decryption time and to reduce it the lower bits of the mantissa may be discarded, because they will not affect the original message recovery.
Figure 3.
The NN architecture for decryption of encrypted data.
Figure 3.
The NN architecture for decryption of encrypted data.
Formation of the weight matrix. The matrix of weights for decrypting encrypted data is formed from a matrix of weights for encrypting input data by transposing it:
The basic operation for encryption of input data and decryption of encrypted data is the calculation of the scalar product, which is implemented using a tabular-algorithmic method.
Calculation of the table of macro-partial products for decryption of encrypted data. A specific feature of the scalar product calculation operation used to decrypt encrypted data is that the weights are pre-calculated (constants) and set in floating-point format, while the encrypted data are received in block-floating-point format. The calculation of the scalar product using the tabular-algorithmic method is performed by formula (7). Preparation and calculation of possible variants of macro-partial products is performed as in the previous case under the formula (8).
Amount of encrypted data determines the number of macro-partial products and the size of the table. The largest common order is computed for each table.
NN tabular-algorithmic decryption of encrypted data. The NN decryption is specified by multiplying the
matrix by the encrypted data vector
:
The multiplication of the weights matrix
by the input data vector
is reduced to performing
scalar product calculations:
where —number of products, .
Tabular-algorithmic calculation of the mantissa of the scalar product is reduced to reading the macro-partial product
from the table (memory) at the address corresponding to the i-th bit-slice of k input data, and adding it to the previously accumulated sums, according to the formula:
where
,
—bit rate of the encrypted data. The time necessary to calculate the scalar product mantissa is defined under the formula:
where
—time for scalar product calculation,
—time for reading from a table (memory),
—time of reading (writing) from the register,
—time for adding. The result of the calculation of
scalar product consists of a mantissa
and order, which is equal to
.
At the output of the NN (see
Figure 3), we obtain
decrypted data in the following form
, where
is the mantissa at the
-th output,
is the value of the order at the
-th output. To obtain the input data, it is necessary to shift the
-th mantissa
by the value of the order
.