def randomQR(n): return cmod.random(n)**2
def _genX(cls, p_prime, q_prime): maxValue = p_prime * q_prime - 1 minValue = 2 return cmod.integer(cmod.random(maxValue - minValue)) + minValue
def generateParams(cls) -> PublicParams: rho, b, Gamma = PublicParamsBuilder._genRhoBGamma() g = PublicParamsBuilder._genG(Gamma, b) r = cmod.random(rho) h = g**r return PublicParams(Gamma, rho, g, h)
def genX(self): maxValue = self.p_prime * self.q_prime - 1 minValue = 2 return cmod.integer(cmod.random(maxValue - minValue)) + minValue
def _genG(cls, Gamma, b): while True: gprime = cmod.random(Gamma) g = (gprime**b) % Gamma if g != 1: return g