Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 ZOT-BINARY: A NEW NUMBERING SYSTEM WITH AN APPLICATION ON BIG-INTEGER MULTIPLICATION

1SHAHRAM JAHANI, 2AZMAN SAMSUDIN

1,2 School of Computer Sciences, Universiti Sains Malaysia,Pulau Penang, Malaysia

E-mail: [email protected], [email protected]

ABSTRACT

In this paper we present a new numbering system with an efficient application on Big-Integer multiplication. The paper starts with an introduction to a new redundant positional numbering system known as “Big-Digit Numbering System” (BDNS). With BDNS, a new non-redundant positional numbering system known as ZOT-Binary is proposed. ZOT-Binary has a low Hamming weight with an average of 23.8% nonzero symbols, and therefore is highly suitable for Big-Integer calculation, especially for Big- Integer multiplication. To harvest such benefit from the ZOT-Binary representation, a new Big-Integer multiplication algorithm, ZOT-CM, which is based on the Classical multiplication algorithm, is proposed. Our result shows that when compared with the Classical multiplication algorithm, ZOT-CM is about 12 times faster for multiplying 128 bits numbers and at least 16 times faster for multiplying numbers that are bigger than 32,000 bits long. Our result also shows that ZOT-CM is about 20 to 3 times faster than Karatsuba multiplication algorithm, for multiplying numbers that are ranging from 128 bits to 32,000 bits long. From the findings, it is clear that ZOT-CM is a valuable addition to Big-Integer multiplication algorithm, and it is also believed that ZOT-Binary representation can benefit many other Big-Integer calculations. Keywords: Numbering system, Big-Integer multiplication, Cryptography, Hamming weight.

1. INTRODUCTION [8], Toom-Cook [9, 10] and Shonang-Strassen [11], in which the first two algorithms are more common Numbering system has always been important in than the others. Although the complexity of the history of human civilization, and the increasing Classical multiplication algorithm, ( ), is higher of number crunching applications signifies than the complexity of other algorithms,2 Xianjin numbering system as a crucial necessity more than and Longshu [12] have shown that푂 푛the Classical in the past. To improve arithmetic operations, multiplication algorithm is efficient for multiplying researchers [1-4] have looked into alternative numbers that are less than 255 digits long. On top numbering systems. For example, by proposing of its efficiency, it has also been shown that signed-binary numbers [1, 3, 4] instead of the Classical multiplication algorithm is efficient in standard binary numbers has decreased the number memory utilization. Karatsuba multiplication of partial product in Classical multiplication algorithm has a better complexity, ( . ), algorithm [5] and therefore increased overall compared to Classical multiplication algorithm.1 58 algorithm efficiency. Multi-base numbering However Karatsuba multiplication algorithm푂 푛 systems [2, 6, 7] are other similar examples. overhead in lower range numbers (less than 255 The main goal of this paper is to increase the digits) has caused implementers [12] to combine efficiency of Big-Integer multiplication operation both algorithms, Classical and Karatsuba, to which has many important applications, such as achieve better overall algorithm efficiency. In this cryptography and other scientific calculations. To paper we propose a new numbering system that can achieve this goal, modification of known help improve the efficiency of Classical multiplication algorithm running on top of a new multiplication algorithm and consequently increase numbering system has been identified as the the range of its functionality above the 255 digits approach. The most popular algorithms for Big- threshold. Integers multiplication are Classical, Karatsuba

