Processing math: 100%

Thursday, August 11, 2016

Dlogs and Factoring with polynomial number of arithmetic steps

❚ This post is related to a paper of mine, that will get published around the end of October this year in the Journal of Groups, Complexity and Cryptography (GCC). Some people may think, when they read the headline of this post, this must be a post about Shor's quantum factoring/dlog algorithm, because it is well known that dlogs and factoring can not be solved in polynomial number of arithmetic steps otherwise.

 But this is not true.

This sounds very unintuitive, because in cryptography we nearly always work with finite fields, where the bit length is restricted by the size of the modulus and the complexity of an algorithm is hence often measured as the number of arithmetic steps.

But of course you can do this, if you increase the available space. It is not obvious how to do it, but Adi Shamir [1] already showed in 1979 how this could be done, it you allow integers in memory/registers that are of exponential size.

His idea is the following: If we denote with [n]2:=n(mod2), then observe, that you could write the factorial function recursively:
m!=m[n]2(m1[n]2(m1)m/2)(m/2!)2=m[n]2m1[n]2(m1)!m/2!m/2!(m/2!)2
Hence, the computational task to compute m! could be reduced to compute m/2!, thus, after repeating this log2m times you reach m=1:
18!=18!9!9!(9!)29!=98!4!4!(4!)24!=4!2!2!(2!)22!=2!1!1!(1!)21!=1

However, in order to make this algorithm work, you need an efficient way to compute the intermediate values (2mm)=(2m)!m!m! which you multiply with the known values (m!)2 that you get from the recursion.

Therefore, Shamir used that (1+10m)m=mi=0(mi)10im=j=0cj10j
and that binomial coefficient (mi) is entirely encoded in the base-10 coefficients cmi to cmi+m1. E.g. the binomial coefficients values of (6i) for 0i6 are 1,6,15,20,15,6,1 which can found in the coefficients of:
(1+106)6=1000006000015000020000015000006000001=[0000]1000006000015000020000015000006000001
Since (1+10m)m could be computed in a number of steps that in polynomial in logm, one could extract the binomial coefficient values out of the base-10 coefficient values using appropriate dividing and rounding methods. Finally, if we execute this procedure with mN and N is the number to factorize, we get a non-trivial factor via gcd(m!,N).


An algorithm for discrete logarithm


❚ It is a neat result and I though about this algorithm for quite a long time. I was searching for another (important) cryptographic problem that could be solved similarly. I asked a few people if they were aware of anything in this direction, but nobody knows another explicit example for one of the well known cryptographic problems. Finally, i came up with an idea for the discrete logarithm problem in finite fields Fq. I will give here a short overview of the idea:

The main tool of the algorithm, is to use the binary &-operator and write Fermat quotients in a base-p representation and make use of its cyclic properties. There are several related works, which classify complexity classes according to the necessary operations that are needed to solve problems in the class. The operations for this algorithm are {+,,×,÷,&}, from which it is known that they already cover the entire class PSPACE. Hence the existence of the algorithm is not surprising.

So how does it work?

Well, here i can only give you a slight explanation of the idea by means of a little example, which i also gave in the appendix of the paper:

Suppose you have the prime number q=37 and want to compute the discrete logarithm of 19 in the group generated by 5, i.e. you want to compute x from 5x19(mod37). It is easy to check, that if you know x1 from px119(mod37) as well as x2 from px25(mod37) for some integer p, then you could compute the solution x of 5x19. The following example shows the computation of x1. Spoiler Alert! - The solution is x1=7.

You start by picking the integer p=2log2q=32. Hence, we are going to compute the solution of 32x119. Lets compute the Fermat quotient Qq(p)=Q37(32). It is: 41418798401780779955631000733792140097803760059016275
Nothing to see here, but if you write it in base-32 you get:
Q37(32)=03235+273234+213233+193232+283231+173230+93229+163228+133227+263226+253225+303224+83223+203222+243221+63220+293219+123218+313217+43216+103215+123214+33213+143212+223211+153210+18329+5328+6327+1326+23325+11324+7323+25322+2321+19320
The coefficient 9, that i marked red, is the coefficient that is at position x1, starting from the highest monomial (here 3235) with exponent q2. The coefficient 31, that i marked bold is the largest among all coefficients, denoted as ¯k. We proved, that its value can be found in log2q steps using base-p digits sums. Here we have  ¯k=31. The largest coefficient has the property, that its position within Qq(p) can be determined in log2(q) steps, using again base-p digit sums combined with a binary search algorithm. However, since the largest coefficient will be at some unrelated position to x1, it seems not that useful on the first sight.

But, the Fermat quotient Qq(p) is a cyclic number. The means, that its coefficients are cyclically shifted when Qq(p) is multiplied with integer <p. E.g., Q11(8)=05642721358 and 3Q11(8)=2135056427. It can be easily seen, that the later is a cyclic shift of the former. The definition of cyclic numbers can be extended. We call them "restricted" cyclic numbers. The coefficients of those integers are cyclically shifted only whenever they are multiplied with some integer rGpFq. We use the cyclic shift to move the largest integer ¯k to the position of coefficient 9, by multiplication of Qq(p) with a certain factor. We proved that this factor can be found efficiently from ˆk and the target group element 19 only. In our example the factor turns out to be 10, hence:
10Q37(32)=83235+203234+243233+63232+293231+123230+313229+43228+103227+123226+33225+143224+223223+153222+183221+53220+63219+13218+233217+113216+73215+253214+23213+193212+03211+273210+21329+19328+28327+17326+9325+16324+13323+26322+25321+30320
The largest coefficient ¯k=31 is now at the former position of coefficient 9. The final step is, to compute the position of ¯k in the base-p coefficients of 10Qq(p), as already mentioned above. The result yields the solution x1=7.

Of course, i skipped many details but this is the overall idea.

 [1] Adi Shamir, Factoring Numbers in O(logn) arithmetic steps. Information Processing Letters 8 (1979) S. 28–31

No comments:

Post a Comment