Optimization of Multi-Scalar Multiplication Algorithm: Sin7Y Tech Review (21)

Written by sin7y | Published 2022/04/15
Tech Story Tags: sin7y | blockchain | algorithms | multi-scalar-multiplication | endomorphism | optimization | blockchain-technology | good-company

TLDRMulti-Scalar Multiplication (MSM) is the algorithm for calculating the sum of multiple scalar multiplications. Usually, G is a cyclic group defined on the elliptic curve of y^2=x^3+ax+b on the finite field of F_p. If the group operation is conducted by the plain algorithm of fast exponentiation, the number of group operations needed for everyĀ a_i.P_iĀ isĀ 1.5bnĀ times on average.via the TL;DR App

LetĀ GĀ be a cyclic group,Ā P_i āˆˆ GĀ is the element in the group,Ā a_i āˆˆ ZĀ is the scalar, and the Multi-Scalar Multiplication (MSM) is the algorithm for calculatingĀ āˆ‘_{i=1}^{n} a_{i} P_{i}Ā , the sum of multiple scalar multiplications. As the group operation is more complicated than the addition and multiplication of elements in the finite field, the MSM algorithm is employed to reduce the number of times of group operation as much as possible. Usually,Ā GĀ is a cyclic group defined on the elliptic curve ofĀ y^2=x^3+ax+bĀ on the finite field ofĀ F_p, with the orderĀ |G|Ā beingĀ b ā‰ˆ 256Ā bits, andĀ 0 ā‰¤ a_i< 2^b. If the group operation is conducted by the plain algorithm of fast exponentiation, the number of group operations needed for everyĀ a_i.P_iĀ isĀ 1.5bnĀ times on average, and for allĀ a_i.P_iĀ isĀ 1.5bĀ times in total. Next, we will introduce some optimization methods corresponding to largerĀ n.

Optimization Based on the Windowing Technique

We can split theĀ bĀ bit scalar intoĀ cĀ width windows: reduce the scalar toĀ 2^cĀ base system.

Here,Ā Q_j=āˆ‘_{i=1}^{n} a_{i j} P_{i}, so we reduce the original algorithm issue ofĀ b-bit MSM into a smallerĀ c-bit issue. We can put the same scalars fromĀ āˆ‘_{i=1}^{n} a_{i j} P_{i}Ā into a bucket and write them in another form:

For example, whenĀ c = 3, it is calculated as:

When calculatingĀ āˆ‘kS_k, set the partial sumĀ T_l=S_l+ā‹Æ+S_k, then

However, the operation results ofĀ T_lĀ can be obtained through the recurrence sequence T_l=T_l+1+S_l. It means that only one group operation is needed for the operation for eachĀ T_l. Under the MSM algorithm withĀ cc-bit scalar, allĀ S_kĀ requiresĀ nāˆ’2^c+1Ā times of group operation. All T_kĀ requiresĀ 2^cāˆ’1Ā times and the sum of theseĀ T_kĀ requiresĀ 2^cāˆ’2Ā times of group operation. Therefore, each window with the value ofĀ cĀ requires n+2^cāˆ’2 times of group operations. The operation ofĀ āˆ‘_{j=0}^{b / c-1} Q_{j} 2^{j c}Ā only requires the normal method of fast exponentiation by (b/cāˆ’1)(c+1)=b āˆ’ c + b/cāˆ’1Ā times of group operation.

In summary, we can conclude that the total number of group operations required by the method of the Windowing Technique of a width ofĀ cĀ is

SetĀ c = logn, then the number of group operations isĀ 2bn/logn. WhenĀ nā‰ˆ10^5Ā , the number of group operations reduces toĀ 1/12Ā of its original value.

Optimization Based on Group Endomorphism

For the cyclic groupĀ GĀ on the elliptic curveĀ y^2=x^3+ax+bĀ on the finite fieldĀ F_p, if the following group endomorphism ofĀ Ļ†Ā can be found: there existsĀ Ī±,Ī² āˆˆ F_p, satisfyingĀ Ļ†(x,y)=(Ī±x,Ī²y)Ā holds for all the points onĀ G, then it is easy to prove that such an endomorphism is a multiplication map, namely there is aĀ Ī»Ā makingĀ Ļ†(P)=Ī»PĀ hold for all the points ofĀ PĀ onĀ G, which means that whenever we know the coordinates of one point, we can change it to the coordinates of another point simply by multiplying a number inĀ F_pĀ to both the values of abscissa and ordinate. The algorithm can be further optimized based on this important property.

WhenĀ Ī» = āˆ’1,Ā Ī± = 1, Ī² = āˆ’1. The reverse value of one point can be obtained only by taking the opposite number from the ordinate. Based on this feature, in the plain fast exponentiation algorithm, the scalar can be written into the non-adjacent form (NAF), namelyĀ āˆ‘e_{i}.2^{i}, e_{i} āˆˆ {āˆ’1,0,1}Ā and any two adjacentĀ e_iĀ cannot be non-zero at the same time. Compared to theĀ b-bit scalars, the group operation number in the fast exponentiation algorithm can be reduced from the original average ofĀ 3/2ā‹…bĀ times toĀ 4/3ā‹…bĀ times. This technique can also be used to optimize the Windowing Technique. After writing a_i toĀ a_i=āˆ‘_{j=0}^{b / c-1} a_{i, j} 2^{j c}, 0 <= a_{i, j}<2^{c}

conduct the following operation:

The result ofĀ a_i=āˆ‘_{j=0}^{b / c-1} aā€™_{i, j}^2^{j c} and -2^{c-1} <= aā€™_{i, j}^ <= 2^{c-1} can be obtained. Since the complexity of addition and subtraction in group operation of an elliptic curve is the same, we can put these terms into a bucket according to the absolute value of scalars. Therefore, the number of groups can be reduced from the original 2c toĀ 2^cĀ , and the overall number of group operations required is reduced from (1) to:

If the parameters of the elliptic curve are special, for example, the BLS curve can be written asĀ y^2=x^3+b, andĀ p ā‰” 1( mod3 ), take third-order elementĀ Ī±Ā fromĀ F_p^x, then there is a correspondingĀ Ī»Ā that holdsĀ Ī»(x,y)=(Ī±x,y)

Algorithm 1: Signed Digits

In addition,Ā Ī»3 ā‰” 1(mod |G| ). Then the multiplication operation can be optimized as follows:

From [1], we can find a small enough scalarĀ |m1|, |m2|<āˆšGĀ to make the above equation true, which gives us a way to reduce the multiplication ofĀ bbĀ bits into the multiplication of twoĀ b/2Ā bits. Use it into the Windowing Technique, and the number of group operations is reduced to

In summary, both the above two optimization methods can reduce the number of group operations byĀ 5.5%Ā whenĀ n=10^5.

References

[1] Francesco Sica, Mathieu Ciet, and Jean-Jacques Quisquater. Analysis of the gallant-lambert-vanstone method based on eļ¬€icient endomorphisms: Elliptic and hyperelliptic curves. In International Workshop on Selected Areas in Cryptography, pages 21ā€“36. Springer, 2002.


Written by sin7y | Sin7Y is a tech team that explores layer 2, cross-chain, ZK, and privacy computing. #WHAT IS HAPPENING IN BLOCKCHAIN#
Published by HackerNoon on 2022/04/15