by Panagiotis C. Karagiorgis
Declaration of notations used Ó 2006
÷Î× : element ÷ belongs to set ×. phone: (30) 210.825.3209
"÷ : for every ÷. e-mail: karagiorgis@tellas.gr
$÷ : there exists some ÷.
[÷] : the integer part of ÷³0.
×-Õ : set of all contents of × not belonging to set Õ.
“:” : such that.
Í={1,2,3,…} is the set of positive integer numbers.
Í0={0,1,2,3,…}=Íîø{0} the set of nonnegative integers.
Æ={0,±1,±2,±3,…} is the set of all integer numbers.
x»y : numbers x and y are similar in size.
The congruence ÷ºø (mod â), where appearing, denotes that integers ÷ and ø give the same nonnegative remainder, once being divided by a certain positive integer â.
The function mod(á,â) is the nonnegative remainder, upon division of áÎÆ by âÎÍ.
The expression “numbers … are identical/different modulo â” means that, once divided by a certain positive integer â, give the same/different nonnegative remainder.
The function gcd(á,â) gives the greatest common divisor of numbers á,â: (á,â)ÎÍ2.
¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾
The first two theorems (1 and 2) state that, if ì=2í, where íÎÍ, then:
5ìº1 (mod 4·ì) and ì£ç "çÎÍ: 5çº1 (mod 4·ì).
Theorem 1.
If ì=2í, for íÎÍ, then 5ìº1 (mod 4·ì).
When í=1, then ì=21=2 and it is obvious that 52º1 (mod 4·2).
To proceed by induction, we accept that, for some êÎÍ, the next congruence holds:
5ìº1 (mod 4·ì), where ì=2ê.
Then, 5ì-1º0 (mod 4·ì) Þ (5ì-1)·(5ì+1)º0 (mod 4·2·ì) Þ 52·ì-1º0 (mod 4·2·ì). Consequently 52·ìº1 (mod 4·2·ì) and since 2·ì=2ê+1, it follows that:
5ëº1 (mod 4·ë), where ë=2·ì=2ê+1.
The induction is complete and, therefore, 5ìº1 (mod 4·ì) "íÎÍ, where ì=2í.
Theorem 2.
If ì=2í, for íÎÍ, then ì£ç "çÎÍ: 5çº1 (mod 4·ì).
From the 1st theorem, it follows (since ì=2í) that the least positive integer ô, for which 5ôº1 (mod 4·ì), has to be of the form ô=2ñ, where ñÎÍ (0<ñ£ì), because, for ô=20=1 we would get the contradiction 51º1 (mod 4·ì), where 4·ì³8.
We also observe that the assumption ñ<ì would justify the congruence:
5ì/2º1 (mod 4·ì), for ì=2í, where íÎÍ.
When í=1, then the last congruence is obviously false.
We’ll show by induction that this is also false "íÎÍ, based on the assumption that:
$êÎÍ-{1}: 5ì/2º1 (mod 4·ì), for ì=2í, when í=ê.
Then, for ì=2ê, we would get 5ì/2-1º0 (mod 4·ì) ) Þ (5ì/4-1)·(5ì/4+1)º0 (mod 4·ì)
Þ 5ì/4-1º0 (mod 4·ì/2), given that 5ì/4+1º2 (mod 4).
Hence: 5(ì/2)/2º1 (mod 4·ì/2), and since ì/2=2ê-1, it follows that:
5ë/2º1 (mod 4·ë), where ë=ì/2=2ê-1.
As we just show, the induction hypothesis contradicts the initially realized fact, that the congruence 5ì/2º1 (mod 4·ì) is false, when í=1 and ì=2í=21.
Consequently, if ì=2í, for íÎÍ, then ì£ç "çÎÍ: 5çº1 (mod 4·ì).
Theorem 3.
If ñº1 (mod 2), then and only then, the retrospective sequence:
ëê=mod(á·ëê-1+ñ,2í) "êÎÍ, where (í,á)ÎÍ2: áº5 (mod 8), ë0ÎÍ0 (and ñÎÍ0),
admits (in any circular order) all values ëÎÍ0: ë<2í
(in mathematical terms: "(í,k)ÎÍ2 and "ëÎÍ0: ë<2í $êÎÍ: ê>k and ëê=ë).
The converse of the implication (the “only then” part) proposed in this theorem, can be proven, rather easily, by contradiction. Because, if ñ was an even number, then ëê=mod(á·ëê-1+ñ,2í) would result (beyond some ëê-1 of even value) to a circular sequence of even terms, only. Surely, there is at least one even ëê-1, considering that:
"(í,k)ÎÍ2 and "ëÎÍ0: ë<2í must $êÎÍ: ê>k and ëê=ë,
counts for ë=0, as well. But, then, the above statement would be false for ë=1 (which is impossible).
To verify the direct implication, one is obliged (for í>2) to implement the above theorems (1 and 2), as well as a corollary from the Diophantic-equations theory.
(For í£2, we have áº1 (mod 2í) Þ ëê=mod(ëê-1+ñ,2í) "êÎÍ and, thereby, the equivalent to the congruence ñº1 (mod 2) condition gcd(ñ,2í)=1 is necessary and sufficient, for the above sequence ëê to run over all values ëÎÍ0: ë<2í.)
By theorems 1 and 2, we confirm, step by step, the following results:
á´. For ì=2í, where íÎÍ, and since 5ôº1 (mod 4) "ôÎÍ, the congruences:
5ìº1 (mod 4·ì) and ì£ç "çÎÍ: 5çº1 (mod 4·ì)
imply that, for ô=1,2,3,…,ì , the numbers 5ô admit typically all values 1,5,9,…,4·ì-3 modulo 4·ì, in a different order.
â´. For any constant odd positive integer ó<ì, and for ô=1,2,3,…,ì , the numbers 5ó·ô form a complete coverage of all values 1,5,9,…,4·ì-3 modulo 4·ì, in some order, depending on the choice of ó.
ã´. For all acceptable values of ó, the constants 5ó cover precisely the values 5,13,21,…,4·ì-3 modulo 4·ì, and this makes us consider the circular retrospective sequence: ñê=mod(á·ñê-1,â) "êÎÍ and for any ñ0º1 (mod 4), by implementing the constants áÎ{5,13,21,…,4·ì-3} and â=4·ì (for ì=2í, where íÎÍ). As a result, ñê runs over the values 1,5,9,…,4·ì-3 modulo 4·ì, in some circular order, determined by the choice of constant á.
ä´. For ðõ=(ñõ-1)/4 "õÎÍ0, we find the retrospective formula of the transformed circular sequence ðê=mod((4·a+1)·ðê-1+a,ì) "êÎÍ, for ð0ÎÍ0 and aÎ{1,3,5,…,ì-1} (where ð0=(ñ0-1)/4 and a=(á-1)/4). Now, ðê runs over all different values modulo ì.
å´. For ÷ê=mod(ðê+b,ì) "êÎÍ, with ÷0=ð0+b and bÎÍ0 arbitrary, we identify the retrospective form of this third sequence, as ÷ê=mod((4·a+1)·÷ê-1+(1-4·b)·a,ì) "êÎÍ, where ÷0ÎÍ0. Again, ÷ê admits all different values modulo ì.
ò´. For øõ=mod(-÷õ,ì) "õÎÍ0, we finally get the fourth retrospective sequence øê=mod((4·a+1)·øê-1+(4·b-1)·a,ì) "êÎÍ, with ø0ÎÍ0, which is complementary to the third one, and leads to the generalization:
(1) ëê=mod((4·a+1)·ëê-1+(4·b±1)·a,2í) "êÎÍ, for ë0ÎÍ0 and íÎÍ. Obviously:
(2) "(í,k)ÎÍ2 and "ëÎÍ0: ë<2í $êÎÍ: ê>k and ëê=ë. Moreover:
(3) "aÎ{1,3,5,…, 2í-1} and "(í,ñ)ÎÍ2: ñº1 (mod 2) $bÎÍ0: ñº(4·b±1)·a (mod 2í) ,
considering that a is odd, and one can chose 4·b±1 among all odd positive integers. According to the Diophantic-equations theory, gcd(a,2í)=1 implies that, regarding the value of 4·b±1, there is a unique modulo 2í, solution î. If í>1, then 1 (mod 4) and b=-(±1-mod(î,2í))/4, with ± matching, everywhere, the appropriate sign in 4·b±1 (either + or -). When í=1, then a=1 Þ b=0. As for a, we realize that:
(4) "(í,á)ÎÍ2: áº5 (mod 8)
$ qÎ{0,1,2,3}, aÎ{1,3,5,…, 2í-1}: 4·a+1º2í·q+á (mod 2í+2) , because the integer (á-1)/4 is odd. For qÎ{0,1,2,3} being arbitrary (excluding the case í£2, when q=mod((1-á)/4-ñ,í2) "ñÎÍ0), we get the short formula: a=mod((2í·q+á-1)/4,2í).
Relations (1), (2), (3), and (4) prove, together, the direct implication of this theorem.
Theorem 4.
The recursively computable value: xu+1=mod(g-(xu-1)2/2,2u),
for x3=1 and "(g,u)ÎÍ2: gº1 (mod 4) and u³3,
is a unique, modulo 2u, solution of the simultaneous congruences:
x2º2·g-1 (mod 2u+1) and xº1 (mod 4) .
Consider the retrospective sequence yu+1=mod(c-2·yu2,2u-2), where y3=0, c=(g-1)/4, and u³3. For xu=4·yu+1 "uÎÍ-{1,2}, we have x3=1, and xu+1=mod(g-(xu-1)2/2,2u) when u>3. We intend to show by induction that, "uÎÍ-{1,2}, the critical congruence (4·y+1)2º8·c+1 (mod 2u) is equivalent to: yºyu (mod 2u-3). Starting with u=3, we have:
(4·y+1)2º8·c+1 (mod 23) Û (2·y+1)·yºc (mod 1), which is true "yÎZ, as is, always, the congruence yºy3 (mod 20). Hence, there is at least one suitable u³3, satisfying the equivalence: (4·y+1)2º8·c+1 (mod 2u) Û yºyu (mod 2u-3). The question is, if such a u serves for the following equivalence to hold:
(4·y+1)2º8·c+1 (mod 2u+1) Û yºyu+1 (mod 2u-2).
Before proceeding, assume that the congruences: (4·y+1)2º8·c+1 (mod 2u+1) and
(4·(y+z)+1)2º8·c+1 (mod 2u+1),
hold simultaneously for some zÎÆ. Then,
2·y2+yº2·(y+z)2+y+z (mod 2u-2) Þ 0º4·y·z+2·z2+z (mod 2u-2) Þ
Þ 0º(4·(y+z/2)+1)·z/2 (mod 2u-3) Þ zº0 (mod 2u-2), which implies
that the solution y=yu+1: (4·y+1)2º2·g-1 (mod 2u+1), the existence of which shall be proven right away, is unique modulo 2u-2. Indeed, we have:
(4·yu+1)2º8·c+1 (mod 2u) Þ 2·yu2+yuºc (mod 2u-3) Þ (c-2·yu2-yu)/2u-3=r0ÎZ. Hence:
yu+1=mod(c-2·yu2,2u-2) Þ (c-2·yu2-yu+1)/2u-2=r1ÎZ Þ r0·2u-3+yu-yu+1=r1·2u-2 Þ
Þ yu+1=yu+r·2u-3, for r=r0-2·r1. Then, 2·yu+12+yu+1=2·(yu+r·2u-3)2+yu+r·2u-3=2·yu2+yu+ +(4·yu+1+r·2u-2)·r·2u-3=c+(r·(4·yu+1+r·2u-2)-r0)·2u-3=c+(r·(2·yu+1+r·2u-3)-r1)·2u-2 Þ
Þ 2·yu+12+yu+1ºc (mod 2u-2) Þ (4·yu+1+1)2º8·c+1 (mod 2u+1), which had to be shown.
From theory to practice
1. The sequence ôê=(ëê+0.5)/2í covers uniformly the interval (0,1). For a sufficiently great íÎÍ, the size of ì=2í permits us to regard ôê as a continuous random variable following the uniform distribution U(0,1). In usual applications, it’s enough to have í>50. However, for serious implementation in cryptography, special simulations, or other scientific applications, the size required for í may extend to several millions…
2. Binary Oblong Random Number (B.O.R.N.) engines are extremely fast, since based on the sequences ëê and ôê, the calculations for them being free from time consuming divisions, confined only to multiplications and binary translations. The number of operations is, of course, proportional to í2 and this could be a problem, in the case where í is very big. To minimize such a problem, one may use a smaller í, together with a special áº5 (mod 8), it depending on ô=2ë, í-4³ëÎÍ, and øÎ{Ö(5)-1,3-Ö(5)}, through the congruence: áôº4·ô·(2·[ø·2í-4/ô]+1)+1 (mod 2í+2).
3. The above optimization technique originates, theoretically, from a property characterizing all simple, natural multiples of the so-called golden ratio: They just tend to have their fractional parts rather uniformly distributed in the (0,1) interval.
Implementing this property in B.O.R.N. engines has the following result: "ôê: |ôê-÷|<å, where ÷Î(0,1) and å>0 reasonably small, the future ôê+ô, after ô executions, will spread uniformly in the (0,1) interval, as long as æ lies sufficiently close to any odd integer. We obtain such a distribution for í-ë=35, 51, 56, 65, …, 303402, 1913791, 3912915, 7868057 and infinite other numbers, for which the random-numbers recycling period, 2í, becomes inconceivably extensive.
4. The apparent independence of random numbers generated improves, when the choice of ë is such that: number æ=2í-3·ø/ô gets close enough to an odd integer and, at the same time, (2ë=) ô»í2. For instance, if í=78 and ë=13, then ô=213=8192 (which is similar in size to í2=6084), and the odd integer 2·[æø<1/2]+1 lies sufficiently near to æø<1=ø·278-3/8192=3523014627193176565.0241… (for ø=3-Ö(5)). The formula of áô gives áôº115442143303866009681921 (mod 280), and the respective theory (here advising to implement the 4th theorem 13 times, repetitively) enables us to calculate á=á0=ámin(æø<1)=126179576654017396061, one of the optimal values for the engine ëê=mod(á·ëê-1+ñ,278), the effectiveness of which is not influenced by the choice of the odd integer ñ. The value of ñ may be chosen freely (say, ñ=71300379), or based on a truly random ë0ÎÍ0: ë0<22·í-1 (instead of ë0<2í), through the formula: ñ=2·[ë0·2-í]+1.
5. In general, the congruence áôº4·ô·(2·[ø·2í-4/ô]+1)+1 (mod 2í+2) is satisfied by 2·ô different modulo 2í+2 integers á, the following: á2·i+ä=áä+2í+2·i/ô, ãéá i=0,1,2,…,ô-1 and ä=1 or 0, when æ=æø>1 or æø<1, respectively. Obviously, for ô=2 (ë=1), the only incongruent numbers, modulo 2í, are á0 and á1. When ô>2 (Û ô³4, and ë³2), then all á2·i+ä are different to each other, modulo 2í, provided i<ô/4. For every such á=á2·i+ä, we set á´=mod(áw,2í), where w=2í-2-1. Then, for ñ´º-á´·ñ (mod 2í), the generator ëê=mod(á´·ëê-1+ñ´,2í), admits in inverse order the terms of ëê=mod(á·ëê-1+ñ,2í). The new generation of engines, thus arising, retains the advantage of maximal distribution and can be used alternatively. The so-called secondary B.O.R.N. generators, in combination with the respective primary, are also suitable for variable string coding and decoding transformations, in packs being originally [í/8] characters long, before extended by one extra byte, this concealing the transmission code for the current pack. In our example, [í/8]=[78/8]=9, and the first step, for the sender, is to form the integer ÷³0, from the 9 characters of each group. Next, he constructs the term ëê-1=64·÷+ù, by choosing an arbitrary ùÎ{0,1,2,…,63}, and computes ëê=mod(á´·ëê-1+ñ´,278), from ñ´ and á´=mod(áw,278), for w=276-1 and for any selection of áÎ{á0,á2,á4,á6} (since ä=0). In practice, the sender doesn’t need to know the value of á=á2·i(+ä), provided he knows which iÎ{0,1,2,3} represents each feasible pair (á´,ñ´), among the ones corresponding to his 4 private keys á´, processed with the given value of ñ. The encrypted pack of 9+1=10 bytes transmitted to the recipient is, finally, the quantity n=4·ëê+i. Since that fellow knows the values of á0,á2,á4,á6 (and ñ), he just sets ëê-1=[n/4] and á=á2·i(+ä), for i=mod(n,4), so as to decipher the concrete pack, through ëê=mod(á·ëê-1+ñ,278). Once ÷=[ëê/64] is obtained, it actually reveals the 9 characters of that pack. After reading the full series of packs, the recipient can send his response, well encrypted, by simply using his own parameters. The owner of the respective pairs (á´,ñ´) will certainly be able to decipher his response.
6. When í is relatively small, the need for a good choice of æ gets crucial, and its exact value depends, exclusively, on the difference of the parameters í and ë. Here, í-ë=65 (=78-13), and we have the opportunity to construct one more primary generator of typical specifications. By setting í=77 and ë=12, in this case, we steadily have í-ë=65 (=77-12), while ô=2ë=212=4096»5929=772=í2. So, we have every reason to calculate a few of the optimal ô/2=2048 pairs (á,á´), and we already known how. (For ë>1, there are always ô/2 such pairs, incongruent modulo 2í, while for ë=1, their number is ô=21=2.)
Generally, the best choices of í appear in pairs of successive integers, with partners adjacent ë-values, all arising from a known difference f=í-ë: |2·[æ/2]+1-æ|<å(f)<0.05, for some decreasing function å(f)>0, slowly tending to 0, as f tends to ¥. For ë=[log2(f2)] Þ [log2(f2)]+1, we obtain the respective successive values of í=f+ë. When f=65, then log2(652)=12.0447… and ë=12 or 13. So, í=ë+65=77 or 78, respectively.
7. Filtering files through xor bit-operations, with operant a key-file of totally random contents, requires two programs: á) “Key Maker” (rarely used), which produces a reasonably large “binary.key” and â) “Key Holder” (often used), which serves to encrypt or decipher any file. The files being encrypted by the sender are, in practice, already compressed folders with the desired contents, and are sent as attached to an email being addressed to other owners of the exact binary.key file, that was used for encryption. Only a variant part of this large key file applies, each time, and its end determines, automatically, the beginning of the next key part to be used for secret communication, as far as the same pair of correspondents is concerned.