Hi all,

Some time ago I’ve been thinking about a programming challenge that’s not simply another HackerRank style algorithm task and came up with something that I myself had a lot of fun solving. It goes like this:

We have a well known function (as in I didn’t come up with it):

 function xoshiro128ss(a, b, c, d) {
                return function() {
                    var t = b << 9, r = b * 5; r = (r << 7 | r >>> 25) * 9;
                    c ^= a; 
                    d ^= b;
                    b ^= c; 
                    a ^= d; 
                    c ^= t;
                    d = d << 11 | d >>> 21;
                    
                    return (r >>> 0) / 4294967296;
                }
            }  

We initialize it with 4 random parameters a,b,c,d (that I selected) :

  let rnd = xoshiro128ss(a, b, c, d);

and we do:

  let rand1 = rnd();
  let rand2 = rnd();
  let rand3 = rnd();
  let rand4 = rnd();

Knowing that:

rand1 == 0.38203435111790895
rand2 == 0.5012949781958014
rand3 == 0.5278898433316499
rand4 == 0.5114834443666041

What are the values of a,b,c and d?

I was wandering if it’s possible to figure it out and couldn’t stop trying until I did. It was an interesting journey and I learned some new things along the way Maybe someone else here will also have fun with it. As for prizes, I don’t know… whoever posts the right answer first gets an upvote and eternal fame.

  • CameronDev@programming.dev
    link
    fedilink
    arrow-up
    6
    ·
    10 个月前

    If this is your kind of thing, you will enjoy doing crypto ctf challenges. There are a few RNG reversing challenges.

    I hate them tbh, to much math, not enough brain :(