29

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 We review most of the related works on the symbols in -2. Booth [1], NAF [3] and MOF positional numbering system of radix 2 in Section [4] algorithms are the examples of SB numbering 2.1. We describe the Classical multiplication systems that take advantage from this redundancy algorithm in Section 2.2. Section 3 is dedicated to to decrease the number of operations in the the proposed numbering systems, BDNS, and ZOT- multiplication [1, 15-18], exponentiation [19, 20] Binary. In Section 3.4 the proposed multiplication and scalar multiplication [1, 3, 4, 17, 18] algorithms mbCM and ZOT-CM are described. We computations. present the experimental results and comparison of Booth [1] in 1959 proposed an algorithm to the proposed multiplication algorithm with existing speed up the Classical multiplication computation methods in Section 4, before concluding in Section on computer. The main goal of the original Booth’s 5. algorithm and in the higher radix Booth’s algorithm 2. NUMBERING SYSTEMS AND [15, 16], is to decrease the number of partial ARITHMETIC OPERATIONS product in the algorithm by decreasing the number of nonzero digits in the binary representation Section 2.1 reviews positional numbering system through the use of the symbol “-1” in radix-2. since it has a significant role in arithmetic operations. Following that, Section 2.2 reviews the NAF (Non-Adjacent-Form) [3] is another ternary Classical multiplication algorithm which is numbering system that was introduced by fundamental to the work of this paper. Reitwiesner in 1960. NAF representation is obtained by scanning every 3 bits in a binary 2.1. Positional Numbering System number (from right to left) and substituting “ 11” In positional numbering system, an integer in with “101” where “1” denotes “−1” and radix-r (or base r) can be written as: represents any digit. The immediate advantage푥 of � � 푥 ( … ) = + + + (1) the NAF representation is a low Hamming weight, 푛 1 which is 1/3 [21]. The generalization of If푎 푛0 푎1푎<0 푟 , then푎푛푟 this representation⋯ 푎1푟 푎 0is unique. Reitwiesner’s NAF algorithm can be found in [22, We call as digit, and its related set, such as 푖 23]. {0,1, …≤, r푎 1},푟 as digit set. numbers with 푖 r = 10 and푎 {0,1, … ,9}, and binary numbers Another important SB representation is MOF (Mutual Opposite Form). MOF has a Hamming with r = 2− and {0,1}, are the two most known 푖 weight of 1/2 [4]. However MOF can perform its numbering systems.푎 ∈ Ternary (r = 3), quaternary (r 푖 calculation in both directions (right-to-left and left- = 4), (r = 푎8) ∈and (r = 16) are the to-right) and requires less memory compared to other examples of fixed-radix positional numbering NAF. system [5]. Note that, the SB representation is not always 2.1.1. Fixed-radix numbering system used for optimizing arithmetic operations. For Equation (1) represents the fixed-radix example, in [24] the Highest-Weight Binary Form numbering system. The weight of each digit (HBF) of scalars and randomization are proposed to ( for ) in the representation is obtained by resist power analysis in Elliptic Curve multiplying푖 a fixed value (r) by the previous digit’s i Cryptography (ECC). There is another ternary weight푟 푎( ). In the following, our discussion numbering system, System [5, focus on the푖− 1radix-2 number systems with different 25], which is very similar to the SB numbering digit set. 푟We use S to represent the digit set. system. Balance Ternary System uses the same 2.1.1.1. digits set as the SB numbering system but with a The birth of radix-2 arithmetic is usually base of 3. attributed to G. W. Leibniz[13], while the binary 2.1.1.3. Multi-Base numbering system (MBNS) notation has appeared in 1605 in some unpublished The simplest system in MBNS category is the manuscripts of Thomas Harriot [5]. Digit set for the double-base numbering system (DBNS). This = {0,1} binary system is . numbering system was first proposed by Dimitrov et al. [2] for computing the scalar multiplication in 푆 2.1.1.2. Signed binary (SB) number ECC. Numbers in DBNS are represented as In Signed Binary representation, which is 2 3 where {0, ±1}, and , . sometimes known as Ternary Numbering System 푎푖 푏푖 + { } 푖 푖 푖 푖 푖 [14], the digit set is = 0, ±1 . The redundancy in ∑ If푐 = × 3 , 푐then∈ this representation푎 푏 ∈ can푍 be the numbering system is the result of using 3 transformed to 푏푖 2 . This shows DBNS 푖 푖 푆 푑 푐 푎푖 푖 푖 30 ∑ 푑

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 representation is a radix-2 numbering system, with ( … , , ) = = an enlarged set of integers. Other MBNS [6, 7, 26] ( … , , ) 푛 1 0 use radix-2 as one of the main bases, and similar to 푑푖푔푖푡푠 푎 푎 푎 � ( … � ) +� 푛+ (1 0 )�+ DBNS, it can be shown that they are all a radix-2 푟푎푑푖푥푒푠 푏 푏 푏 (3) numbering system with an enlarger digit set. Multi- 푎2.2.푛 푏 푛Classical푏0 M⋯ultiplication푎1 푏1푏0 A푎lgorithm0푏0 base NAF (mbNAF)[7] is one of the latest Big-Integer multiplication algorithm is one of the numbering systems that falls under this category. fundamental algorithms for scientific computing, in which many mathematicians and computer 2.1.1.4. Window sliding method A number = ( … ) where scientists are continuously making improvements {0, … , 1} can be represented by on the subject [10, 11, 28]. As mentioned earlier, 퐴 푎푛 푎2푎1푎0 푏 푎푖 ∈ among the multiplication algorithms, Classical =푏 − … (2) multiplication algorithm is the most used. This is because of its efficiency in multiplying lower range where퐴 �=퐴푝 ,퐴 2퐴1=퐴0�푟 ( ) and numbers [12]. Classical multiplication algorithm is = 푤 푤−1 푗 . 푖 푗=0 푗+푖푤 also being used in combination with the other 푟 푏 퐴 ∑ 푎 푏 multiplication algorithms to gain overall 푝 The푛 푚표푑digit set푟 for Equation (2) numbering system improvement. Better space complexity is another is {0,1, … , 1}. In this way, we can represent advantage of the Classical multiplication algorithm, numbers with푤 fewer digits. The time complexity of resulted in the algorithm being used in memory algorithms푏 (such− as multiplication algorithm) constrained applications. utilizing this windowing method is related to the The efficiency of the Classical multiplication number of digits and the window size. In general, algorithm is related to the numbering system used. Window Sliding Method increases the arithmetic The complexity of the Classical multiplication efficiency in an algorithm. Most popular bases of algorithm (see Algorithm 1 [5]) is ( ), where n this group are in the form of = 2 . is the size of the numbers being 2multiplied. 푤 푂 푛 Window Sliding Method can푟 be combined with Therefore, the number representation that has fewer SB representation. wNAF [22, 23], wMOF [4], digits is theoretically should run faster than the wmbNAF [7] are the windowing method of NAF, number representation that has more digits in its MOF and mbNAF, respectively. Mishra and et al. representation. In addition, the density of nonzero [27] presented in 2007 a new variant for the digits in the numbers influences the number of window version of DBNS. The windowing method addition that has to be carried out in the Classical improves the efficiency of the original algorithms multiplication algorithm. Equation (4) describes the by having pre-calculated calculations saved in a Classical multiplication equation in radix-r, in lookup table (LUT) and uses pre-calculated values which the Algorithm 1 is based on. in computations. However, the size of the window × = ( ). depends on application and is limited to the (4) 푛 푚 푖+푗 available memory. For example if we want to store 푖 푗 퐴 퐵 ∑푖=0 ∑푗=0 푎 푏 푟 a multiplication LUT for w = 16 bits, we need Algorithm 1: Classical Multiplication CM (A,B) 2 × 2 × (2 × 16) = 128 Gbyte of memory, Input: A = (a … a ) B = (b … b ) which16 is16 not reasonable in most applications, even n 0 r Output: C = (c … , c c ) with today’s technology. m 0 r 1. carry = 0; temp = 0 2.1.2. Mixed-base numbering system m+n 1 0 r 2. for ( i = 0; i m + n; i++ ) Fixed-base numbering system was first 3. c = 0 generalized to a mixed-base numbering system by 4. for ( i = 0; i ≤ n; i++ ) Georg Cantor in 1869 [5]. Prime number system i 5. for ( j = 0; j m; j++ ) and number system [5] are examples of ≤ 6. temp = c + a × b + carry mixed-base systems. Equation (3) shows the ≤ representation of integers in mixed-base numbering 7. carry = temp/r i+j � i j � system. There are two of numbers 8. c = temp carry × r ⌊ ⌋ ( … , , , ) and ( … , , , ) where ’s 9. return C i+j are the digits and ’s are the bases. The weight of − 푛 2 1 0 푛 2 1 0 푛 each푎 digit푎 푎is a푎 multiple푏 of the푏 weight푏 푏 of previous푎 In Algorithm 1, Steps 2 and 3 initialize the 푛 digit. 푏 output array to zero. Multiplicand and multiplier digits are scanned in a row manner in Steps 4 and 5.

