Pseudo Random Function vs Pseudo Random Generator - random

Hi all I am referring PBKDF2, I could not understand what exactly this Pseudo-Random Dunction.
What is the difference between the Pseudo-Random Function and Pseudo-Random Generator?

1)in personal opinion ,Pseudo-Random Function is a likewise true function that can replace random function to simulate the exponential numbers from true random functions set ,for example 2^2n.In Pseudo-Random Function user just uses a seed (k) as key which will be calculated with input x to have a random result. The method is likewise to choose a function randomly from one function set.
2)Normally speaking to Pseudo-Random Function, one property is the advantage between probability of choosing pseudorandom function and probability of true random function is negligible. Then people can think they can choose the pseudorandom function to replace random function.
3)In true random function people must choose some function as random function but the territory or the amount of the whole functions set is too large which can not be stored in computer or written by human. So we choose pseudorandom function as a smart way.

Related

Which type of function is ReL?

I was wondering if the ReL function is a linear or an identity function.
If the function was linear (meaning y=kx+d) the function could be "changed" a lot more.
If the function on the other hand was an identity function (meaning y=x), then output wouldn't be changed - at least for positive inputs.
As far as I've read, positive values that are ran through a ReLU are not changed. Meaning, that the function (from 0 onwards) is an identity function. Is my understanding correct?
When it's applied on a set of input values evenly distributed around zero, the ReL function is linear for half of the input domain (on the positive input values) and nonlinear for the other half. Thus, it is referred to as a piecewise linear function or a hinge function.

Pseudo random number

I need to find a function f(t) which generates pseudo random numbers in range [0;1) with uniform distribution. Results for same t must be equals.
It seems that a linear congruential generator might be the way to go.
https://rosettacode.org/wiki/Linear_congruential_generator

How can I call the same pseudorandom number for a given i and j?

I'm working on a project with multiple functions. I call a pseudorandom number several times, each in different functions, and then do some math on it. For example:
f(i,j)*random(i,j)
I assume that in the different functions the pseudorandom number isn't equal to the pseudorandom number in another function at a given i and j. Is that a correct assumption? If so, how is it possible to change that?
If it matters, the language I'm using is Xojo, which is similar to VB6.
I'm not really sure what the question is, but hopefully giving some basics of pseudo-random number generators (PRNG) will answer it:
This is more of a language feature, but usually calling the same function (i.e. random) is independent of where you call it from (there may be other determining factors).
random(i,j) may or may not return the same number twice in a row or after some time. It's (pseudo-)random, we just don't know whether it will.
If you want random(i,j) to always return the same value, you can consider writing your own function that maps some value of i and j to another value using some formula, or you can store all previous generated numbers in a map, and simply return this value if it exists.
If you want random(i,j) to never return the same value, consider generating numbers from i to j and shuffling them and simply returning the next value in the list repeatedly.
You can usually set the seed of a PRNG. This will cause that, if you get some sequence after setting the seed to some value, you will get the same sequence if you set the seed to the same value at some other time. This doesn't really serve much of a practical purpose (that I can think of) beyond giving you the capability to reproducible previous results exactly.
If you want random(i,j) to return the same random number each time it's called with the same i,j you could simply save the state.
One approach would be to store the state in an n x n matrix R (where n is the range of i,j). On the first call to random(i,j) set R(i,j) = rand(). On subsequent calls retrieve the existing value.
If the range of i,j is very large and the values sparse use a hash table for R instead of a matrix.

Random number starting points

The awk manual says srand "sets the seed (starting point) for rand()". I used srand(5) with the following code:
awk 'BEGIN {srand(5);while(1)print rand()}'> /var/tmp/rnd
It generates numbers like:
0.177399
0.340855
0.0256178
0.838417
0.0195347
0.29598
Can you explain how srand(5) generates the "starting point" with the above output?
The starting point is called the seed. It is given to the first iteration of the rand function. After that rand uses the previous value it got when calculating the old number -- to generate the next number. Using a prime number for the seed is a good idea.
PRNGs (pseudo-random number generators) produce random values by keeping some kind of internal state which can be advanced through a series of values whose repeating period is very large, and whose successive values have very few apparent statistical correlations as long as we use far fewer of them. But nonetheless, its values are a deterministic sequence.
"Seeding" a PRNG is basically selecting what point in the deterministic sequence to start at. The algorithm will take the number passed as the seed and compute (in some algorithm-specific way) where to start in the sequence. The actual value of the seed is irrelevant--the algorithm should not depend on it in any way.
But, although the seed value itself does not directly participate in the PRNG algorithm, it does uniquely identify the starting point in the sequence, so if you give a particular seed and then generate a sequence of values, seeding again with the same value should cause the PRNG to generate the same sequence of values.

Is this function preimage resistant?

One of the ways of testing strength of PRNG functions is to design tests that distinguish PRNG
outputs from random strings: we are given a box which outputs PRNG(u) for some u or a random string.
We have to determine if the output comes from PRNG.
Assume that a hash function H fails this test.
Does it mean that it is not second preimage resistant?
Assume a 256-bit cryptographic hash function h with all the properties that are expected from such.
Construct the function which, for any input string s, returns the first 255 bits of h(s) followed by the bit 0.
This function is easy to distinguish from random with good probability given enough inputs: it returns only even numbers. But it is still tricky to compute any sort of collision or preimage for it: it is 255-bit strong.
Resistance to collision or preimage is not an all-or-nothing question. There are gradations.

Resources