[PATCH] Custom random number generation function.

Laurent Fousse laurent at komite.net
Sun Aug 29 13:57:05 CEST 2010


* Pedro Gimeno [Sat, Aug 28, 2010 at 04:14:24PM +0200]:
> Your proposed interface looks unacceptable to me. It serves only the
> purpose of stateless generators like the use case you mention, but fails
> to provide a general purpose interface that allows seedable generators.
> Ideally, a custom RNG function should serve to expose the internal
> random number generation infrastructure to the user, so that the user
> can provide custom seeding, generation, clearing and state copying
> functions.
> Since those functions will be exposed to the user, they should also be
> properly documented in this respect. Your proposed single
> byte-buffer-filling function is too specific and does not provide a true
> general custom random number generation interface.

You are correct. Since I developed this extension exactly for the
outlined use-case, seedable generators were not a concern for me. If
you want to allow such generators, you would need to let the user
define completely the content of the gmp_randfnptr_t variable, and
replace the byte buffer in the gmp_rand_custom_struct by some opaque
void* member to be dealt with by the user's functions.

I can change my patch to name the proposed generator "stateless"
instead of custom. Would it be accepted in GMP, if it is properly
documented to be stateless? Or would you rather expose the full struct
to the user?


More information about the gmp-devel mailing list