31

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 “temp” is a temporary memory used to keep the • Based on System 1: summation of the partial product, with the last result being saved in the output array and carry. In = (111) × 2 + (1) × 2 + (1) × 2 + Steps 7 and 8, the value of the output and the new (1) × 2 +11(1111) × 29 7 2 2 2 carry is calculated from temp. 퐴 = 0 0 50 0000 0 2 2

3. BIG-DIGIT NUMBERING SYSTEM �푂3��푂�1��푂�1�푂�1�����푂�4 5 푛표푛−푧푒푟표 푑푖푔푖푡푠 (BDNS) • Based on System 2:

In this section we first introduce a new digit set = (1) × 2 + (1) × 2 + of radix-2, followed by a new numbering system (10101010113 ) × 2 +12(1) × 2 + 2 2 based on the new proposed digit set. 퐴 (1) × 2 + (1) × 32 2 2 2 = 000000001 0 3.1. Definitions 2 2

Definition 1: Let = { , … , , … } be a set, 1 1 9 1 1 1 �푇 �푇��������푇�푇��푇�푇� where is a of n consecutive binary 6 non−zero digits 1 2 푛 • Based on System 3: symbol “1”. We call푂� 푂 as푂 Big-One푂 (BO) with 푛 length 푂 and as the set of Big-Ones. 푂푛 A = (11) × 2 + (101010101) × 2 + (111) × 212 3 Example푛 : 푂� = , = 2 2 = 000000000 00 = { , , , … } = { , , , … } 2 ퟏ ퟐ ퟓ ퟐ . 푶 ퟏ 푶 ퟏퟏퟏퟏퟏ 퐚퐧퐝 2 9 3 �푂��������푇���푂� 푶� Definition푶ퟏ 푶ퟐ 푶2:ퟑ Let ퟏퟐ =ퟏퟏ{ퟐ ퟏퟏퟏ, , ퟐ … , , … }, 3 non−zero digits Therefore, to reduce the number of nonzero in where is a sequence of ( ) consecutive two 푇� 푇1 푇3 푇5 푇푛 Big-Digits, System 3 is preferred. Our experiment binary symbols “10” with 푛additional−1 “1” at the 푇푛 2 with 10,000 random bits (see Table 1) shows that rightmost of the sequence. We call as Big-Two System 3A yields the best result. (BT) with length n and as the set of Big-Twos. 푇푛 Table 1. Number of nonzero in different Big-Digit Example: = 1 , 푇� = 10101 and numbering systems, based on 10,000 random bits = { , , , … } = {1 , 101 , 10101 , … }. System 1 System 2 System 3A System 3B 1 2 5 2 푇 푇 2,492 3,789 2,186 2,346 푇� Definition푇1 푇3 푇 53: Big-Digits2 set2 ( ) is2 defined as = {0}. Each element of is a Big- As shown in Table 1 there are two versions of 퐷� Digit (BD). (Note: to prevent redundancy, we System 3. In converting a binary number to Big- � � � � remove퐷 푂 ∪ and푇 ∪ use in to represent “1퐷 ”) Digit representation, priority can be given to convert Big-Ones first followed by Big-Twos, or Based푇 on1 these Definitions푂1 퐷� (1-3), there 2are three new possible numbering systems of base 2. vice-versa. For example, given a number, 1110111 , System 3 can produce either 000 1. System 1: {0} as the digit set. (priority on Big-Ones) or 00 0 (priority on 2 3 3 2. System 2: {0} as the digit set. Big-Twos). Note that, the first representation푂 has푂 � 2 3 2 3. System 3: 푂 as∪ the digit set. less nonzero Big-Digits. Simila푂 r 푇finding푂 is observed 푇� ∪ from Table 1, where System 3A which supports Big- Given a positive퐷� integer A, if we represent A by One priority out-performed System 3B which using System 1, the number of in the number will supports Big-Two priority in terms of producing increase because the existence of pattern “010”. fewer digits. From the examples above, it is clear 1 Similarly, if we represent A by푂 using System 2, the that when converting from binary to Big-Digit, the number of in the number will increase because priority must be given in converting Big-Ones, the existence of pattern “11”. System 3 which is a followed by Big-Twos. With this information, we 1 hybrid of both푇 previous systems produces the best can define a unique Big-Digit representation that result. The following examples describe the supports the minimum nonzero Big-Digits. = 11101010101111 phenomenon. Let and Definition 4: A sequence of Big-Digits is called consists of 10 non-zero digits. 2 Big-Digits representation of A if and only if 퐴 = ( , … , , ) = 2 + + (5) 푛 where퐴 푎 푛 D푎 1. 푎 0 2 푎 푛 ⋯ 푎 0 푎푖 ∈ � 32

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 This numbering system is called Big-Digit Proof. Assume a ZOT-Binary representation of numbering system (BDNS). integer = ( , … , , … , , ) is not unique, and therefore let 3.2. ZOT-Binary: A canonic Big-Digits 퐴 푎푚 푎푝 푎1 푎0 2 numbering system = ( , … , , … , , ) and = , … , , … , , Definition 5: A sequence of Big-Digits 푚 푝 1 0 22 퐵 푏 푏 푏 푏 ( … , , ) is known as ZOT-Binary 퐶be the�푐 푚two different푐푝 푐 1ZOT푐0�-Binary representations of representation if and only if for every two 푘 1 0 2 integer A. Compare B and C by scanning from right “neighboring”푥 푥 푥 nonzero Big-Digits and , to left, Big-Digit by Big-Digit, to find the first Big- where length of is n: 푞 푝<푞 Digit which is not the same in B and C. Let the 푥 푥 position of the first non-similar Big-digit denoted 푝 1. +푥 + 2, when and are both by p. Subsequently, we can represent B and C as

