import binascii import simplesha3 hash = simplesha3.keccakc512 # SHA-3 winner with 256-bit output p = 2^224 - 2^96 + 1 # standard NIST P-224 prime k = GF(p) def secure(A,B): n = EllipticCurve([k(A),k(B)]).cardinality() return (n.is_prime() and (2*p+2-n).is_prime() and Integers(n)(p).multiplicative_order() * 100 >= n-1 and Integers(2*p+2-n)(p).multiplicative_order() * 100 >= 2*p+2-n-1) def str2int(seed): return Integer(seed.encode('hex'),16) A = p-3 S = '3CC520E9434349DF680A8F4BCADDA648D693B2907B216EE55CB4853DB68F9165' B = str2int(hash(binascii.unhexlify(S))) # verifiably random if secure(A,B): print 'p',hex(p).upper() print 'A',hex(A).upper() print 'B',hex(B).upper() # output: # p FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001 # A FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE # B BADA55ECFD9CA54C0738B8A6FB8CF4CCF84E916D83D6DA1B78B622351E11AB4E