<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Neural network method for base extension in residue number system</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>M Babenko</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>E Shiriaev</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>A Tchernykh</string-name>
          <email>chernykh@cicese.mx</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>E Golimblevskaia</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>CICESE Research Center</institution>
          ,
          <addr-line>Ensenada, BC</addr-line>
          ,
          <country country="MX">México</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Ivannikov Institute for System Programming</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>North-Caucasus Federal University</institution>
          ,
          <addr-line>Stavropol</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>South Ural State University</institution>
          ,
          <addr-line>Chelyabinsk</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Confidential data security is associated with the cryptographic primitives, asymmetric encryption, elliptic curve cryptography, homomorphic encryption, cryptographic pseudorandom sequence generators based on an elliptic curve, etc. For their efficient implementation is often used Residue Number System that allows executing additions and multiplications on parallel computing channels without bit carrying between channels. A critical operation in Residue Number System implementations of asymmetric cryptosystems is base extension. It refers to the computing a residue in the extended moduli without the application of the traditional Chinese Remainder Theorem algorithm. In this work, we propose a new way to perform base extensions using a Neural Network of a final ring. We show that it reduces 11.7% of the computational cost, compared with state-of-the-art approaches.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Currently, many cryptosystems use Montgomery multiplication [1] and exponentiation by numbers with
high resolution. Often, Redundant Residue Number Systems (RRNS) are used to implement this
operation due to the possibility of parallelizing its arithmetic [2]. For scaling RNS operations, a base
extension is required to obtain the new extended moduli system.</p>
      <p>This operation is the most computationally expensive since traditional methods of converting a
number from RRNS to Weighted Number System (WNS) and calculating the Redundant Residue
Number System (RRNS) with a new modulo base are used to perform it.</p>
      <p>Thus, an important task is to find an efficient algorithm for expanding the RNS base. In this paper,
we study traditional algorithms for converting a number from RNS to WNS, two algorithms for the RNS
base extension considering integer arithmetic and floating-point arithmetic. We also design and analyze
the efficiency of the neural network method for this operation.</p>
      <p>The outline of the paper is as follows. Section 2 describes the concept of RNS. Section 3 discusses
base extension in Residue Number System. Section 4 describes base extension based on translating a
number from RNS into a WNS. Section 5 includes base extension based on scaling a number using the
number range function in RNS. Section 6 contains the use of neural networks to expand the base. The
study of the effectiveness of algorithms is performed in Section 7. The conclusion is presented in Section
8.</p>
    </sec>
    <sec id="sec-2">
      <title>2. The concept of RNS</title>
      <p>In this section, we introduce basic concepts of RNS, its operations, and the translation of numbers from
WNSC and back.</p>
      <p>RNS is a non-positional number system based on modular arithmetic. The representation of a number
in RNS is based on moduli comparison of two integers and the Chinese Remainder Theorem (CRT) [3].
Let us consider the following notations (Table 1).
||) * remainder of the division  by modulo &amp;
-th number
-th number
Integer number in WNS
-th RNS moduli
dynamic range RRNS</p>
      <sec id="sec-2-1">
        <title>Base modulo</title>
      </sec>
      <sec id="sec-2-2">
        <title>WNS coefficient</title>
      </sec>
      <sec id="sec-2-3">
        <title>Core Function weight</title>
      </sec>
      <sec id="sec-2-4">
        <title>Orthogonal basis</title>
        <p>Approximate coefficient</p>
      </sec>
      <sec id="sec-2-5">
        <title>Range coefficient</title>
        <p>Orthogonal basis weight</p>
      </sec>
      <sec id="sec-2-6">
        <title>Number range</title>
        <p>5 ≡ ( 5)
7 ≡ ( 7)
. . . . . . . . . . . . . . . . . . . . . . . ..</p>
        <p>9 ≡ ( 9 )
RNS can be defined as a set of mutually prime moduli (5, 7, … , 9 ), whose vector is called the basis
9
of RNS, and its dynamic range  = ∑&amp;&gt;5 &amp;. Every integer , which belongs to the range [0,  − 1], can
be represented in RNS. A set of residues is presented as (5, 7, . . . , 9 ), where
Based on the corollary of CRT, the uniqueness of the representation of non-negative integers from the
interval [0,  − 1] is guaranteed. The main advantage of representing a number in RNS is determined
by the fact that operations such as addition, subtraction, and multiplication can be performed by the
formula:</p>
        <p>
          ∗  = (5, 7, . . . , 9 ) ∗ (5, 7, . . . , 9 ) =
= ((5 ∗ 5)  5), ((7 ∗ 7)  7), . . . , ((9 ∗ 9 )  9 ),
(
          <xref ref-type="bibr" rid="ref1">1</xref>
          )
where * denotes operations such as addition, multiplication, or subtraction.
        </p>
        <p>Such operations are called modular [4]. For their execution in RNS, one cycle of processing