either Big-Two or . 푝 푞 follow: 2. 푞 ≥ 푝 + 푛 + 1, for other푥 cases. 푥 1 Big-Digit = 0000 푂0000 is not a ZOT- 퐵푅 Binary representation푞 ≥ 푝 푛 since = ( = 0, = = × 2 = 퐵퐿 × 2 + × 2 (6) 1 2 5 5) and =퐴 (q푂 = 5) 푇and therefore푂 ( = 5) < 푚 푖 푚 푖 푝−1 푖 0 5 푖=0 푖 �푖�=��푝�푖���� �푖�=��0 �푖���� ( + + 1 = 6) which does not푥 satisfy푂 푝 Condition푛 퐵 ∑ 푏 ∑ 푏 ∑ 푏 5 2 2 of Def푥inition푇 5. 푞 = × 2 = 퐶퐿 × 2 + 퐶푅 × 2 (7) 푝 푛 푚 푖 푚 푖 푝−1 푖 푖=0 푖 �푖�=�푝�푖��� �푖�=��0 �푖���� Big-Digit = 0 00000 is not a ZOT- 퐶 As∑ mentioned푐 above,∑ 푐 {0∑, 푐1}, = . Binary representation since = ( = 6, = Therefore from (6) and (7) we can conclude that 1 1 3 푖 푖 1) and = 퐵 ( 푂= 8푂) and therefore푇 ( = 8) < ∀푖 ∈ 푝 − 푏 푐 6 1 = and = ( ) = ( ) = . ( + + 2 = 9) which does not푥 satisfy푂 푝 Condition푛 푥8 푂1 푞 푞 1 of Definition 5. 퐵Therefore푅 퐶푅 퐵퐿 퐵 − 퐵푅 퐶 − 퐶퐿 퐶푅 푝 푛 Definition 5 introduces the ZOT-Binary × 2 = × 2 where . (8) representation. The representation is named ZOT- 푚 푖 푚 푖 푖=In푝 Table푖 2, we푖 =listed푝 푖 all valid cases푝 of 푝and Binary to highlight the base, which is base two, and ∑ 푏 ∑ 푐 푐 ≠ 푏 (symmetrical cases have been ignored) and we the digits used in the representation, which are 푐푝 푏푝 Zero, Big-One and Big-Two. showed that for each case, there is a contradiction. Therefore, by contradiction, the ZOT-Binary Theorem 1. Every non-negative integer A has a represents non-negative integers uniquely. unique representation in ZOT-Binary. Table 2. Summary Of Contradictions For Two Different ZOT-Binary Representations Conditions Contradictions = 0 o푝 or푝 푏 푐 = 1 푝 퐿 푚 푚 푎 = 0 푖푛 퐵 푂 푇 푝 퐿 푎 = 1 푖푛 퐶 푝+푚 퐿 푚 푛 푎 = 1 푖푛 퐵 푂 푂 = 1 푝+푚 퐿 푎 = 0 푖푛 퐶 = 1 푝+3 퐿 푎 = 1 푖푛 퐵 푧 > 2 푝+3 퐿 푎 = 0 푖푛 퐶 푚 푝+2 퐿 푚 푛 푎 = 1 푖푛 퐵 푂 푇 2푧 푝+2 퐿 푎 = 0 푖푛 퐶 푝+1 퐿 푎 = 1 푖푛 퐵 푚 ≥ = + 1 푝+1 퐿 푎 = 0 푖푛 퐶 푝+푚+2 퐿 푎 = 0 푖푛 퐵 푧 > 푚 + 1 푝+푚+2 퐿 푚 푛 푎 = 1 푖푛 퐶 푇 푇 푝+푚+1 퐿 - z denotes the number of zeros on the left of Big-Digits in the푎 first column. 푖푛 퐵 푧 푚 푝+푚+1 퐿 - p, q, m and n are positive integers and m

