News for hackers. Stuff that matters.
Re:Ask HN: Would you like to play a game? by sklivvz1971 on Thursday July 31, 2014 @09:37AM (#8113937)
Yes, pseudo-random permutation.

The basic algorithm goes like this. To generate the codes

    generate_codes(range valid_range)

      for(i in valid_range)
        encoded = RSA.Encode(key, i)
        code = base32.Encode(encoded)
        print code
and then, to verify a code

    verify(string code, range valid_range)

      encoded = base32.Decode(code)
      value = RSA.Decode(key, encoded)

      return valid_range.contains(value)
where of course RSA is an implementation of http://en.wikipedia.org/wiki/RSA_(cryptosystem) and base32 refers to http://en.wikipedia.org/wiki/Base32.

On top of that, we needed codes to be of a specified maximum length and with a specified alphabet. Thus, instead of base32 we used a different base with different letters, but the same algorithm. To fix the length of the codes, we needed the output of RSA encode to be less than a specific value. In RSA this can be controlled by choosing the modulus part of the key.

There are more subtleties to this, but the gist is there.

Re:Ask HN: Would you like to play a game? by junto on Thursday July 31, 2014 @09:45AM (#8113994)
Thanks for this. Very interesting.

I assume that without the RSA key I cannot generate these codes myself then, even if I was to guess at the range?

Re:Ask HN: Would you like to play a game? by sklivvz1971 on Thursday July 31, 2014 @09:56AM (#8114087)
Yes, that's the idea :-)
Re:Ask HN: Would you like to play a game? by junto on Thursday July 31, 2014 @10:12AM (#8114176)
Ok, thus, if a similar scheme is being used for the FIFA stickers, the person that put this together (http://fifapaninicode7.appspot.com/) must know the RSA key!
Re:Ask HN: Would you like to play a game? by sklivvz1971 on Saturday August 09, 2014 @05:11AM (#8156558)
Or they simply have a list of codes...
Re:Ask HN: Would you like to play a game? by kaoD on Thursday July 31, 2014 @11:16AM (#8114576)
Did you check that these codes work and are not just a ruse?
Re:Ask HN: Would you like to play a game? by junto on Thursday July 31, 2014 @11:56AM (#8114848)
They do work.