11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Then verify that c n 5= a 129n 5and c n 6= a 127n 6. Find similar relations forn 1 = (p − 1) div 2 n 3 = (p − 1) div 5,n 2 = (p − 1) div 3 n 4 = (p − 1) div 37.and use this information to find the discrete logarithm of c with respect to a.Solution.We set up the problem in SAGE in the following way.sage: p = 2^131+1883sage: fac = (p-1).factor(); fac2 * 3 * 5 * 37 * 634466267339108669 * 3865430919824322067sage: primes = [ f[0] for f in (p-1).factor() ]sage: (p1, p2, p3, p4, p5, p6) = primessage: expons = ( (p-1) // r for r in primes )sage: (n1, n2, n3, n4, n5, n6) = exponsIn this way, p 1 , p 2 , p 3 , p 4 , p 5 , and p 6 are assigned to be the prime divisors of p − 1 and n 1 ,n 2 , n 3 , n 4 , n 5 , and n 6 their cofactors.Raising both generator a and its power c to the large exponents n 1 , n 2 , n 3 , and n 4reduces the solution to the discrete logarithm to one modulo p 1 = 2, p 2 = 3, p 3 = 5, andp 4 = 37, which can be easily solved by enumerating all possibilities.sage: FF = FiniteField(p)sage: a = FF(109)sage: c = FF(1014452131230551128319928312434869768346)sage: [ a^(n1*i) for i in range(2) ].index(c^n1)1sage: [ a^(n2*i) for i in range(3) ].index(c^n2)2sage: [ a^(n3*i) for i in range(5) ].index(c^n3)4sage: [ a^(n4*i) for i in range(37) ].index(c^n4)29sage: crt([1,2,4,29],[2,3,5,37])29For the larger primesp 5 = 634466267339108669 and p 6 = 3865430919824322067,we verify the given discrete logarithms.131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!