def _serialize(element, compress, relicSizeBinFunc, relicWriteBinFunc):
    """
    Serializes an @element using the proper function @relicWriteBinFunc into
    a bytearray. @compress specifies whether the element should be compressed.
    @relicSizeBinFunc is used to determine the size of the serialized output.
    This is underlying implementation for serialize G1, G2, and Gt.
    """
    cFlag = c_int(compress)
    size = relicSizeBinFunc(byref(element), cFlag)

    # Make an array of the correct size. 
    binArray = (c_ubyte*size)()

    # Serialize
    relicWriteBinFunc(byref(binArray), size, byref(element), cFlag)
    return bytearray(binArray)
def _serialize ( element , compress , relicSizeBinFunc , relicWriteBinFunc ) : cFlag = c_int ( compress ) size = relicSizeBinFunc ( byref ( element ) , cFlag ) binArray = ( c_ubyte * size ) ( ) relicWriteBinFunc ( byref ( binArray ) , size , byref ( element ) , cFlag ) return bytearray ( binArray )
Serializes an @element using the proper function @relicWriteBinFunc into
    a bytearray. @compress specifies whether the element should be compressed.
    @relicSizeBinFunc is used to determine the size of the serialized output.
    This is underlying implementation for serialize G1, G2, and Gt.