numerical values is sufficient. This processing takes place in parallel. The value of the number in each
category is independent of other categories.</p>
        <p>
          Let RNS be given by a base (5, 7, . . . , 9 ) and a number with a residue system  = (5, 7, . . . , 9 ).
Let (5, 7, . . . , 9 ) be RNS bases, then the number  can be represented as
 = (9 ⋅ 5 ⋅ 7 ⋅. . .⋅ 9M5 + 9M5 ⋅ 5 ⋅ 7 ⋅. . .⋅ 9M7+. . . +O ⋅ 5 ⋅ 7 + 7 ⋅ 5 + 5),
(
          <xref ref-type="bibr" rid="ref2">2</xref>
          )
where 0 ≤ Q &lt; 5 ⋅ 7 ⋅. . .⋅ QM5( = 1, . . . , ) are RNS coefficients.
        </p>
        <p>The ranges of numbers represented in RNS and WNS are the same. We can talk about a one-to-one
correspondence between the set of representations of numbers in RNS and WNS.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Base Extension in Residue Number System</title>
      <p>The base extension is one of the main non-modular operations in RNS [5]. The base extension of the
number in RNS is possible for the following reasons. Firstly, it lacks the significance of the order of
numbers in a number record. Secondly, both codes and verified numbers are represented as residues,
which allow such codes to be considered completely arithmetic.</p>
      <p>Based on these properties, we can conclude that modular arithmetic can effectively solve the problem
of building both fault-tolerant and high-performance systems. Due to its properties, RNS [6] has a basis
for modifying encryption methods, increasing their cryptographic strength, and performance of
information security. Many publications demonstrate the practical application of RNS in digital
communication systems, global communication systems, wireless networks, fault-tolerant hybrid
memory structures, and others. In this paper, we study the calculation of RNS using various algorithms
and methods.</p>
      <p>This operation may be necessary when performing the division, calculating positional characteristics,
or when overflow is detected after adding or multiplying numbers, for example, Montgomery
multiplication.</p>
      <p>The problem of the base extension can be formulated as follows: To find the residual representation
of a number on a new base (new bases). If the representation of a number on other bases is known, to
find the residue of division by other numbers. One of the ways to extend the base is to translate the
number into a positional number system and calculate the residue of the division by a new module. This
path is not efficient in terms of the number of operations. Another method of the base extension is to
determine the digit of a number on a new base, using positional characteristics of the number as the
range of ′, where ′ is the range of  in the extended base.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Base Extension Based on Translating a Number from RNS into WNS</title>
      <p>We study the following algorithms for returning a number in WNS: CRT based method; Translation
Method of the Mixed Radix Conversion (MRC); Modified CRT Method; Core function method;
Diagonal Function Method; Approximate method.</p>
      <p>For these methods, the general operation is the operation of finding the residue of the modulo
division. This operation is not displayed in the description of the algorithms since it is obvious.</p>
      <sec id="sec-4-1">
        <title>4.1. CRT based method</title>
        <p>CRT based method calculates the formula [7]:
where Z 5 Z is a multiplicative inversion &amp; modulo &amp;.</p>
        <p>X* ) *</p>
        <p>Also, the calculation of this method can be represented as
where &amp; = &amp; ∙ Z 5 Z ∙ &amp;</p>
        <p>X* ) *
Algorithm 1. Base extension with CRT
 = |5 + 7 + ⋯ + 9 |X ,
Output: 
1.  = 0
2. for  = 1 to  do:</p>
        <p>
          9 5
Input:(5, 7, … , 9 ), (5, 7, … , 9 )  = ∏&amp;&gt;5 &amp;, &amp; = &amp; ⋅ ZX*Z) *, for  = ]1]],]].
(
          <xref ref-type="bibr" rid="ref3">3</xref>
          )
(
          <xref ref-type="bibr" rid="ref4">4</xref>
          )
2.1  += 5 ∙ &amp;
3.  = ||X
4. return
        </p>
        <p>
          To illustrate base extension with CRT, let us consider the following Example 1.
35, 7 = dcf = 21,
O = dch = 15. Then the restoration of the number from (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) is the following.
        </p>
        <p>Example 1 (Base extension with CRT). The initial data includes a set of residues 5 = 1, 7 =
1, O = 0 and a set of moduli 5 = 3, 7 = 5, O = 7. We calculate  = 5 ⋅ 7 ⋅ O = 105, 5 = dce =
5
5 = 5 ∙ Z Z</p>
        <p>Xe ) e
5
5 = 5 ∙ Z Z</p>
        <p>Xe ) e</p>
        <p>5
∙ 5 = 1 ∙ 2 ∙ 35 = 70, 7 = 7 ∙ Z Z</p>
        <p>Xf ) e</p>
        <p>∙ 7 = 1 ∙ 1 ∙ 21 = 21,
∙ O = 0 ∙ 1 ∙ 15 = 0,  = |5 + 7 + O|c = |70 + 21 + 0|X</p>
      </sec>
      <sec id="sec-4-2">
        <title>4.2. MRC method</title>
        <p>MRC performs converting a number from RNS to WNS. Also, in this algorithm, is traced in a
