Clever Geek Handbook
📜 ⬆️ ⬇️

Gelfond - Shanks Algorithm

The Gelfond - Shanks algorithm ( English Baby-step giant-step ; also called the algorithm of large and small steps ) - in group theory, the deterministic discrete logarithm algorithm in the mulplicative group of the residue ring modulo a prime number. It was proposed by the Soviet mathematician Alexander Gelfond in 1962 and Daniel Shanks in 1972 [1] [2] [3] .

The method theoretically simplifies the solution of the discrete logarithm problem, on the computational complexity of which many public-key cryptosystems are built. Refers to meeting methods in the middle .

Content

Scope

The discrete logarithm problem is of great interest for building public key cryptosystems . Cryptographic algorithms such as RSA , DSA , Elgamal , Diffie-Hellman , ECDSA , GOST R 34.10-2001 , Rabin and others are based on the assumption of extremely high computational complexity for solving this problem. In them, the cryptanalyst can get the private key by taking the discrete logarithm of the public key (known to everyone), and using it to convert the ciphertext into the message text. However, the more difficult it is to find it (the more operations you need to do to find the discrete logarithm), the more stable is the cryptosystem. One way to increase the complexity of the discrete logarithm problem is to create a cryptosystem based on a group with a large order (where the logarithm will take place modulo a large prime). In the general case, such a problem is solved by exhaustive search , the same algorithm allows in some cases to simplify finding the exponent (reduce the number of steps) when calculating modulo a prime number, in the most favorable case, by the square root of the times [4] , but this reduction is still not enough to solve the problem on a computer in a reasonable time (the question of solving the discrete logarithm problem in polynomial time on a personal computer remains open so far) [5] .

Discrete Logarithm Problem

 
Daniel Shanks is a mathematician who proposed the Gelfond-Shanks algorithm in 1972.
 
Alexander Osipovich Gelfond - a mathematician who proposed the Gelfond - Shanks algorithm in 1962.

Let a cyclic group be givenG {\ displaystyle G}   with generatrixg {\ displaystyle g}   containingn {\ displaystyle n}   elements. Integerx {\ displaystyle x}   (in the range from0 {\ displaystyle 0}   beforen-one {\ displaystyle n-1}   ) is called the discrete logarithm of the elementh∈G {\ displaystyle h \ in G}   on the basis ofg {\ displaystyle g}   if the relation holds:

gx=h.{\ displaystyle g ^ {x} = h.}  

The discrete logarithm problem is givenh {\ displaystyle h}   ,g {\ displaystyle g}   to determinex {\ displaystyle x}   .

Formally, the discrete logarithm problem is posed as follows [6] :

{Input:g,h,n∈NOutput:x∈N:gx≡h(modn){\ displaystyle {\ begin {cases} {\ text {Input:}} \ quad & g, h, n \ in \ mathbb {N} \\ {\ text {Output:}} \ quad & x \ in \ mathbb {N }: \ g ^ {x} \ equiv h {\ pmod {n}} \\\ end {cases}}}  

provided thatx {\ displaystyle x}   may not exist as welln {\ displaystyle n}   can be either a prime or a compound.

Theory

The idea of ​​the algorithm is to choose the optimal ratio of time and memory , namely, in an advanced search for the exponent.

Let a cyclic group be givenG {\ displaystyle G}   of ordern {\ displaystyle n}   group generatorα {\ displaystyle \ alpha}   and some element of the groupβ {\ displaystyle \ beta}   . The problem comes down to finding an integerx {\ displaystyle x}   for which is executed

αx=β.{\ displaystyle \ alpha ^ {x} = \ beta \ ,.}  

Gelfond - Shanks Algorithm Based on Representationx {\ displaystyle x}   asx=i⋅m-j {\ displaystyle x = i \ cdot mj}   wherem=⌊n⌋+one {\ displaystyle m = \ left \ lfloor {\ sqrt {n}} \ right \ rfloor +1}   , and brute forceone≤i≤m {\ displaystyle 1 \ leq i \ leq m}   and0≤j<m {\ displaystyle 0 \ leq j <m}   . Restriction oni {\ displaystyle i}   andj {\ displaystyle j}   follows from the fact that the order of the group does not exceedm {\ displaystyle m}   , which means the indicated ranges are sufficient to obtain all possiblex {\ displaystyle x}   from a half-interval[0;m) {\ displaystyle \ left [0; m \ right)}   . Such a representation is equivalent to equality

αim=βαj.{\ displaystyle \ alpha ^ {im} = \ beta \ alpha ^ {j} \ ,.}  

(one)

The algorithm precomputesαim {\ displaystyle \ alpha ^ {im}}   for different valuesi {\ displaystyle i}   and saves them in a data structure that allows efficient search, and then iterates over all sorts of valuesj {\ displaystyle j}   and checks ifβαj {\ displaystyle \ beta \ alpha ^ {j}}   corresponds to some valuei {\ displaystyle i}   . Thus are the indicesi {\ displaystyle i}   andj {\ displaystyle j}   which satisfy relation (1) and allow us to calculate the valuex=i⋅m-j {\ displaystyle x = i \ cdot mj}   [7] .

Algorithm

Entrance : Cyclic groupG {\ displaystyle G}   of ordern {\ displaystyle n}   generatorα {\ displaystyle \ alpha}   and some elementβ {\ displaystyle \ beta}   .

Output : Numberx {\ displaystyle x}   satisfyingαx=β {\ displaystyle \ alpha ^ {x} = \ beta}   .

  1. m{\ displaystyle m}   ←⌊n⌋+one {\ displaystyle \ left \ lfloor {\ sqrt {n}} \ right \ rfloor +1}  
  2. Calculateγ {\ displaystyle \ gamma}   ←αm {\ displaystyle \ alpha ^ {m}}   .
  3. For anyonei {\ displaystyle i}   Where0 {\ displaystyle 0}   <i {\ displaystyle i}   <m {\ displaystyle m}   :
    1. Write to the table (i {\ displaystyle i}   ,γ {\ displaystyle \ gamma}   ) (see the section "Implementation")
    2. γ{\ displaystyle \ gamma}   ←γ {\ displaystyle \ gamma}   •αm {\ displaystyle \ alpha ^ {m}}  
  4. For anyonej {\ displaystyle j}   Where0 {\ displaystyle 0}   ≤j {\ displaystyle j}   <m {\ displaystyle m}   :
    1. Calculateα {\ displaystyle \ alpha}   .
    2. Check if containedβαj {\ displaystyle \ beta \ alpha ^ {j}}   in the table.
    3. If yes, returnim {\ displaystyle im}   -j {\ displaystyle j}   .
    4. If not, continue to run cycle [1] [2] [7] .

Algorithm Justification

It is necessary to prove that the same elements in the tables necessarily exist, that is, there are suchi {\ displaystyle i}   andj {\ displaystyle j}   , whatgmi=β⋅gj=gx+j {\ displaystyle g ^ {mi} = \ beta \ cdot g ^ {j} = g ^ {x + j}}   . This equality holds in the casemi=x+j(modn) {\ displaystyle mi = x + j {\ pmod {n}}}   , orx=mi-j(modn) {\ displaystyle x = mi-j {\ pmod {n}}}   . Atone≤i≤m {\ displaystyle 1 \ leq i \ leq m}   ,one≤j≤m {\ displaystyle 1 \ leq j \ leq m}   the inequality holds0≤mi-j≤m2-one {\ displaystyle 0 \ leq mi-j \ leq m ^ {2} -1}   . For different couples(ione,jone) {\ displaystyle (i_ {1}, j_ {1})}   and(i2,j2) {\ displaystyle (i_ {2}, j_ {2})}   we havemione-jone≠mi2-j2 {\ displaystyle mi_ {1} -j_ {1} \ neq mi_ {2} -j_ {2}}   , otherwise it would have turned outm(ione-i2)=(jone-j2) {\ displaystyle m (i_ {1} -i_ {2}) = (j_ {1} -j_ {2})}   that with the indicated choiceione,i2 {\ displaystyle i_ {1}, i_ {2}}   only possible ifione=i2 {\ displaystyle i_ {1} = i_ {2}}   , and thereforejone=j2 {\ displaystyle j_ {1} = j_ {2}}   . Thus expressionsmi-j {\ displaystyle mi-j}   accept all values ​​ranging from0 {\ displaystyle 0}   beforem2-one {\ displaystyle m ^ {2} -1}   which, due to the fact thatm2>n {\ displaystyle m ^ {2}> n}   , contains all possible valuesx {\ displaystyle x}   from0 {\ displaystyle 0}   beforen-one {\ displaystyle n-1}   . So for somei {\ displaystyle i}   andj {\ displaystyle j}   equality holdsx=mi-j(modn) {\ displaystyle x = mi-j {\ pmod {n}}}   [2] .

Algorithm Estimation

Let's say you need to solveh=ng {\ displaystyle h = ng}   whereh {\ displaystyle h}   andg {\ displaystyle g}   - positive integers less100 {\ displaystyle 100}   . One way is to iterate over sequentiallyn {\ displaystyle n}   fromone {\ displaystyle 1}   before100 {\ displaystyle 100}   comparing the valuen⋅g {\ displaystyle n \ cdot g}   withh {\ displaystyle h}   . In the worst case, we need100 {\ displaystyle 100}   steps (whenn=99 {\ displaystyle n = 99}   ) On average, it will take50 {\ displaystyle 50}   steps. In another case, we can imaginen {\ displaystyle n}   asn=tena-b {\ displaystyle n = 10a-b}   . Thus, the task is to finda {\ displaystyle a}   andb {\ displaystyle b}   . In this case, you can rewrite the task ash=(tena-b)g {\ displaystyle h = (10a-b) g}   orh+bg=tenag {\ displaystyle h + bg = 10ag}   . Now we can iterate over all possible valuesa {\ displaystyle a}   on the right side of the expression. In this case, these are all numbers fromone {\ displaystyle 1}   beforeten {\ displaystyle 10}   . These are the so-called big steps. It is known that one of the obtained values ​​fora {\ displaystyle a}   - desired. We can write all the values ​​of the right side of the expression in the table. Then we can calculate the possible values ​​for the left side for various valuesb {\ displaystyle b}   . These are all numbers from0 {\ displaystyle 0}   before9 {\ displaystyle 9}   of which one is the desired one, and together with the correct value of the right part gives the desired resultn {\ displaystyle n}   . Thus, the task is reduced to enumerating various values ​​of the left side and searching for them in the table. If the desired value in the table is found, then we foundb {\ displaystyle b}   , and therefore the correspondingn=tena+b {\ displaystyle n = 10a + b}   . This illustration demonstrates the speed of the algorithm. Average performed1.5n {\ displaystyle 1.5 {\ sqrt {n}}}   operations. Worst case required2n {\ displaystyle 2 {\ sqrt {n}}}   operations [3] .

Example

Below is an example of solving a discrete logarithm problem with a small group order. In practice, groups with a higher order are used in cryptosystems to increase cryptographic stability .

Let it be knownfivex≡3(mod23) {\ displaystyle 5 ^ {x} \ equiv 3 {\ pmod {23}}}   . First, create and fill in the table for the "big steps". Choosem=five {\ displaystyle m = 5}   ← (sixteen+one {\ displaystyle {\ sqrt {16}} + 1}   ) Theni {\ displaystyle i}   will pass fromone {\ displaystyle 1}   beforefive {\ displaystyle 5}   .

i{\ displaystyle i}  one23fourfive
fiveim=20i{\ displaystyle 5 ^ {im} = 20 ^ {i}}  209nineteen12ten

Find a suitable valuej {\ displaystyle j}   for3⋅fivejmod23 {\ displaystyle 3 \ cdot 5 ^ {j} \ {\ bmod {\}} 23}   so that the values ​​in both tables match

j{\ displaystyle j}  one23four
βαj=3{\ displaystyle \ beta \ alpha ^ {j} = 3}   ·fivej {\ displaystyle 5 ^ {j}}  156712

It can be seen that in the second table forj=four {\ displaystyle j = 4}   , this value is already in the first table. We findx=mi-j=five⋅four-four=sixteen {\ displaystyle x = mi-j = 5 \ cdot 4-4 = 16}   [2] .

Implementation

There is a way to improve the performance of the Gelfond-Shanks algorithm. It consists in using an effective table access scheme. The best way is to use a hash table . You should hash the second component, and then search for the hash in the table in the main loop byγ {\ displaystyle \ gamma}   . Since accessing and adding items to the hash table works in timeO(one) {\ displaystyle O (1)}   ( constant ), then asymptotically this does not slow down the algorithm.

The running time of the algorithm is estimated asO(n) {\ displaystyle O ({\ sqrt {n}})}   which is much better than work timeO(n) {\ displaystyle O (n)}   full enumeration of degree indicators [4] .

Features

  • The Gelfond – Shanks algorithm works for an arbitrary finite cyclic group [7] [3] .
  • No need to know group orderG {\ displaystyle G}   in advance. The algorithm also works ifn {\ displaystyle n}   Is the upper bound of the order of the group [7] .
  • Usually the Gelfond-Shanks algorithm is used for groups whose order is a prime . If the order is a composite number , then the use of the Polyg – Hellman algorithm [7] is recommended.
  • Gelfond - Shanks algorithm requiredO(n) {\ displaystyle O (n)}   memory. It’s possible to choose lessm {\ displaystyle m}   in the first step of the algorithm. This increases the run time of the program toO(n/m) {\ displaystyle O (n / m)}   . It is also possible to use the Pollard ρ-method for discrete logarithm , which works for the same time, but requires a small amount of memory [7] .

Notes

  1. ↑ 1 2 D. Shanks. The infrastructure of a real quadratic field and its applications. Proceedings of the Number Theory Conference. - University of Colorado, Boulder ,, 1972. - S. pp. 217-224. .
  2. ↑ 1 2 3 4 I.A. Pankratova. Number-Theoretical Methods in Cryptography: A Training Manual. - Tomsk: TSU, 2009 .-- S. 90-98. - 120 s. .
  3. ↑ 1 2 3 V.I. Nechaev. Elements of cryptography. Fundamentals of information security theory. - M .: Higher School, 1999. - S. 61-67. - 109 p. - ISBN 5-06-003644-8 . .
  4. ↑ 1 2 DC Terr. A modification of Shanks' baby-step giant-step algorithm . - Mathematics of Computation. - 2000. - T. 69. - S. 767–773. .
  5. ↑ Vasilenko O. N. Number-theoretic algorithms in cryptography . - Moscow: ICMMO, 2003 .-- S. 163-185. - 328 p. - ISBN 5-94057-103-4 . .
  6. ↑ Yan, Song Y. Primality testing and integer factorization in public-key cryptography . - 2. - Springer, 2009 .-- S. 257-260. - 374 p. - ISBN 978-0-387-77267-7 . .
  7. ↑ 1 2 3 4 5 6 Glukhov M. M, Kruglov I. A., Pichkur A. B., Cheremushkin A. V. Introduction to number-theoretic methods of cryptography. - 1st ed .. - St. Petersburg: Doe, 2010 .-- S. 279-298. - 400 p. with. - ISBN 978-5-8114-1116-0 . .

Literature

  • A.O. Gelfond, Yu.V. Linnik. Elementary methods in analytic number theory. - M .: Fizmatgiz, 1962 .-- 272 p.
Source - https://ru.wikipedia.org/w/index.php?title=Gelfond_ Algorithm_ — _Shenks&oldid = 101588845


More articles:

  • Anna (Dido's sister)
  • Wanderer (novel)
  • List of Oman diplomatic missions
  • Ul, Rezhan
  • Fc Receptor
  • Guanyo
  • Li & Fung
  • Zombie Apocalypse
  • Apache (film)
  • Periderm

All articles

Clever Geek | 2019