Hmmn.. Off the top of my head it looks like an encryption
Algorithm..... RSA mayhap?

This looks like either RSA or the Cayley Purser algorithm..


jeremy

-----Original Message-----
From: Cary Gordon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 03, 2000 3:37 PM
To: CF-Talk
Subject: OT: Harder Math Question


Any idea of how I can turn this algorithm a custom tag?  It is in
Mathematica format as that is the only way I could think of to post it here.

      StringToMatrices[text_String]:= Partition[Parition[Flatten
      [Append[StringToList[text],{32,32,32}]],2],2]

      _______________________________________________________________

      MatriceToString[l_List] :=
       StringJoin [ ConvertNumber/@Flatten[1]]

      _______________________________________________________________

      CPpqn[digits_Integer] :=Module[{
        p1 = FirstPrimeAbove[Random[Integer,
             {10^(Floor[digits/2]-1), 10^(Floor[digits/2])-1}]],
        q1 = FirstPrimeAbove[Random[Integer,
             {10^(Floor[digits/2]-1), 10^(Floor[digits/2])-1}]],
      While[PrimeQ[p = 2p1 +1], p1 = FirstPrimeAbove[p1 + 1]]; p;
       While[PrimeQ[q = 2q1 +1], q1 = FirstPrimeAbove[q1 + 1]];
       q; n = pq; ]

      _______________________________________________________________

      randmatrix := (Catch[
         Do[m = Table[Random[Integer, {0, n}], {i, 1, 2}, {j, 1, 2}];
      If[GCD[Mod[Det[m], n], n] == 1, Throw[m]], {1000}]])

      _______________________________________________________________

      inv[a_] := (d = Mod[Det[a], n]; i = PowerMod[d, -1, n];
      {{Mod[i * a[[2, 2]], n], Mod[-i * a[[1, 2]], n]},
         {Mod[-i * a[[2, 1]], n], Mod[i * a[[1, 1]], n]}})

      _______________________________________________________________

      mmul[j_, k_] := Mod[
        {{Mod[j[[1, 1]]*k[[1, 1]], n] + Mod[j[[1, 2]]*k[[2, 1]], n],
          Mod[j[[1, 1]]*k[[1, 2]], n] + Mod[j[[1, 2]]*k[[2, 2]], n}},
         {Mod[j[[2, 1]]*k[[1, 1]], n] + Mod[j[[2, 2]]*k[[2, 1]], n],
          Mod[j[[2, 1]]*k[[1, 2]], n] + Mod[j[[2, 2]]*k[[2, 2]], n]}},
        n]

      _______________________________________________________________

      CPparameters := (identity = {{1, 0}, {0, 1}};
        alpha = randmatrix; Catch[Do[chi = randmatrix;
      If[mmul[chi, alpha] ! = mmul[alpha, chi],
           Throw[chi]], {10000000}]]
        chiinv = inv[chi]; alphainv = inv[alpha];
        Catch[Do[s = Random[Integer, {2, 50}];
          gamma = Mod[MatrixPower[chi, s], n];
          If[gamma != identity, Throw[gamma]], {10000000}]];
      Catch[Do[delta = Mod[Mod[Random[Integer, {1, n-1}]gamma, n]
              + Mod[Random[Integer, {1, n-1}]identity, n], n]
            If[delta !=identity &&
              mmul[delta, alpha] !=mmul[alpha, delta], Throw [delta]],
          {10000000}];
        beta = mmul[mmul[chiinv, aphainv], chi];
        deltainv = inv[delta];
        epsilon = mmul[mmul[deltainv, alpha], delta];
      kappa = mmul[mmul[deltainv, beta], delta];
        lamda = mmul[mmul[chiinv, epsilon], chi];)

      _______________________________________________________________

      CPenc[plain_String] := CPencNum [ StringToMatrices[plain]]
      _______________________________________________________________

      CPDecNum[l_list] := Table[mmul[mmul[lamda, l[[i]]], lamda], {i,
Length[l]}]
      _______________________________________________________________

      CPEncNum[l_List] :=
       Table[mmul[mmul[kappa, l[[i]]], kappa], {i, Length[l]}]


      _______________________________________________________________

      CPdec[cipher_List] := MatricesToString[CPDecNum[cipher]]

I will award a meaningful, albeit insignificant, prize to the first poster
who can identify, even in broad terms, the (quite useful) function of this
algorithm.

Cary

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to