Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research js Randomness for Shuffling #1

Open
kellyelton opened this issue Jan 6, 2016 · 1 comment
Open

Research js Randomness for Shuffling #1

kellyelton opened this issue Jan 6, 2016 · 1 comment

Comments

@kellyelton
Copy link
Member

We need to research and come up with a good method to shuffle in JS with a good random.

There are 3 purposes of this ticket

  1. Develop a way to test algorithms and random sources
  2. Lay out all the different ways we could generate a random seed for use with the randomizer function signature
  3. Figure out which platforms we need to test on and update this ticket.

1. Develop a way to test algorithms and random sources

We need a method that takes uses the shuffle function below and tests it's randomness.

The trick here is that you should expect that the js engine will be running headless(no actual visuals). The task is actually a 2 part task.

  1. Create the actual test, and have it output data we can look at later
  2. Have a separate script(preferably a jsFiddle that can take the data produced and create a graph or something from it(kind of like this https://jsfiddle.net/kellyelton/8s1jejho/2/)
// array: a js array of numbers in order, the amount is not known at this time
// randomizer: a function that returns a random number. It's defined below
shuffle(array, randomizer){
  var random = array.map(randomizer);
  array.sort(function(a, b) {
    return random[a] - random[b];
  });
}

// returns:  Random decimal between 0 and 1
randomizer()

2. Lay out all the different ways we could generate a random seed for use with the randomizer function signature

When the first part gets done, then we can start posting some overloads of the randomizer function for testing.

3.Figure out which platforms we need to test on and update this ticket.

Once we're done with 1 and 2 we should figure out which js engines we need to test against and update this ticket. We should then update our testing method to make sure it works on all of the engines.

Some links

http://hackaday.com/2015/12/28/v8-javascript-fixes-horrible-random-number-generator/

https://github.com/clipperz/javascript-crypto-library

https://github.com/simbo1905/srp-6a-demo/blob/master/srp/Client/lib/random.js

https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues

http://chancejs.com/

https://github.com/simbo1905/srp-6a-demo/blob/master/srp/Client/lib/random.js

@Gravecorp
Copy link

https://gist.github.com/ne-sachirou/852327
another random alternative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants