def format_random_value(name: str, value: str) -> str: """ Take a string of random data and a name/explanation for it and format them together. For instance: 'Faber College verkey (FuN98eH2eZybECWkofW6A9BKJxxnTatBCopfUiNxo6ZB)' :param name: Name of explanation related to the random string. :param value: String representation of some random-looking value. :return: A formatted string. """ formatted_string = apply_colour(name, Colours.BOLD) if SHOW_RANDOM: formatted_string += " ({})".format( apply_colour(shorten(serializeToStr(value), 80), Colours.GREY)) return formatted_string
def testGroupElementG1IdentitySerializeToFromStr(): elem = cmod.PairingGroup(PAIRING_GROUP).random(cmod.G1) identity = cmod.PairingGroup(PAIRING_GROUP).init(cmod.G1, elem / elem) assert identity == deserializeFromStr(serializeToStr(identity))
def testGroupElementZRIdentitySerializeToFromStr(): elem = cmod.PairingGroup(PAIRING_GROUP).init(cmod.ZR, 555) identity = elem / elem assert identity == deserializeFromStr(serializeToStr(identity))
def testGroupElementSerializeToFromStr(): value = cmod.PairingGroup(PAIRING_GROUP).random(cmod.G1) assert value == deserializeFromStr(serializeToStr(value))
def testCryptoIntModSerializeToFromStr(): value = cmod.integer(44444444444444444) % 33 assert value == deserializeFromStr(serializeToStr(value))
def testIntSerializeToFromStr(): value = 111 assert value == deserializeFromStr(serializeToStr(value))
def testStrSerializeToFromStr(): value = 'aaa' assert value == deserializeFromStr(serializeToStr(value))