generalized form &amp; = |&amp; ∙ &amp;|k *, which is defined as the translation coefficient, where &amp; defined as
follows:</p>
        <p>To illustrate base extension with MRC, let us consider the following Example 2.</p>
        <p>Example 2 (Base extension with MRC). The initial data contains a set of moduli 5 = 127, 7 =
63, O = 50, r = 13 and a set of residues 5 = 78, 7 = 41, O = 47, r = 7. 5 = 1, 7 = 1 O =
1 r = 1 are the same.</p>
        <p>First, we need to find the coefficients:
5 = 5 ∙ 5 = 78,
7 = 7 ∙ 7 = (41 − 78)uO ∙ 1 = 26,
O = O ∙ O = (47 − 78 − 127 ∙ 26)vn ∙ 1 = 17,</p>
        <sec id="sec-4-2-1">
          <title>Yassin and Moore [8] found that</title>
          <p>
            the number is restored to WNS by (
            <xref ref-type="bibr" rid="ref2">2</xref>
            ).
          </p>
        </sec>
        <sec id="sec-4-2-2">
          <title>Algorithm 2 Base extension with MRC</title>
          <p>Input:(5, 7, … , 9 ), (5, 7, … , 9 )
Output: 
1. 5 = 5, 5 = 0, ℎ = 0
2. for  = 2 to  do
2.1 ℎ ∗= &amp;M5
2.2 &amp; = (&amp; − 5 − &amp;M5)  &amp;
2.3 &amp; = &amp; ∗ ℎ − &amp;M5
3.  = 1,  = Un
4. for  = 2 to  do
5.1  ∗= &amp;M5
5.2  +=  ⋅ |Uo|dp  &amp;
5.3  = 
6. return 
5 = 5, 7 = |7 − 5|ke, O = |O − 7 − 57|kf.
= 1, 7 = Z</p>
          <p>
            5 Z
) e) f ) h
= 1,
(
            <xref ref-type="bibr" rid="ref5">5</xref>
            )
(
            <xref ref-type="bibr" rid="ref6">6</xref>
            )
O = r ∙ r = (7 − 78 − 127 ∙ 26 − 127 ∙ 63 ∙ 17)5O ∙ 1 = 9.
          </p>
          <p>
            Based on the obtained values, the number in WRS is calculated according to (
            <xref ref-type="bibr" rid="ref2">2</xref>
            )
78 + 26 ∙ 127 + 17 ∙ 127 ∙ 63 + 9 ∙ 127 ∙ 633 ∙ 50 = 3 739 847
          </p>
        </sec>
      </sec>
      <sec id="sec-4-3">
        <title>4.3. Modified CRT Method</title>
        <p>In general, this method is the standard CRT method [9] modified by translating coefficients &amp; defined
in WNS [10], which are calculated as follows:
where () is a range from moduli range,
⋅ ()U ,</p>
        <p>) *
&amp; = &amp; ∙ Z 5 Z ,</p>
        <p>X* ) *
(8)
(9)
(10)
Example 3 (Base extension with modified CRT). The input in this example is a set of residues
calculated by 5 = 3, 7 = 5, O = 7, r = 11, 5 = 385, 7 =
5 = 1, 7 = 2, O = 3, r = 4)
231, O = 165, r = 105.</p>
        <p>In the beginning, we calculate the coefficients yo.
5 = OvZheOZhM5 = 128, 7 = 5O5∙vvv Z7O55Zv = 77, O = 5O5∙vv Z5u5v Z = 110, r = 5O5∙5v5v Z5n5v Z55 = 70
Then, based on the calculated coefficients, the number is restored
 = 1 + 3 ∙ (128 + 154)v + 15 ∙ 
= 1 + 3 ∙ 2 + 15 ∙ 3 + 105 ∙ 3 = 367</p>
      </sec>
      <sec id="sec-4-4">
        <title>4.4. Core function method</title>
        <p>In addition to using sequential MRC to translate a number from RNS to WNS, it uses core functions
[11-13]. This method is about calculating the weights of the function (9):
which allow the calculation of these functions [11]:</p>
        <p>() = |∑&amp;9&gt;5 &amp; ∙ (&amp;)|X ,
and use them to translate the number</p>
        <p>= (XX ) W() + ∑&amp;9&gt;5 )** &amp;Y,
Algorithm 4 Base extension with Core Function
Input:(5, 7, … , 9 ), (5, 7, … , 9 ), , (5, 7, … , 9 ), (), (&amp;), &amp; for  = ]1]],]].
Output: 
1.  = 0
2. for  = 1 to  do:
2.1  += &amp; ∙ (&amp;)
3.  = ||(X)
4.  = 0
5. for  = 1 to  do:
5.1 += (&amp;/&amp;) ∙ &amp;
6.  = (XX ) ∙ ( + )
7. return 
To illustrate base extension with Core Function, let us consider the following Example 4.
(11)
(12)
Example 4 (Base extension with Core Function). The input in this example is a set of residues
r
5 = 1, 7 = 2, O = 3, and r = 4 calculated by 5 =3, 7 =5, O =7, r =11,  = ∏&amp;&gt;5 &amp; = 1155,
5 = )Xe = 385,
7 = )Xf = 231, O = )Xh = 165, r = dc = 105.</p>
        <p>Let 5 = 0, 7 = 0, O = 0, r = 1.</p>
        <p>Further, the coefficients are calculated