33

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 3.3. ZOT-Binary Conversion Algorithm first zero. However, if the type of is BT then we = ( + count the number of adjacent ‘01’. The length of Based on Definition 5, suppose 푖 ), which indicates that m is the amount of zeros BT is double of this number minus푎 one. For between xp and xq in the binary representation.푚 푞 − 푝 consistency, we replace all occurrence of with 푛 its equivalent . Therefore we can conclude that two nonzero 1 neighboring Big-Digits in binary representation 푇 Step 5: Completing푂1 the conversion: Repeating satisfy the conditions of ZOT-Binary representation Steps 2-4 until the last bit. if the number of zeros between them is at least two, in which either one or both of them are Big- We can also represent a ZOT-Binary number in a Twos or . The ZOT-Binary conversion algorithm mixed-base number representation. Such (see Algorithm 2) described below, is using this representation is very useful for some calculations 1 property 푂to convert a binary number to ZOT-Binary such as multiplication, since we can have a more representation. compact representation of ZOT-Binary by removing all the zeros. The following describes the Let = ( … , , , ) be a binary number conversion of ZOT-Binary to its mixed-base form. and let the ZOT-Binary representation of A be 푛 2 1 0 2 ( … ,퐴 , ,푎 ) , 푎where푎 푎 = ( , ) represents the i-th Big-Digit in A. denotes the type of and A = (101010001110001111binary ) 푛 2 1 0 2 푖 푖푡 푖푙 푐 denotes푐 푐 the푐 length of 푐. Following푐 푐 are the steps 푖푡 푖 �����������������2 to convert a binary 푐number to its ZOT-Binary푐 = (T 00000푍푂푇O−푏푖푛푎푟푦000000O ) 푖푙 푖 representation푐 . 푐 ��5������3��������4�2 mixed−(Tbased, O 푍푂푇, O −)푏푖푛푎푟푦 Algorithm 2: ZOT-Binary Conversion Algorithm = (2 , 2 , 2 ) (right-to-left) ���5��3���4� Input: A = (a … , a , a ) is a binary number � 6 7 0 � Output:C = (c … , c , c ) where , c = (c , c ) Algorithm 3, a modified version of Algorithm2, n 1 0 2 is the ZOT-Binary representation of A describes the conversion process of converting a n 1 0 2 i it il 1. a = 0; binary number to a mixed-base ZOT-Binary 2. (i = 0 to n + 1; i + +) representation. These changes are mainly related to n+1 3. a = 1 the relative position calculation of two neighboring 4. 퐟퐨퐫 c = (a + 1); P = i; nonzero BD. In this algorithm, indicates the i 5. 퐢퐟 (c 퐭퐡퐞퐧= 2 ) relative position of and . it i+1 푘 (a = 1) 푃 6. 푘 푘−1 퐢퐟 Pt 퐭퐡퐞퐧 푐 푐 7. i + +; c + +; c = 0; Algorithm 3: Mixed-Base ZOT-Binary 퐰퐡퐢퐥퐞 i 8. Conversion Algorithm (right-to-left) ( Pl ) it 9. a a = 01 Input: A = (a … , a , a ) 10. 퐞퐥퐬퐞 I+= 2; c += 2; i+1 i (nc … ,1c ,0c 2) 퐰퐡퐢퐥퐞 c = 0; c( ) = 0; Pl Output: C= where c (2 … , 2 , , 2 ) i--it; --; i−1 t k 1 0 11. (c = 1) then � pk p1 p0 � Pl c = (c , c ) and p is position of c 12. c = 2; Pl 1. a = 0; k=0; iold=0; 13. 퐢퐟return C i it il i i Pt 2. (i = 0 to n + 1; i + +) n+1 3. a = 1 Step 1: Initializing: Set all to zero. 4. 퐟퐨퐫 C = (a + 1); i 푖푡 퐢퐟 p 퐭퐡퐞퐧= i iold; iold = i; Step 2: Identifying the position푐 of nonzero in kt i+1 5. (c = 2 ) then BD: Scan the binary number from right to left to k 6. (a− = 1) identify the first nonzero bit . This indicates the kt beginning of a new nonzero in BD. 7. 퐢퐟 i + +; c + +; i 푎푖 8. 퐰퐡퐢퐥퐞 Step 3: Identifying the type of the BD: The Big- kl 9. (a a = 01) Digit, , can identify the type for . If = 0 10. 퐞퐥퐬퐞 i+= 2; c += 2; then the type is BT ( = 1), otherwise the type is i+1 i 푖+1 푖 푖+1 11. 퐰퐡퐢퐥퐞i--; c --; BO ( 푎= 2). 푎 푎 kl 푖푡 12. (c = 1) then 푐 kl Step 4:푖푡 Identifying the length of the BD: If the 13. c = 2; 푐 kl type of is BO then we count all of 1’s before the 14. return C 퐢퐟 kt 푖 푎 34

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 The reverse conversion, converting ZOT-Binary Tables 3, 4 and 5 show the corresponding representation to binary is relatively simple. The multiplication tables, which we call them as Big- conversion can be done by applying these Digits multiplication LUT (BD-MLUT). replacements:

Table 3. Big-One-Big-One MLUT (BOBO-MLUT)

× 1 11 111 ... 0푛…−10 1 …푛 1 and 0푛…−10 101 …푛 101 (9) 1 1 11 111 ... �� � 푂푛 → ��� ��� 푇푛 → ������� 11 11 1001 10101 ... Therefore the procedure for converting a mixed- 111 111 10101 110001 … base ZOT-Binary representation A to its binary … … … … … equivalent can be described as follows: Table 4. Big-Two-Big-Two MLUT (BTBT-MLUT)

(a … , a , a ) × 1 101 ... A = (2 … , 2 , , 2 ) 101 101 11001 ... k 1 0 � pk p1 p0 � 10101 10101 1101001 ... = a … a 0 …pi 0 a … a 0 p…0 0 (10) 1010101 1010101 1101100001 … … … … … k i i−1 0 � ��� ����

where all in Equation (10) are replaced with Table 5. Big-One-Big-Two MLUT (BOBT-MLUT) their equivalent binary values as shown in Equation 푖 (9). For example:푎 × 1 11 ... 101 101 1001 ... (O , T , O ) 10101 10101 111111 ... A = (2 , 2 , , 2 ) 1010101 1010101 11111111 … 3 3 5 … … … … � 5 7 4 �

O 00000 T 0000000 O 0000 = 5 7 4 In general, rows and columns in Tables 3-5 are 3 3 5 unlimited and therefore tables size do not limit to a � ����� ������� ���� = (1110010100111110000) . certain value. One advantage of BD-MLUT is that it grows relatively slower compared to decimal or 2 3.4. Multiplication On BDNS binary multiplication time-tables, which suggest This subsection explains the process of that storing BD-MLUT requires notably less performing multiplication in BDNS. Classical memory comparing to storing decimal or binary multiplication algorithm that runs on ZOT-Binary is multiplication tables. Nevertheless storing big size also described in this subsection. tables will put a constraint on a computer memory. 3.4.1. Big-Digits multiplication To solve this problem, many implementation such In many multi-digits multiplication as in [30, 31] divide the numbers into smaller parts implementations, multiplication time tables are so that smaller LUTs are used. used. These tables are a pre-computed lookup-table For Big-Digits, we had analyzed 10,000 random (LUT) that saves the information on digit by digit bits representing random integers and found that the multiplications. Window-based numbering systems following five Big-Digits, 1, 11, 111, 1111 and 101 as describe earlier uses LUT in its calculations. LUT occurs 90.3% of the time (see Figure. 1). is also being used to improve calculation speed as documented in [29-31]. In the same way, we This finding has a big implication in determining propose three multiplications LUT-based on Big- the size of BD-MLUT that we need to use Digits, they are: Big-One-Big-One multiplication effectively for our multiplication algorithm. A LUT (BOBO-MLUT), Big-Two-Big-Two small size of BD-MLUT of 5 rows by 5 columns is multiplication LUT (BTBT-MLUT), and Big-One- enough to capture almost 90.3% of random Big- Big-Two multiplication LUT (BOBT-MLUT). Digits. For the rest of the 9.7% cases, we need to run the following conversion which will break the Big-Digits into the identified five Big-Digits mentioned above.

