codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rng] Uniform big integers


Hi.

On Thu, 20 Dec 2018 15:15:55 +0000, Bernd Eckenfels wrote:
Hello,

I don’t know what the usecase is, it is motivated by a Bug about
BigInteger(num, Random). I guess one of the users is actually the
crypto usecase (starting with random numbers to find primes).

I wanted to check how RNG deals with this

You can do it by defining a bridge from [RNG] "UniformRandomProvider"
to "java.util.Random":
--- CUT (untested) ---
public class BridgeToRandom extends Random {
   private final UniformRandomProvider delegate;

   public BridgeToRandom(UniformRandomProvider rng) {
       delegate = rng;
   }

   @Override
   protected int next(int unused) {
       return rng.nextInt();
   }
}
---CUT---

Then, you can test all the generators implemented in [RNG].

Regards,
Gilles

(since the additional need
for generating a random bitlength looks unfamiliar but logical to me).
Is it really not enough to fill all bits randomly (especially for the
case where it is a 0 .. 2^n range only)?

Discussion is here:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057594.html

Gruss
Bernd
--
http://bernd.eckenfels.net

________________________________
Von: Gilles <gilles@xxxxxxxxxxxxxxxxxxxxx>
Gesendet: Donnerstag, Dezember 20, 2018 2:16 PM
An: dev@xxxxxxxxxxxxxxxxxx
Betreff: Re: [rng](site) broken source(current) link

Hi.

On Thu, 20 Dec 2018 12:43:51 +0000, Bernd Eckenfels wrote:
I wanted to check if RNG can construct uniformly distributed
BigIntegers and how it is doing it (answer: it doesn’t)

It could be a feature request.
[I guess that you mean "within a given range".]

Being curious: What's the use-case for random "BigInteger"s?

while doing so
I noticed that the site link to the source is broken, maybe this is
due to git-wip migration?

Yes.
Thanks; fixed now.


BTW: http://cr.openjdk.java.net/~bpb/8146153/webrev.01/index.html


Regards,
Gilles


Gruss
Bernd
--
http://bernd.eckenfels.net


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxx