class SplittableRandom
Martin Buchholz
martinrb at google.com
Mon Jul 15 23:06:18 UTC 2013
Another experiment that provides bit-full seed but poor gamma
public void testAdversary3() {
SplittableRandom r = new SplittableRandom(new Random().nextLong(),
1L<<61, new Error());
System.out.println("testAdversary3");
int prev = 0;
for (int i = 0; i < 30; i++) {
int next = r.nextInt();
System.out.printf("next=%08x diff=%08x%n", next, next - prev);
prev = next;
}
}
produces insufficiently random output like the below, which seems to show
that a poor choice of gamma (even though very unlikely) can invalidate an
entire generated sequence. It would be nice if we had more confidence that
the gamma we choose will be "high-quality".
[java] .testAdversary3
[java] next=75b1386c diff=75b1386c
[java] next=b7599731 diff=41a85ec5
[java] next=aa95c7fc diff=f33c30cb
[java] next=ec3e26c1 diff=41a85ec5
[java] next=2de68586 diff=41a85ec5
[java] next=6f8ee44c diff=41a85ec6
[java] next=a3f44ce7 diff=3465689b
[java] next=e59cabac diff=41a85ec5
[java] next=27450a72 diff=41a85ec6
[java] next=68ed6937 diff=41a85ec5
[java] next=bc5021dc diff=5362b8a5
[java] next=fdf880a1 diff=41a85ec5
[java] next=3fa0df66 diff=41a85ec5
[java] next=81493e2b diff=41a85ec5
[java] next=b5aea6c7 diff=3465689c
[java] next=f757058c diff=41a85ec5
[java] next=38ff6451 diff=41a85ec5
[java] next=7aa7c317 diff=41a85ec6
[java] next=f34f0e8c diff=78a74b75
[java] next=34f76d51 diff=41a85ec5
[java] next=769fcc16 diff=41a85ec5
[java] next=b8482adc diff=41a85ec6
[java] next=ecad9377 diff=3465689b
[java] next=2e55f23c diff=41a85ec5
[java] next=6ffe5102 diff=41a85ec6
[java] next=b1a6afc7 diff=41a85ec5
[java] next=2b7f385d diff=79d88896
[java] next=6d279722 diff=41a85ec5
[java] next=aecff5e7 diff=41a85ec5
[java] next=f07854ac diff=41a85ec5
On Mon, Jul 15, 2013 at 3:46 PM, Doug Lea <dl at cs.oswego.edu> wrote:
> On 07/15/13 16:13, Martin Buchholz wrote:
>
>> I'll be your loyal adversary today, trying to break SplittableRandom.
>>
>> Let's make it easier by providing a low-level constructor:
>>
>> /** XXXX Testing */
>> public SplittableRandom(long seed, long gamma, Error XXXX) {
>>
>
> Now you see why we don't do that :-)
>
>
>
>>
>> and then we have sneaky test using weakest args: seed = 0, gamma = 16
>>
>
> Which you would otherwise run into once every 2^64 splits.
> So, rarely. you get some not-very-random-looking randoms.
> Which is also what you'd expect under a truly random RNG.
>
>
> -Doug
>
>
>
More information about the core-libs-dev
mailing list