Op 18-11-2021 om 12:17 schreef
osobli...@gmail.com:
>> What's more, because of this:
>> def Ek(n):
>> e=[n%2]
>> e.extend([Xk(n,k) for k in range(1,log2(n))])
>> return e
>> Eknum has one bit to much (because we are adding one bit by e=[n%2]). It has to be:
>>
>> def Ek(n):
>> e=[n%2]
>> e.extend([Xk(n,k) for k in range(1,log2(n)-1)])
>> return e
>>
I agree with e[0]=n%2, but I disagree with log2(n)-1. Note that my
version rounds log2 up, so that may be a source of confusion. Also note
that I start from 1 in range(1,log2(n)).
The version I have gives the same result as in the paper.
Ek(26)
[0, 1, 0, 0, 1]
>>
>> I have no idea why results are different after 2 iterations.
>
> With bigger numbers than 2**95+1 iterations are completely different. I think the mistake is in:
>
> atmp = bin(b(n+ao)^Eknum(n+ao))[2:97]
>
> It Eknum(n+ao) could cut least significant bits before xoring, because we want number Eknum(n+ao) composed of 95 most significant bits. If we not cut them first it will xor using 95 least significant bits, because this is how xoring works. Am I right?
>
Ok, I see your point. Then it may be better to forget about the
Ek-vector as a number (so no more Eknum) and only interpret it as a vector.
Now I xor Ek=[X0,X1,X2,...,X94] with b(n+ao)=[b94,b93,b92,...,b0]. But I
am not sure. The paper is not explicit on this. And we don't have any
test vectors, so we don't really know what to work towards.
Here is my final version, as I interpret the description of alg1. Sorry
that it is still in python2 (so you may have to rewrite a bit to make it
work). I skipped the final step where you have to do Ek(n+a0)Ek(n+a1)...
If you post the broken seeds I can test again. Btw, the paper considers
seeds > 2**95.
Ozz
#!/bin/python
def T(n):
return (n*3**(n%2)+n%2)/2
def Tk(n,k):
if k==1:
return T(n)
else:
return Tk(T(n),k-1)
def Xk(n,k):
return Tk(n,k)%2
def log2(n): # rounds up
i=0
while 2**i < n:
i += 1
return i
def Ek(n):
e=[n%2]
e.extend([Xk(n,k) for k in range(1,log2(n))])
return e
def b(n):
return n>>(log2(n)-95)
def alg1(n):
ao=0
while True:
bv=[int(i) for i in bin(b(n+ao))[2:]]
ekv=Ek(n+ao)[:95]
av=[x^y for (x,y) in zip(bv,ekv)]
s=0
for i in range(len(av)):
s = s + av[i]*2**(len(av)-i-1)
a=(s+ao)%(2**128)
ao=a
yield a
x=2**95+1
c=alg1(x)
for i in range(50):
print c.next()