5 = 5 ⋅ ZX5eZ) e = 385 ∙ ZO5vZO = 385, 7 = 7 ⋅ ZX5fZ) f = 231 ∙ Z7O55Zv = 231,
O = O ⋅ ZX5hZ) h = 165 ∙ Z5u5v Z = 330, r = r ⋅ ZX5Z)  = 105 ∙ Z5n5v Z55 = 210
Calculating the functions, the following values were obtained
С(5) = ∑&amp;r&gt;5 &amp; | )e*  = |e = 35, С(7) = ∑&amp;r&gt;5 &amp; | )f*  = |f = 21,</p>
        <p>)  ) 
С(O) = ∑&amp;r&gt;5 &amp; | )h*  = |)h = 30, С(r ) = ∑&amp;r&gt;5 &amp; | )*  = |) = 19 and
r</p>
        <p>r X X
() = ∑&amp;&gt;5 &amp; |) * = |  = r =105</p>
        <p>) 
() =  &amp; ∙ (&amp;)</p>
        <p>= |1 ⋅ 35 + 2 ⋅ 21 + 3 ⋅ 30 + 4 ⋅ 19|5nv = 33
&amp;&gt;5 (X )
Thus, the number is restored from the calculated values</p>
        <p>r
 =</p>
        <p>()
() + </p>
        <p>&amp; =
&amp;&gt;5
&amp;
&amp;</p>
      </sec>
      <sec id="sec-4-5">
        <title>4.5. Diagonal Function Method</title>
        <p>The Diagonal function is calculated using the following formula:
9
() =   
&amp;&gt;5

&amp;
() =  &amp; ⋅ &amp; </p>
        <p>
5
where &amp; = Z−</p>
        <p>9
and  = ∑&amp;&gt;5 &amp; is Sum of Quotients.</p>
        <p>Z
) * </p>
        <p>This method is similar to the Core function method, with some exceptions. The weight wo = 1 for
all i of this function is 1 [15-17], so the formulas in Section 4.4 look as follows:</p>
        <p>= X W() + ∑&amp;9&gt;5 )~**Y (13)
Algorithm 5. Base extension with Diagonal function
Input:(5, 7, … , 9 ), (5, 7, … , 9 ), , (5, 7, … , 9 ), , &amp; = −
for  = 1]]],]].
5</p>
        <p>
do ¢£
Output: X
1.  = 0
2. for  = 1 to  do:
2.1  += &amp; ∙ &amp;
3.  = ||
4.  = 0
5. for  = 1 to  do:
5.1 += (&amp;/&amp;) ∙ &amp;
6.  = X (() + )
7. return 
To illustrate base extension with Diagonal function, let us consider the following Example 5.
Example 5 (Base extension with Diagonal function). The input in this example is a set of residues
r
5 = 1, 7 = 2, O = 3, r = 4 calculated by 5 = 3, p7 = 5, pO = 7, pr = 11,  = ∏&amp;&gt;5 &amp; = 1155,
5 = )Xe = 385, 7 = )Xf = 231,
O = )Xh = 165, r = dc = 105, and  = 5 + 7 + O + r = 886. The coefficients Diagonal
function are calculated as follows:
5 = Z− )5eZ¢£ = Z− 5OZu = 295, 7 = Z− 5 = 177, O = Z− d5hZ¢£ = Z− 5Zu = 253,</p>
        <p>Z
df £¢
1</p>
        <p>
r </p>
        <p>5
= Z− Z
v u
1
= −</p>
        <p>
11 u

r = −
= 161
Calculating D(X), we obtained:</p>
        <p>r
() =  &amp; ⋅ &amp;</p>
        <p>= |295 ⋅ 1 + 177 ⋅ 2 + 253 ⋅ 3 + 161 ⋅ 4|u = |2052|u = 280
&amp;&gt;5 ¢£
Thus, the number is restored from the calculated values:</p>
        <p>9
 =


() + 
&amp;&gt;5 &amp;
&amp;
 =
1155
886
280 +
1
3
2
5
+
+
3
7
+
4
11
 =</p>
        <p>&amp; = §|5/)c*p|¨* ∙ 2©ª,
9
where  = ⌈log7( ⋅ )⌉, and  = ∑&amp;&gt;5 &amp; − . Next, the number is calculated as (15)
(14)
 = ²∑*³e Q7*∙´~* ²f´∙X,
