Random Numbers

Discussion of anything and everything relating to chess playing software and machines.

Moderators: Harvey Williamson, bob, hgm

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 3:31 pm
Location: Atlanta, Georgia

Random Numbers

Post by Dan Honeycutt » Sat Dec 17, 2016 6:05 pm

Hi All,

If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.

Best
Dan H.

mar
Posts: 2185
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Random Numbers

Post by mar » Sat Dec 17, 2016 9:02 pm

Dan Honeycutt wrote:Hi All,

If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.

Best
Dan H.
Here's mine, proven to be good (real world scenarios):

Code: Select all

ULong keys[2];

inline ULong Rotate(ULong v, Byte s) {
	return &#40;v >> s&#41; | &#40;v << &#40;64-s&#41;);
&#125;

// generate next 64-bit random number
inline ULong Next64&#40;)
&#123;
	ULong tmp = keys&#91;0&#93;;
	keys&#91;0&#93; += Rotate&#40;keys&#91;1&#93; ^ 0xc5462216u ^ (&#40;ULong&#41;0xcf14f4ebu<<32&#41;, 1&#41;;
	return keys&#91;1&#93; += Rotate&#40;tmp ^ 0x75ecfc58u ^ (&#40;ULong&#41;0x9576080cu<<32&#41;, 9&#41;;
&#125;
where ULong = uint64_t
IV is two 64-bit numbers (keys) so seed with whatever you want.
If your compiler can fold rotations (last time I tried with clang it couldn't), it can generate ~1 billion 64-bit PRN per second on my several years old stock i7 quad (single core).

public domain.

Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.

Milos
Posts: 3923
Joined: Wed Nov 25, 2009 12:47 am

Re: Random Numbers

Post by Milos » Sun Dec 18, 2016 2:10 am

Dan Honeycutt wrote:Hi All,

If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
https://en.wikipedia.org/wiki/Mersenne_Twister

Dann Corbit
Posts: 11621
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Random Numbers

Post by Dann Corbit » Sun Dec 18, 2016 3:05 am

Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 3:31 pm
Location: Atlanta, Georgia

Re: Random Numbers

Post by Dan Honeycutt » Sun Dec 18, 2016 5:10 am

mar wrote:Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.
What I'm working on is a very simple text editor with a password feature to use to store the many passwords you end up with if you are active on the internet. I'm an encryption noob, what advantage would a crypto-secure RNG give, just harder to decrypt?

Best
Dan H.

User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 3:31 pm
Location: Atlanta, Georgia

Re: Random Numbers

Post by Dan Honeycutt » Sun Dec 18, 2016 5:14 am

Milos wrote:
Dan Honeycutt wrote:Hi All,

If you're in the market for a good 64 bit pseudo random number generator my post in CTF, "So. Many. Passwords." may be of interest. I'm working on an encryption application - if you know something about encryption (I don't) I'd also like to hear your comments.
https://en.wikipedia.org/wiki/Mersenne_Twister
I've read that Kiss is something of an improvement over the Mersenne Twister but I certainly don't know enough to attest one way or the other.

Best
Dan H.

User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 3:31 pm
Location: Atlanta, Georgia

Re: Random Numbers

Post by Dan Honeycutt » Sun Dec 18, 2016 5:26 am

Thanks, Dann. I'm still trying to understand if I really need a crypto-secure RNG but if I do your second link looks like a good candidate.

Best
Dan H.

Dann Corbit
Posts: 11621
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Random Numbers

Post by Dann Corbit » Sun Dec 18, 2016 7:51 am

Dan Honeycutt wrote:
mar wrote:Of course it's not crypto-secure so I'm not sure what you want to accomplish. Generates sequence to xor input data with? Might work as a naive encryption.
What I'm working on is a very simple text editor with a password feature to use to store the many passwords you end up with if you are active on the internet. I'm an encryption noob, what advantage would a crypto-secure RNG give, just harder to decrypt?

Best
Dan H.
If you want to handle passwords, you NEED a crypto secure method.
Especially since users tend to reuse passwords.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 3:48 am

Re: Random Numbers

Post by kbhearn » Sun Dec 18, 2016 8:27 am

When it comes to cryptography there's so many ways to mess it up that you really shouldn't roll your own anyways for anything other than educational purposes - take an existing crypto library, use it as intended. Even your own implementation of an accepted protocol is risky (your implementation may 'work' while not being secure against subtle attacks) - heavily used crypto libraries you at least have the peace of mind that many people are looking for and fixing these vulnerabilities.

Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 10:41 am

Re: Random Numbers

Post by Lyudmil Tsvetkov » Sun Dec 18, 2016 8:35 am

one more thread, when one wonders, especially when posted by a mod, whether it belongs strictly here.

in any case, I see nothing related to computer chess: the use is not intended to tackle building a chess engine and, even if it were so, still the rigth forum would be the programming section.

on the other hand, I find Harvey's London chess classic thread quite acceptable, as people are using engine output to decide on a position.

Post Reply