35

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195

35.0%

30.0%

25.0%

20.0%

15.0% Big-Two

10.0% Big-One

5.0%

0.0% 1 2 3 4 5 6 7 8 9 10 Big-Two 0.0% 0.0% 7.4% 0.0% 2.2% 0.0% 0.4% 0.0% 0.1% 0.0% Big-One 32.0% 29.2% 14.2% 7.5% 3.8% 1.5% 1.0% 0.3% 0.2% 0.2%

Figure 1: Nonzero Big-Digits distribution in ZOT-Binary representation based on 10,000 random bits

In general, suppose the length of a Big-Digit is n The memory requirement to store the MLUT for and BD-MLUT support only Big-Digits less than ZOT-CM is only 25 byte as shown below: m, then the following conversions can be applied.

Let = and = × , then Size of = 5 × 5 × 8 = 25 byte.

푝 푛 푚표푑 푚 푛 푘 푚 − 푝 푀퐿푈푇 � ⏟ ⏟ � 0 … 0 = 0푝…−10 0 … 0 … 0 … 0 . rows columns 푛−1 푚−1 푚−1 Table 6 shows another perspective of the Big- Or�� l�et 푂 푛 =�� � 푂푝 (��+�1푂)푚 and ��=� 푂×푚 ( + Digits distribution in range of 128 bits to 32 kbits �������푘 ������ 1) , then random integer. It indicates that ZOT-Binary 푝 푛 푚표푑 푚 푛 푘 푚 representation reduce the percentage of nonzero − 푝 symbols to 21.86%, while the average of Hamming weight for MOF and NAF is 50% [4] and 33% [21] 0푛…−10 = 0푝…−10 0 …푚 0 … 0 …푚 0 . respectively. 푛 푝 푚 푚 �� � 푇 ��� 푇 �����푇�����������푇� Table 6. Distribution of nonzero푘 Big-Digits in ZOT-Binary representation in range of 128 bits to 32 kbits 128 256 512 1 2 4 8 16 32 Length Average bits bits bits kbits kbits kbits kbits kbits kbits

( ) % 21.1 22.7 21.9 21.2 21.7 22.0 21.6 21.8 22.0 21.8 푛표푛푧푒푟표 퐵퐷 퐿푒푛푔푡ℎ 3.4.2. mb-CM: A modified mixed-base (11) and (12), respectively. Classical multiplication algorithm = ( × … × ) ( … , , , ) 푛 푝푖 푝1 푝0 = 푖=0 (푖 ) (11) Let = and 퐴 ∑ 푎 푟푖 푟 푟 ( … , , , ) ∑푗=0 푝푗 푛 2 1 0 푛 푖=0 푖 (푝푎푛 … ,푎푝2 ,푎푝1,푎 푝)0 ∑ 푎 푟 퐴 = � � = ( × … × ) (푟 … ,푟 ,푟 ,푟 ) 푚 2 1 0 푚 푞푘 푞1 푞0 = 푘=0 푘( ) (12) 푞푏푚 푏푞2 푏푞1푏 푞0 퐵 ∑ 푏 푟 푘 푟 푟 be the two퐵 mixed� -base integer multiplicands� such 푚 ∑푙=0 푞푙 푟 푟 푟 푟 푘=0 푘 that , , , and are integers. Integer A and B Multiplying∑ 푏 푟 A and B, we have: can be written as series, as shown by Equations 푝푖 푞푖 푚 푛 푟

36

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 compared to the normal Classical algorithm. × = 푛 × 푖 ∑푗=0 푝푗 3.4.3. ZOT-CM: Classical multiplication on 퐴 퐵 �� 푎푖 �푟 �� ZOT-Binary representation 푖=0 푚 ( ) 푘 By substituting r = 2 in Algorithm 4, we can ∑푙=0 푞푙 Then �� 푏푘 푟 � modify Algorithm 4 to Algorithm 5 that supports 푘=0 × = ( ( )) × ( ( )) ZOT-Binary numbers. We call this algorithm as 푛 푃푖 푚 푄푘 ZOT-CM. Let the sequence of A and B be the two 퐴Where퐵 =∑푖=0 푎푖 푟 and ∑=푘=0 푏푘 푟. ZOT-Binary numbers.

푖 푘 Then 푃푖 ∑푗=0 푝푗 푄푘 ∑푙=0 푞푙 Algorithm 5: Classical Multiplication for ZOT- × = ( ) × ( ) Binary Numbers ZOT-CM(A , B) 푛 푚 푃푖 푄푘 ( ) (a … , a , a , a ) 퐴 퐵 = ∑푖=0 ∑푘=0 푎푖 푟 푏푘 푟 (13) Input: A = is a (2 … , 2 , 2 , , 2 ) 푛 푚 푃푖+푄푘 n 2 1 0 푖=0 푘=0 푖 푘 ZOT-Binary numberpn p2 p1 p0 Series in∑ Equation∑ 푎 (1푏3)푟 has a similar structure to � � (b … , b , b , b ) the series in Equation (4). Therefore, Algorithm 1 B = is a (2 … , 2 , 2 , 2 ) can be generalized to Algorithm 4 to support the m 2 1 0 mixed-base Classical multiplication and result is ZOT-Binary number� qm q2 q1 q0 � saved in radix-r. Output: C = c … , c , c , c