Algorithm 6. Base extension with CRT approximate method
Input:(x5, x7, … , x¶), (p5, p7, … , p¶), P, (P5, P7, … , P¶), N, ko = §|5/dcpp|ºp ∙ 2»ª for i = ]1]],]n] .
Output: X
1. sum = 0
2. for i = 1 to n do:
2.1 sum+= ko ∙ xo
3. sum = sum AND 2» − 1
4. X = (sum ∙ P) ≫ N
5. return X
To illustrate base extension with CRT approximate method, let us consider the following Example
(15)
6.</p>
        <p>Example 6 (Base extension with CRT approximate method). The input in this example is a set of
r
residues 5 = 1, 7 = 2, O = 3, r = 4 calculated by 5 = 3, 7 = 5, O = 7, r = 11,  = ∏&amp;&gt;5 &amp; =
1155, 5 = )Xe = 385, 7 = )Xf = 231, O = )Xh = 165, r = dc = 105,  = ∑&amp;9&gt;5 &amp; − n = 3 + 5 +
7 + 11 − 4 = 22 and  = ⌈log7( ⋅ )⌉ = ⌈log7(1155 ⋅ 22)⌉ = 15.</p>
        <p>Calculating the coefficients, the following values were obtained
5 = §|5/c)ee|¨e ∙ 2©ª = §|5/OOv|h ∙ 25v ª = 10923, 7 = §|5/c)ff|ºf ∙ 2©ª = §|5/7vO5| ∙ 25v ª = 6554,
O = §|5/c)hh|ºf ∙ 2©ª = §|5/5uv |Á ∙ 25v ª = 9363, r = §|5/c)|º ∙ 2©ª = §|5/55n5v |ee ∙ 25v ª = 5958
¶
Calculate |∑o&gt;5 ko ∙ xo|7Â, we have:
9</p>
        <p>= |10923 ⋅ 1 + 6554 ⋅ 2 + 9363 ⋅ 3 + 5958 ⋅ 4|7e = |75952|7e = 10416
 &amp; ∙ &amp;
&amp;&gt;5 7´
Thus, based on the coefficients, we can translate the number</p>
        <p>|∑&amp;9&gt;5 &amp; ∙ &amp;|7´ ∙  10416 ∙ 1155
 = Ã 2© Ä =  25v
 = 367
5. Base Extension Based on Scaling a Number with the Number Range Function in RNS
We concentrate on two algorithms for extension of the range of the base:
• Extension method using integer arithmetic.
• Extension method using floating point arithmetic.</p>
        <p>For both methods, the general operation is the operation of finding the residue of the division modulo.
Therefore, this operation is not displayed in the description of the algorithms, since it is obvious.</p>
      </sec>
      <sec id="sec-4-6">
        <title>5.1. Extension method using integer arithmetic</title>
        <p>The first method uses the equation as shown in (16) [19].</p>
        <p>Output: xË
9Å = ∑&amp;9&gt;5 U&amp; ∙ Z 5 Z U ∙ |o|dÆÇ −  ⋅ ||) ÉÇ , (16)</p>
        <p>X* ) * ) * Ç
) É</p>
        <p>This method can be considered as calculating CRT without decreasing the dynamic modulo range P.
This means that the converted value can have multiples of P.</p>
        <p>Algorithm 7. Base extension with new CRT
Input:(x5, x7, … , x¶), Êp5, p7, … , p¶, pËÌ, P, v, |P|dÆÇ, (P5, P7, … , P¶), pËÎ, Z 5 Z and |Po|dÆÇ for i = 1]]],]n].
cp dp
1. sum = −v ⋅ |P|dÆÇ
1. for i = 1 to n do:
1.1 sum += Uxo ∙ Zc5pZdpUdp ∙ |Po|dÆÇ
2. xË = sum mod pËÎ
3. return xË
To illustrate base extension with new CRT, let us consider the following Example 7.</p>
        <p>Example 7 (Base extension with new CRT). The input in this example is a set of residues 5 =
1, 7 = 2, O = 3, r =4 calculated by 5 = 3, 7 = 5, O = 7, r = 11, base extends by 5Î = 17,  =
c = 105, and
d
|∏3&amp;r8&gt;55|5&amp; == 11115,5,|7|)5eÇ==)X|e2=313|585,=710=, )Xf|=O|2)3eÇ1=, |1O6=5|)5Xh == 11625,, |rr =|) eÇ = |105|5 = 3, |Z55|Z) eÇ ==
Xe ) e
ZO5vZO = 1, ZX5fZ) f = Z7O55Zv = 1, ZX5hZ) h = Z5u5v Z = 2, ZX5Z)  = Z5n5vZ55 = 2, and ||) ÉÇ = |1155|5 = 16.</p>
        <p>¶
We use from Example 6 ∑o&gt;5 ko ∙ xo = 10923 ⋅ 1 + 6554 ⋅ 2 + 9363 ⋅ 3 + 5958 ⋅ 4 = 75952 then
Ñ vÒv7
v = |∑p³e Ïp∙Ðp = | 7e  = 2.</p>
        <p>7Â
