Esempio n. 1
0
def proof_export(proof):

    bproof = ffi.new("byte_t **")
    bproof[0] = ffi.NULL
    size = ffi.new("uint32_t *")  
    if lib.groupsig_proof_export(bproof, size, proof) == constants.IERROR:
        raise Exception('Error exporting proof.')
    b64proof = base64.b64encode(ffi.buffer(bproof[0], size[0]))
#    lib.free(bproof[0])
    return b64proof    
Esempio n. 2
0
def gml_export(gml):
    """
    Exports a GML to a Base64 string.
    
    Parameters:
        gml: The GML to export.
    Returns:
        A Base64 string. On error, an Exception is thrown.
    """

    bgml = ffi.new("byte_t **")
    bgml[0] = ffi.NULL
    size = ffi.new("uint32_t *")
    if lib.gml_export(bgml, size, gml) == constants.IERROR:
        raise Exception('Error exporting GML.')
    b64gml = base64.b64encode(ffi.buffer(bgml[0], size[0]))
    #    lib.free(bgml[0])
    return b64gml
Esempio n. 3
0
def grpkey_export(grpkey):
    """
    Exports the given group key to a Base64 string.

    Parameters:
        grpkey: The native group key data structure.
    Returns:
        A Base64 string. On error, an Exception is thrown.
    """
    
    bkey = ffi.new("byte_t **")
    bkey[0] = ffi.NULL
    size = ffi.new("uint32_t *")
    if lib.groupsig_grp_key_export(bkey, size, grpkey) == constants.IERROR:
        raise Exception('Error exporting group key.')
    b64 = base64.b64encode(ffi.buffer(bkey[0],size[0]))
    b64 = b64.decode('utf-8').replace('\n', '')
    #    lib.free(bkey[0])
    return b64
Esempio n. 4
0
def blindsig_export(sig):
    """
    Exports the given blinded signature to a Base64 string.
    
    Parameters:
        sig: The blinded signature to export.
    Returns:
        The produced Base64 string. On error, an Exception is thrown.
    """

    bsig = ffi.new("byte_t **")
    bsig[0] = ffi.NULL
    size = ffi.new("uint32_t *")
    if lib.groupsig_blindsig_export(bsig, size, sig) == constants.IERROR:
        raise Exception('Error exporting blindsig.')
    b64sig = base64.b64encode(ffi.buffer(bsig[0], size[0]))
    b64sig = b64sig.decode('utf-8').replace('\n', '')
    #    lib.free(bsig[0])
    return b64sig
Esempio n. 5
0
def signature_export(sig):
    """
    Exports the given group signature a Base64 string.

    Parameters:
        sig: The native group signature data structure.
    Returns:
        A Base64 string. On error, an Exception is thrown.
    """

    bsig = ffi.new("byte_t **")
    bsig[0] = ffi.NULL
    size = ffi.new("uint32_t *")
    if lib.groupsig_signature_export(bsig, size, sig) == constants.IERROR:
        raise Exception('Error exporting signature.')
    b64sig = base64.b64encode(ffi.buffer(bsig[0], size[0]))
    b64sig = b64sig.decode('utf-8').replace('\n', '')
    #    lib.free(bsig[0])
    return b64sig
Esempio n. 6
0
def bldkey_export_pub(bldkey):
    """
    Exports the public part of given blinding keypair to a Base64 string.
    
    Parameters:
        bldkey: The blinding key to export.
    Returns:
        The produced Base64 string. On error, an Exception is thrown.
    """    

    bkey = ffi.new("byte_t **")
    bkey[0] = ffi.NULL
    size = ffi.new("uint32_t *")  
    if lib.groupsig_bld_key_export_pub(bkey, size, bldkey) == constants.IERROR:
        raise Exception('Error exporting blinding public key.')
    b64key = base64.b64encode(ffi.buffer(bkey[0],size[0]))
    b64key = b64key.decode('utf-8').replace('\n', '')    
#    lib.free(bkey[0])
    return b64key