1. carry = 0 pn+qm 2 1 0 � �2 2. for( i = 0; i n; i++) Algorithm 4: Mixed-Base Classical 3. I+= p ; Multiplication mbCM(A , B ) ( ) ( ) 4. for ( j =≤0; j m; j++) i (a … , a ,pai , a )qi Input: A = r r is a 5. J+= q ; (r … , r , r , r ) 6. temp = (≤c … c ) + n 2 1 0 i ( ) mixed-base numberpn in termsp2 pof1 (rp0 ) � � a × b + carry ; (b … , b , b , b )pi I+J+q i+1 I+J B = is a ( ) (r … , r , r , r ) 7. carryi =j temp/2 m 2 1 0 � �2 mixed-base numberqm in termsq2 qof1 (rq0 ) 8. c … c q =i+1temp � � ( ⌊ ) ⌋ qi ( ) Output: C = c … , c , c , c carryI+J+q×i+21 I;+ J � q i+1 � − n m 9. (c … c ) = carry ; carry = 0 �∑i=0 pi+∑j=0 qj� 2 1 0 1. � �r 10. return C I+J+qm+pi I+J+qm 2. for( i = 0; i n; i++) 3. I+= p ; 4. for ( j =≤0; j m; j++) 4. EXPERIMENTAL RESULTS i 5. J+= q ; ≤ In Section 3.4, it has been shown that the average 6. temp = (c ( ) … c ) + i of nonzero Big-Digit for relatively large sample of a × b + carryi+; 1 I+J+q I+J random numbers is about 24%. Since the 7. carry = temp/r ( ) � i j�r complexity of the Classical multiplication is ( ), 8. c … c q i=+1temp ( ⌊ ) ⌋ then theoretically, the execution time of ZOT-CM2 carry × r ( ); 푂 푛 � I+J+q i+1 I+J� − compare to the Classical multiplication algorithm (c … c q i+)1 = carry 9. ; must be: 10. return m C i m I+J+q +p I+J+q . × . = 0.058.

Partial multiplication of ZOT−CM 0 24n 0 24n 2 There are two main differences in Algorithm 4 Partial multiplication of CM n ≅ over the normal Classical multiplication algorithm. Table 7 shows the execution time of the First, Algorithm 4 ignores zeros between every two Classical, Karatsuba and ZOT-CM multiplication Big-Digits (Steps 3 and 5) in its calculation. algorithms against different bit length numbers Second, digits in this algorithm are processed in a which are randomly generated. Each value in Table group (Steps 6, 7 and 8). Both modifications will 8 is based on an average of 20 actual readings and additionally speed-up the multiplication calculation the conversion overhead had already been included

37

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 in the readings. Experiment was conducted on AMD Phenom (TM), 9950, Quad core processor, 2.6 GHz, 3.25GB RAM, with Windows XP (Service Pack 2) Professional and Dev-C++ version 4.9.9.2 compiler.

Table 7. Execution Time (Msec) Of Different Multiplication Algorithms Length 128 256 512 1 2 4 8 16 32 Algorithm bits bits bits kbits kbits kbits kbits kbits kbits Classical 0.1140 0.451 1.793 7.163 28.66 114.70 458.8 1,916.7 7,703 Karatsuba 0.1726 0.522 1.582 4.753 14.29 43.00 129.0 388.2 1,165.6 ZOT-CM 0.0087 0.030 0.111 0.427 1.68 6.65 26.6 108.4 434.92

Table 8. Execution Time Ratio Of ZOT-CM Multiplication Algorithm Against Classical And Karatsuba Multiplication Algorithms Length 128 256 512 1 2 4 8 16 32 Ratio bits bits bits kbits kbits kbits kbits kbits kbits ZOT-CM / CM 8% 7% 6% 6% 6% 6% 6% 6% 6% ZOT-CM / KM 5% 6% 7% 9% 12% 15% 21% 28% 37%

Tables 7 and 8 show that ZOT-CM multiplication (ZOT-Binary) were created. BDNS and ZOT-Binary algorithm performs better than the Classical and representation was extracted from the binary Karatsuba multiplication algorithms, for representation and posses some interesting multiplying integers in the range of 128 bits – 32 properties, such as lower percentage of nonzero kbits. The execution time of ZOT-CM symbols. In this paper we are focusing on Big- multiplication algorithm is 8% of the Classical Integer multiplication on ZOT-Binary. The multiplication algorithm for 128 bits integers, and modified Classical multiplication algorithm, ZOT- this ratio decreases to 6% for 32,000 bits numbers. CM, increases the efficiency of the multiplication For multiplying numbers that are bigger than algorithm in such way that ZOT-CM not only can 32,000 bits, the ratio should be 6% or lower. replace Classical multiplication algorithm but also can replace Karatsuba multiplication algorithm ZOT-MC multiplication algorithm is also faster when multiplying numbers in a certain range. It is than the Karatsuba algorithm for multiplying believe that many other calculations that depend on numbers in the range of 128 – 32,000 bits. For 128 binary systems can benefit from the ZOT-Binary bits integers, the execution time of ZOT-CM representation. multiplication algorithm is about 5% of the Karatsuba multiplication algorithms execution 6. ACKNOWLEDGMENT time, and the ratio gradually increases to 37% for 32,000 bits integers. The reason for the increment We are pleased to make an acknowledgement to the in the ratio is because Karatsuba algorithm posses a Universiti Sains Malaysia, for their support on this better algorithm complexity than the ZOT-CM research (Grant number: 1001/PKOMP/817059). algorithm. However, from the readings found in REFERENCES Tables 7 and 8, it is expected that Karatsuba multiplication algorithm will out-perform ZOT-CM [1] A. D. Booth, "A signed binary multiplication multiplication algorithm only when multiplying technique," Quarterly J. Mechanical and numbers that are bigger than 442.6 kbits long. Applied Math, vol. 4, pp. 236-240, 1951. 5. CONCLUSION AND FUTURE WORK [2] V. Dimitrov, L. Imber, and P. K. Mishra, "Efficient and secure elliptic curve point Having new perspective to existing numbering multiplication using double-base chains," in systems might reveal some hidden advantages. Advances in Cryptology, ASIACRYPT’05, ser. Based on this believe a new positional numbering system (BDNS) and its canonic numbering system