9</p>
        <p>1</p>
      </sec>
      <sec id="sec-4-7">
        <title>5.2. Extension method using floating-point arithmetic</title>
        <p>This method, instead of an approximate conversion (a conversion with the excess flow), estimates  and
uses the exact value for the conversion [19, 21-25]. Equation (17) can be reformulated to find  as
follows:
 = Ô∑&amp;9&gt;5 U&amp; ∙ Z 5 Z U ∙ 5 Õ ,</p>
        <p>X* ) * dp dp
(17)</p>
        <p>The key problem of this method is to ensure that the estimate of v is correct. Since v is estimated
using floating-point operations, errors due to limited accuracy can occur and lead to a value of v to be
equal to one.</p>
        <p>Algorithm 8. Base extension with CRT fractions number
Input:(x5, x7, … , x¶), Êp5, p7, … , p¶, pËÌ, P, (P5, P7, … , P¶), for i = ]1]],]n] .</p>
        <p>Output: aË
1. for 1 to n do:
1.1 vo = d5p ∙ xo mod po ∙ Zc5pZdp
2. for 1 to n do:</p>
        <p>c
2.1 F += (xo ∙ po)dp ∙ dp − vo ∙ Po
3. aË = F mod pË
To illustrate base extension with CRT fractions number, let us consider the following Example 8.</p>
        <p>Example 8 (Base extension with CRT fractions number). The input in this example is the set of
residues 5 = 1, 7 = 2, O = 3, r = 4) calculated by moduli 5 = 3, 7 = 5, O = 7, r = 11. The
1 1
 = × &amp; ∙    ⋅ Ø = Ã</p>
        <p>&amp; ) * ) * po
&amp;&gt;5
Using (16) let's calculate xr 5, we have:
9</p>
        <p>3
|1 ⋅ 1|O
1
Z
5 Z = 1, Z 5 Z
Ov O Xf ) f
9
= Z
5 Z = 1, Z 5 Z
7O5 v Xh ) h
= Z
5 Z = 2, Z 5 Z
5uv  X ) 
= Z
5 Z
5nv 55
= 2
base is extended by 15, 5 = 385, 7 = 231, O = 165, r = 105. We use from Example 7 Z 5 Z
Xe ) e
=
+
|2 ⋅ 1|v
5
+
|3 ⋅ 2|
7
+</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>6. Base Extension with NN</title>
      <p>To increase efficiency of the base extension, we use NN [20]. The calculation of the new residue is
based on the range of the number, which can be defined as:</p>
      <p>3 = |∑&amp;9&gt;5 &amp;&amp;|) ,</p>
      <sec id="sec-5-1">
        <title>For base extension, it is necessary:</title>
        <p>• Calculate number range Å in the base system 5, 7, … , 9 M5 according to the expression (18);
• Find the residue Å according to the (19).</p>
        <p>The proposed method of base extension is characterized by the calculation of small modulo p¶
instead of calculation of the large modulo P in traditional CRT. The residue of the number on an
extendable base can be obtained using modular NN. Moreover, the constants of expressions (19), (20)
can be calculated in advance and used in the network structure. NN presented in Figure 1.
PoÎ = cÇ. Figure 2 shows the NN structure.</p>
        <p>dp</p>
        <p>The input network receives modular values x5 ÷ x¶. At the first stage, the modular neural network
modulo p¶ by weighted summation of the modular values of the number x5 ÷ x¶ with coefficients g5 ÷
g¶ calculates the range of a number rÞ, and the modular network modulo pË calculates the value
∑o¶&gt;M55 ao|Bo|dÑàe. The second step is calculating xË = |X|dÆ using a computational model (20).</p>
        <p>Each set of bases of modular code is characterized by orthogonal bases, based on which, extending
the base system, it is necessary to recalculate the bases BoÎ, i = 1]],]n]]]+]]]1]. For recalculation, the input data
includes orthogonal bases Bo, i = 1]]],]n], base systems p5, p7, … , p¶ and the values of the extendable base
pË. Thus, we get the following expression:
To solve this problem in a neural network basis, it is necessary to calculate two constants:  5  and
dÆ dp</p>
        <p>The proposed algorithm has less computational complexity compared to the methods described
above. However, the method involves multiplying by pre-calculated constants. Assuming that these
constants are usually known in advance, we can conclude that the algorithm is more efficient.</p>
        <p>To illustrate base extension with NN, let us consider the following example.</p>
        <p>Example 9. The initial data is a set of residues 5 = 1, 7 = 2, O = 3, r = 2 and a set of moduli
