示例#1
0
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
示例#2
0
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))
示例#3
0
def testGroupElementZRIdentitySerializeToFromStr():
    elem = cmod.PairingGroup(PAIRING_GROUP).init(cmod.ZR, 555)
    identity = elem / elem
    assert identity == deserializeFromStr(serializeToStr(identity))
示例#4
0
def testGroupElementSerializeToFromStr():
    value = cmod.PairingGroup(PAIRING_GROUP).random(cmod.G1)
    assert value == deserializeFromStr(serializeToStr(value))
示例#5
0
def testCryptoIntModSerializeToFromStr():
    value = cmod.integer(44444444444444444) % 33
    assert value == deserializeFromStr(serializeToStr(value))
示例#6
0
def testIntSerializeToFromStr():
    value = 111
    assert value == deserializeFromStr(serializeToStr(value))
示例#7
0
def testStrSerializeToFromStr():
    value = 'aaa'
    assert value == deserializeFromStr(serializeToStr(value))