38

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 Lecture Notes in Computer Science, vol. [16] S. Vassiliadis, E. M. Schwartz, and D. J. 3788, pp. 59-78, 2005. Hanrahan, "A general proof for overlapped [3] G. W. Reitwiesner, "Binary arithmetic," multiple-bit scanning multiplications," IEEE Advances in Computers vol. 1, 1960. Trans. Compurers, vol. 38, pp. 172-183, [4] K. Okeya, K. Schmidt-Samoa, C. Spahn, and 1989. T. Takagi, "Signed binary representations [17] P. E. Madrid, B. Millar, and E. E. S. Jr., revisited," in Advances in Cryptology - Crypto "Modified Booth Algorithm for High Radix 2004, Proceedings. vol. 3152, M. Franklin, Fixed-Point Multiplication," IEEE Ed. Berlin: Springer-Verlag Berlin, 2004, pp. Transactions on Very Large Scale Integration 123-139. (VLSI) Systems, Man and Cybernetics, IEEE [5] E. Knuth, The Art of Computer Programming Transactions on, vol. 1, pp. 164--167, June vol. 2: Addison-Wesley, 1997. 1993. [6] V. Dimitrov, L. Imber, and P. K. Mishra, [18] J. Penhollow, "A study of arithmetic recoding "The double-base number system and its with applications to multiplication and application to elliptic curve cryptography," division," Dep. of Computer Sci., UNv. of Mathematics of Computation, vol. 77, pp. Illinois, Urbana, Rep. 128, Sept. 1962. 1075-1104, 2008. [19] B. Moller, "Improved Techniques for Fast [7] P. Longa and A. Miri, "New Multibase Non- Exponentiation," In: ICISC 2002,LNCS, vol. Adjacent Form Scalar Multiplication and its 2587, pp. 298-312, 2003. Application to Elliptic Curve Cryptosystems [20] D. M. Gordon, "A Survey of Fast (Extended Version)," in Cryptology ePrint Exponentiation Methods," J. Algorithms, vol. Archive, Report 2008/052, 2008. 27, pp. 129-146, 1998. [8] A. Karatsuba and Y. Ofman, "Multiplication [21] C. Heuberger and H. Prodinger, "THE of Multidigit Numbers on Automata," Soviet HAMMING WEIGHT OF THE NON- Physics Doklady (English translation), vol. 7, ADJACENT-FORM UNDER VARIOUS pp. 595-596, 1963. INPUT STATISTICS," Periodica [9] A. Cook, "On the Minimum Computation Mathematica Hungarica, vol. 55, pp. 81–96, Time of Functions," Harvard: Harvard 2007. University, May 1966. [22] J. A. Solinas, "Efficient Arithmetic on Koblitz [10] A. L. Toom, "The Complexity of a Scheme of Curves," Designs, Codes and Cryptography, Functional Elements Realizing the vol. 19, pp. 195-249, 2000. Multiplication of Integers. ," Soviet [23] I. F. Blake, G. Seroussi, and N. P. Smart, Mathematics vol. 3, pp. 714-716, 1963. Elliptic Curves in Cryptography vol. 265. [11] A. Schonhage and V. Strassen, "Schnelle Cambridge: Cambridge University Press, Multiplikation großer Zahlen," Computing in 1999. Science & Engineering, vol. 7 pp. 139-144, [24] N. Zhang, Z. Chen, and G. Xiao, "Efficient 1971. elliptic curve scalar multiplication algorithms [12] F. Xianjin and L. Longshu, "On Karatsuba resistant to power analysis," Information Multiplication Algorithm," in Data, Privacy, Sciences, pp. 2119-2129, 2007. and E-Commerce, 2007. ISDPE 2007. The [25] G. Frieder and C. Luk, " Algorithms for First International Symposium on, 2007, pp. Binary Coded Balanced and Ordinary Ternary 274-276. Operations," IEEE Transactions on [13] G. W. Leibniz, "Memoires de 1," Academie Computers, vol. 24 pp. 212-215, Feb. 1975. Royale des Sciences, pp. 110-1161, Paris [26] S. Maitra and A. Sinha, "A single digit triple 1703. base number system - a new concept for [14] R. Hashemian, "A new number system for implementing high performance multiplier faster multiplication," in Circuits and unit for DSP applications," in Information, Systems, 1996., IEEE 39th Midwest Communications & Signal Processing, 2007 symposium on, 1996, pp. 681-684 vol.2. 6th International Conference on, 2007, pp. 1- [15] H. Sam and A. Gupta, " A generalized 5. multibit recoding of two’s complement binary [27] P. K. Mishra and V. Dimitrov, "Window- numbers and its proof with applications in Based Elliptic Curve Scalar Multiplication multiplier implementations," IEEE Trans. using Double Base Number Representation," Computers, vol. 39, pp. 1006-1015, 1990. in INDOCRYPT'07 Proceedings of the

39

Journal of Theoretical and Applied Information Technology 10th February 2013. Vol. 48 No.1 © 2005 - 2013 JATIT & LLS. All rights reserved.

ISSN: 1992-8645 www.jatit.org E-ISSN: 1817-3195 cryptology 8th international conference on Progress in cryptology 2007. [28] A. Karatsuba, "The Complexity of Computation," Proceedings of the Steklov Institute of Mathematics, vol. 211, 1995. [29] G. Harper, A. Menezes, and S. Vanstone, "Public-Key Cryptosystems with Very Small Key Lengths," Proc. Advances in Cryptology ÐEUROCRYPT '92, pp. 163-173, 1992. [30] M. A. Hasan, "Look-up table-based large finite field multiplication in memory constrained cryptosystems," IEEE Transactions on Computers, vol. 49, pp. 749- 758, Jul 2000. [31] A. Mahboob and N. Ikram, "Lookup table based multiplication technique for GF(2(m)) with cryptographic significance," IEE Proceedings-Communications, vol. 152, pp. 965-974, Dec 2005.

40