5 = 2, 7 = 3, O = 5, r = 7. Then the extension of the base modulo Å = 11 is the following.
The representation range of numbers is in a system with bases 5, 7, O  = 2 ∙ 3 ∙ 5 = 30, orthogonal
bases are equal 5 = 15, 7 = 10, O = 6. We calculate the range, while 5 = 4, 7 = 5, O = 3, r =
3:3 = |4 ∙ 1 + 5 ∙ 2 + 3 ∙ 3 + 3 ∙ 2| = |4 + 10 + 9 + 6| = 1..</p>
        <p>Putting the obtained value in (25) we get:</p>
        <p>Å = |1 ∙ |15|55 + 2 ∙ |10|55 + 3 ∙ |6| + 1 ∙ (11 − |30|55 )|55 = |4 + 20 + 18 + 3|55 = 1.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>7. Performance Analysis</title>
      <p>For the implementation of the algorithms, Python was chosen. It uses long arithmetic (work with
highbit numbers) without connecting additional libraries and APIs.</p>
      <p>We consider 128-bit numbers, sets of 7 moduli (6 in the “vector length”, 1 extending range) with a
24-64 bit lengths.</p>
      <p>All methods are implemented as separate functions. Each function is called separately to work with
the already calculated RNS for the "vector length".</p>
      <p>The study is carried out in 2 stages. The first one considers the efficiency of algorithms with a static
"vector length" and a dynamic modulo length in bits. The second stage is the opposite of the first stage:
the length of the moduli is static, and the “vector length” is dynamic.</p>
      <sec id="sec-6-1">
        <title>7.1. The First Stage of the Research</title>
        <p>Figure 3 shows execution time obtained at the first stage. Our algorithms show the best results.
43</p>
        <p>The growth dynamics of the execution time of the algorithms is uneven. It can be explained by the
fact that as the length of the numbers of moduli increases, their basis increases by 10¶ times, where n
is the difference in the length of numbers.</p>
        <p>It also depends on many other parameters that can affect the speed of a function in Python.</p>
        <p>The most important result is the fact that algorithms with integer arithmetic have shown their
efficiency equal to about 200% and, unlike traditional algorithms, work more stably. Based on the
analysis of NN, we can see the advantage of this method over others. In general, we can observe a low
drop in productivity with an increase in the capacity of the moduli, which allows us to declare the
promise of using this method as the best for systems with a dynamic range of RNS moduli.</p>
      </sec>
      <sec id="sec-6-2">
        <title>7.2. The Second Stage of the Research</title>
        <p>The second stage of research shows a similar result to what was obtained in the first stage (Figure 4).
s
m
,
t
3</p>
        <p>4
Moduli vector length</p>
        <p>5
With a vector length of six, the execution time of traditional algorithms is almost identical, except
for the approximate method. Arithmetic-based algorithms show better performance. With a vector
length of two, a performance is increased about 100%. With a vector length of six is 400% faster. We
show that NN is the most suitable method, since this method is the most productive.</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>8. Conclusion</title>
      <p>In this paper, we studied the algorithms for base extension in RNS. We analyze algorithms for both
traditional base extension methods and methods implemented using integer and floating-point
arithmetic. We show the superiority of the NN-based algorithm. It uses machine learning to calculate a
new residue. The number of pre-calculated constants is small and does not require large computing
power. Thus, the result of this work is the definition of the base extension algorithm using NN as the
most suitable for practical use in various computing systems with RNS.</p>
      <p>Acknowledgments
This work was supported by a grant from the President of the Russian Federation MK-341.2019.9.
[7] Bi G., Jones E.V. Fast conversion between binary and Residue Numbers. Electron Lett. 24, 1195–
1197 (1988)
[8] H.M. Yassine, W.R. Moore, Improved Mixed radix conversion for residue number system
architectures. Proc. IEE Part G 138, 120–124 (1991)
[9] Wang Y., Residue to binary converters based on New Chinese Residue theorems. IEEE Trans.</p>
      <p>Circuits Syst. II 47, 197–205 (2000)
[10] Bi S., Gross W.J., The Mixed-Radix Chinese Residue Theorem and its applications to Residue
comparison. IEEE Trans. Comput. 57, 1624–1632 (2008)
[11] Miller D.D. et al., Analysis of a Residue Class Core Function of Akushskii, Burcev and Pak, in
RNS Arithmetic: Modern Applications in DSP, ed. by G.A. Jullien (IEEE Press, Piscataway,
1986)
[12] Gonnella J., The application of core functions to residue number systems. IEEE Trans. Signal</p>
      <p>Process. SP-39, 69–75 (1991)
[13] Burgess N., Scaled and unscaled residue number systems to binary conversion techniques using
the core function, in Proceedings of 13th IEEE Symposium on Computer Arithmetic, pp 250–
257 (1997)
[14] Krishnan R., Ehrenberg J., Ray G., A core function-based residue to binary decoder for RNS filter
architectures, in Proceedings of 33rd Midwest Symposium on Circuits and Systems, pp. 837–
840 (1990)
[15] Dimauro G., Impedevo S., Pirlo G. A new technique for fast number comparison in the Residue</p>
      <p>Number system. IEEE Trans. Comput. 42, 608–612 (1993)
