FreeBASIC's PRNG #2

General FreeBASIC programming questions.
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 15, 2018 22:50

paul doe wrote:Speaking of fast: you don't really need to use strings to pass binary data to PractRand:

Nice piece of code, Paul.

It is amazing what can be done when two are looking at a problem. It is like playing chess except both players win with the final code - if the code is ever final. <smile>
paul doe
Posts: 701
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: FreeBASIC's PRNG #2

Postby paul doe » Sep 15, 2018 22:57

deltarho[1859] wrote:Nice piece of code, Paul.

It is amazing what can be done when two are looking at a problem. It is like playing chess except both players win with the final code - if the code is ever final. <smile>

Thanks. Indeed, I'm actually learning quite a lot, and having a (mildly) good time at once ;)

Ever heard of Pair Programming? I've had my fair share of those, and I can assure you, they are both very instructive, and incredibly fun to boot =D
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 15, 2018 23:17

paul doe wrote:Ever heard of Pair Programming?

I hadn't. Just done a spot of Googling - interesting concept.
dafhi
Posts: 1165
Joined: Jun 04, 2005 9:51

Re: FreeBASIC's PRNG #2

Postby dafhi » Sep 16, 2018 6:00

@paul doe - would you mind if included in my framework, your algorithm
viewtopic.php?f=3&t=26986&start=15#p251557

@dodicat - same.
viewtopic.php?f=3&t=26996&start=180#p252023

for publishing on github .. i can show a preview here
paul doe
Posts: 701
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: FreeBASIC's PRNG #2

Postby paul doe » Sep 16, 2018 6:36

dafhi wrote:@paul doe - would you mind if included in my framework, your algorithm
viewtopic.php?f=3&t=26986&start=15#p251557

By all means, go ahead. However, that's not mine, I think it's xorshift128+, but I can't quite remember now. Perhaps deltarho[1859] will recognize it and can tell you exactly what algorithm it is.
dodicat
Posts: 5086
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC's PRNG #2

Postby dodicat » Sep 16, 2018 8:18

Dafhi
Two's a pair.
The rest of us have been informed.
dafhi
Posts: 1165
Joined: Jun 04, 2005 9:51

Re: FreeBASIC's PRNG #2

Postby dafhi » Sep 16, 2018 8:52

Thanks guys :-) They're up on Projects. I'll wait till I can find more info about the unknown one before i hit Github
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 16, 2018 12:38

paul doe wrote:However, that's not mine, I think it's xorshift128+

Yes, it is although I used 23, 18 and 5 as recommended by Vigna. V8 JavaScript uses 23, 17 and 26. It fails PractRand at 64GB and, from what I have read, it fails Big Crush as well.

If A is faster than B and A passes both Big Crush and PractRand but B fails both why go with B?
dafhi
Posts: 1165
Joined: Jun 04, 2005 9:51

Re: FreeBASIC's PRNG #2

Postby dafhi » Sep 16, 2018 20:00

deltarho[1859] wrote:
paul doe wrote:However, that's not mine, I think it's xorshift128+

Yes, it is although I used 23, 18 and 5 as recommended by Vigna. V8 JavaScript uses 23, 17 and 26. It fails PractRand at 64GB and, from what I have read, it fails Big Crush as well.


thanks!

I read that PCG isn't crypto-strength. And then learning of xorShift, read an article about reverse-engineering for prediction. Having only grazed the article https://blog.securityevaluators.com/xor ... 3365dc0c17 i 'jumped' to several conclusions

1. you can only reverse engineer, to an extent (with today's hardware) if you know the original algorithm.
2. I don't yet know much about crypto, but cross-referencing my experience reading about reversible RNGs with what I read from the article, if i wanted to make a crypto RNG, I would begin by toying with the idea of non-reversibility.

[update]
i think I get it. non-reversibility isn't possible. At least with our current instruction set. Multiply is reversible via 'mod inverse' .. you'd need something non-linear .. logarithmic .. lol .. elliptical curve maybe? (i've heard the term)

this digs into the foundation of mathematics
Last edited by dafhi on Sep 16, 2018 20:30, edited 1 time in total.
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 16, 2018 20:30

If whatever you are using random numbers for does not require secrecy then whether the generator has any predictability is neither here nor there.

Developing a crypto RNG is not easy and Microsoft have been updating theirs for over 20 years in accordance with NIST recommendations. Developing a crypto RNG would be a pointless exercise if crypto strength wasn't a requirement.
jj2007
Posts: 749
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC's PRNG #2

Postby jj2007 » Sep 16, 2018 21:00

Many uses of a PRNG require predictability. For example, if you encrypt a text, you will wish one day to decrypt it. In that moment, you need to know a) which algo and b) the starting point of the sequence.
dafhi
Posts: 1165
Joined: Jun 04, 2005 9:51

Re: FreeBASIC's PRNG #2

Postby dafhi » Sep 16, 2018 21:13

predictability is one thing, reversibility is another. reversibility is a challenge even if you know the forward algorithm
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 16, 2018 21:45

jj2007 wrote:In that moment, you need to know a) which algo and b) the starting point of the sequence.

That is repeatability and not predictability. O'Neill said the predictability of PCG was challenging. However, if we took a snapshot of the state, at some point, and returned to that snapshot later we would repeat the sequence following the snapshot. The past is of no use to an attacker, they want to know the future.
deltarho[1859]
Posts: 1440
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC's PRNG #2

Postby deltarho[1859] » Sep 16, 2018 22:01

dafhi wrote:predictability is one thing, reversibility is another.

The point being?
if i wanted to make a crypto RNG, I would begin by toying with the idea of non-reversibility.

I wouldn't. I would toy with the idea of unpredictability. An unpredictable sequence would be non-reversible. <smile>
dafhi
Posts: 1165
Joined: Jun 04, 2005 9:51

Re: FreeBASIC's PRNG #2

Postby dafhi » Sep 16, 2018 22:03

deltarho[1859] wrote:
if i wanted to make a crypto RNG, I would begin by toying with the idea of non-reversibility.

I wouldn't. I would toy with the idea of unpredictability. An unpredictable sequence would be non-reversible. <smile>

nothing is unpredictable. :P

Return to “General”

Who is online

Users browsing this forum: Baidu [Spider], fxm and 4 guests