# How do I generate a number from a Z* order q set

I would like to generate a random number based on this set, firstly how do I generate the numbers that belong to the Z* order q set. I have the q value and the prime p value.

Also if there's a library in python that does that already that'd be nice

• docs.python.org/3/library/os.html , also don't forget to discard if the number is greater than $q$ otherwise there will be a bias. – kelalaka Jun 14 at 12:19
• @kelalaka Are you sure you linked the correct page? os isn't a package for generating random numbers having the OP's requirements. – kiamlaluno Jun 15 at 13:34