[16] Dimauro G., Impedevo S., Pirlo G., Salzo A., RNS architectures for the implementation of the
diagonal function. Inf. Process. Lett. 73, 189–198 (2000)
[17] Pirlo G., Impedovo D., A new class of monotone functions of the Residue number system. Int. J.</p>
      <p>
        Math. Models Methods Appl. Sci. 7, 802–809 (2013)
[18] Hung C.Y. and Parhami B., An approximate sign detection method for residue numbers and its
application to RNS division, Comput. Math. Appl. 27 (
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) (1994), pp. 23–35
[19] Harvey D. Faster Arithmetic for Number-Theoretic Transforms. Journal of Symbolic
      </p>
      <p>Computation, 60: 113–119, 2014.
[20] Vasetskiy V.V. The implementation of artificial neural networks in a non-positional number
system for automated control systems in Journal of SFU. Technics and techology. 2018. No1
[21] Chervyakov N, Babenko M, Tchernykh A, Kucherov N, Miranda-López V and
CortésMendoza J M 2019 AR-RRNS: Configurable reliable distributed data storage systems for
Internet of Things to ensure security Futur. Gener. Comput. Syst. 92 1080–92
[22] Tchernykh A, Babenko M, Chervyakov N, Miranda-Lopez V, Avetisyan A, Drozdov A Y,
Rivera-Rodriguez R, Radchenko G and Du Z 2020 Scalable Data Storage Design for
NonStationary IoT Environment with Adaptive Security and Reliability IEEE Internet Things J.
[23] Tchernykh A, Babenko M, Chervyakov N, Miranda-López V, Kuchukov V, Cortés-Mendoza J
M, Deryabin M, Kucherov N, Radchenko G and Avetisyan A 2018 AC-RRNS:
Anticollusion secured data sharing scheme for cloud storage Int. J. Approx. Reason. 102 60–73
[24] Babenko M, Tchernykh A, Chervyakov N, Kuchukov V, Miranda-López V, Rivera-Rodriguez R,
Du Z and Talbi E-G 2019 Positional Characteristics for Efficient Number Comparison over
the Homomorphic Encryption Program. Comput. Softw. 45 532–43
[25] Tchernykh A, Miranda-López V, Babenko M, Armenta-Cano F, Radchenko G, Drozdov A Y and
Avetisyan A 2019 Performance evaluation of secret sharing schemes with data recovery in
secured and reliable heterogeneous multi-cloud storage Cluster Comput. 22 1173–85</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Eldridge</surname>
            <given-names>S.E.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Walter C. D.</surname>
          </string-name>
          .
          <article-title>Hardware implementation of Montgomery's modular multiplication algorithm</article-title>
          .
          <source>IEEE Transaction on Computers</source>
          ,
          <volume>42</volume>
          (
          <issue>6</issue>
          ):
          <fpage>693</fpage>
          -
          <lpage>699</lpage>
          ,
          <year>June 1993</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Parhami</surname>
            <given-names>B. RNS</given-names>
          </string-name>
          <article-title>representations with redundant residues</article-title>
          .
          <source>Signals, Systems and Computers</source>
          ,
          <source>2001. Conference Record of the Thirty-Fifth Asilomar Conference</source>
          ,
          <year>2001</year>
          , vol.
          <volume>2</volume>
          , pp.
          <fpage>1651</fpage>
          -
          <lpage>1655</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Inyutin</surname>
            <given-names>S. A.</given-names>
          </string-name>
          <article-title>Modular arithmetic in Meot archaeological culture - Mongol-Tatar invasion</article-title>
          . - M.: Big Russian Encyclopedia,
          <year>2012</year>
          .
          <article-title>- (Big Russian Encyclopedia:</article-title>
          [in 35 vols.] / Ch. Ed. Yu. S. Osipov;
          <fpage>2004</fpage>
          -
          <lpage>2017</lpage>
          , vol.
          <volume>20</volume>
          ).
          <source>- ISBN 978-5-85270-354-5.</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Sagalovich</given-names>
            <surname>Yu</surname>
          </string-name>
          . L. Introduction to algebraic codes - 2nd ed. - M.:
          <string-name>
            <surname>IPPI</surname>
            <given-names>RAS</given-names>
          </string-name>
          ,
          <year>2010</year>
          .-- 320 p.
          <source>- ISBN 978-5-901158-14-2</source>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Lavrinenko</surname>
            <given-names>A.N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chervyakov</surname>
            <given-names>N.I.</given-names>
          </string-name>
          <article-title>Research of non-modular operations in the system of residual classes in Scientific statements</article-title>
          of Belgorod State University. Series: Economics. Computer science.
          <year>2012</year>
          . No.
          <issue>1-1</issue>
          (
          <issue>120</issue>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Erdnieva</surname>
            <given-names>N. S.</given-names>
          </string-name>
          <article-title>The use of special moduli of the Residue Numbers System for redundant representations in Vestnik ASTU</article-title>
          . Series: Management,
          <source>Computing and Informatics</source>
          .
          <year>2013</year>
          . No2.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>