コード例 #1
0
ファイル: batchverify.py プロジェクト: vusirikala/auto-tools
def benchBatchVerification(N, equation, sdl_dict, vars, precompute, _verbose):
    rop_batch = RecordOperations(vars)
    rop_batch.visit(equation, {})
    if _verbose:
        print("<====\tBATCH\t====>")
        print("Equation =>", equation)
        print("<===\tOperations count\t===>")
    for i in precompute.keys():
        if type(i) != str:
            if checkForSigs(precompute[i]): data = {'key': ['N'], 'N': N}
            else: data = {}
            rop_batch.visit(precompute[i], data)
            if _verbose: print("Precompute:", i, ":=", precompute[i])
        else:
            if i == 'delta':  # estimate cost of random small exponents
                rop_batch.ops['prng'] += N
                if _verbose: print("Precompute:", i, ":=", precompute[i])
            else:  # estimate cost of some precomputations
                bp = BatchParser()
                index = BinaryNode(i)
                if 'j' in index.attr_index:
                    compute = bp.parse("for{z:=1, N} do " + precompute[i])
                    rop_batch.visit(compute, {})
                    if _verbose: print("Precompute:", i, ":=", compute)
                else:
                    if _verbose:
                        print("TODO: need to account for this: ", i, ":=",
                              precompute[i])
    if _verbose:
        print_results(rop_batch.ops)
    return calculate_times(rop_batch.ops, curve[param_id], N)
コード例 #2
0
ファイル: batchverify.py プロジェクト: JHUISI/auto-tools
def benchBatchVerification(N, equation, sdl_dict, vars, precompute, _verbose):
    rop_batch = RecordOperations(vars)
    rop_batch.visit(equation, {})
    if _verbose:
        print("<====\tBATCH\t====>")
        print("Equation =>", equation)
        print("<===\tOperations count\t===>")
    for i in precompute.keys():
        if type(i) != str:
            if checkForSigs(precompute[i]): data = {'key':['N'], 'N': N }
            else: data = {}
            rop_batch.visit(precompute[i], data)
            if _verbose: print("Precompute:", i, ":=", precompute[i])
        else:
            if i == 'delta': # estimate cost of random small exponents
                rop_batch.ops['prng'] += N
                if _verbose: print("Precompute:", i, ":=", precompute[i])
            else:  # estimate cost of some precomputations
                bp = BatchParser()
                index = BinaryNode( i )
                if 'j' in index.attr_index:
                    compute = bp.parse( "for{z:=1, N} do " + precompute[i] )
                    rop_batch.visit(compute, {})
                    if _verbose: print("Precompute:", i, ":=", compute)
                else:
                    if _verbose: print("TODO: need to account for this: ", i, ":=", precompute[i])
    if _verbose:
        print_results(rop_batch.ops)
    return calculate_times(rop_batch.ops, curve['mnt160'], N)
コード例 #3
0
ファイル: batchverify2.py プロジェクト: JHUISI/auto-tools
def batcher_main(argv, prefix=None):
    global TEST_STATEMENT, THRESHOLD_FLAG, CODEGEN_FLAG, PROOFGEN_FLAG, PRECOMP_CHECK, VERBOSE, CHOOSE_STRATEGY
    global filePrefix
    if len(argv) == 1:
        print("%s [ file.bv ] -b -c -p" % argv[0])
        print("-b : estimate threshold for a given signature scheme with 1 to N signatures.")
        print("-c : generate the output for the code generator (temporary).")
        print("-d : check for further precomputations in final batch equation.")
        print("-p : generate the proof for the signature scheme.")
        print("-s : select strategy for the ordering of techniques. Options: basic, score, what else?")
        exit(-1)

    # main for batch input parser    
    try:
        print(argv)
        file = str(argv[1])
        if prefix: filePrefix = prefix
        for i in argv:
            if i == "-b": THRESHOLD_FLAG = True
            elif i == "-c": CODEGEN_FLAG = True
            elif i == "-v": VERBOSE = True
            elif i == "-p": PROOFGEN_FLAG = True
            elif i == "-d": PRECOMP_CHECK = True
            elif i == "-s": CHOOSE_STRATEGY = True
            elif i == "-t": TEST_STATEMENT = True
        if not TEST_STATEMENT: ast_struct = parseFile(file)
    except Exception as exc:
        print("An error occured while processing batch inputs: ", exc)
        exit(-1)

    if TEST_STATEMENT:
        debug = levels.all
        statement = argv[2]
        parser = BatchParser()
        final = parser.parse(statement)
        print("Final statement(%s): '%s'" % (type(final), final))
        exit(0)

    verify_eq, N = [], None; cnt = 0
    for n in ast_struct[ OTHER ]:
        if 'verify' in str(n.left):
            result = handleVerifyEq(n, cnt); cnt += 1
            if type(result) != list: verify_eq.append(result)
            else: verify_eq.extend(result)

    # verify 
    variables = ast_struct[ TYPE ]
    for eq in verify_eq:
        bte = BasicTypeExist( variables )
        ASTVisitor( bte ).preorder( eq )
        bte.report( eq )
        
        cte = PairingTypeCheck( variables )
        ASTVisitor( cte ).preorder( eq )
        cte.report( eq )

    # process settings
    for i in range(len(verify_eq)):    
        if VERBOSE: print("\nRunning batcher....\n")
        runBatcher(file + str(i), verify_eq[i], ast_struct, i)
コード例 #4
0
ファイル: batchverify.py プロジェクト: vusirikala/auto-tools
def batcher_main(argv, prefix=None):
    global TEST_STATEMENT, THRESHOLD_FLAG, CODEGEN_FLAG, PROOFGEN_FLAG, PRECOMP_CHECK, VERBOSE, CHOOSE_STRATEGY
    global filePrefix
    if len(argv) == 1:
        print("%s [ file.bv ] -b -c -p" % argv[0])
        print(
            "-b : estimate threshold for a given signature scheme with 1 to N signatures."
        )
        print("-c : generate the output for the code generator (temporary).")
        print(
            "-d : check for further precomputations in final batch equation.")
        print("-p : generate the proof for the signature scheme.")
        print(
            "-s : select strategy for the ordering of techniques. Options: basic, score, what else?"
        )
        exit(-1)

    # main for batch input parser
    try:
        print(argv)
        file = str(argv[1])
        if prefix: filePrefix = prefix
        for i in argv:
            if i == "-b": THRESHOLD_FLAG = True
            elif i == "-c": CODEGEN_FLAG = True
            elif i == "-v": VERBOSE = True
            elif i == "-p": PROOFGEN_FLAG = True
            elif i == "-d": PRECOMP_CHECK = True
            elif i == "-s": CHOOSE_STRATEGY = True
            elif i == "-t": TEST_STATEMENT = True
        if not TEST_STATEMENT: ast_struct = parseFile(file)
    except Exception as exc:
        print("An error occured while processing batch inputs: ", exc)
        exit(-1)

    if TEST_STATEMENT:
        debug = levels.all
        statement = argv[2]
        parser = BatchParser()
        final = parser.parse(statement)
        print("Final statement(%s): '%s'" % (type(final), final))
        exit(0)

    verify_eq, N = [], None
    cnt = 0
    for n in ast_struct[OTHER]:
        if 'verify' in str(n.left):
            result = handleVerifyEq(n, cnt)
            cnt += 1
            if type(result) != list: verify_eq.append(result)
            else: verify_eq.extend(result)

    # verify
    variables = ast_struct[TYPE]
    for eq in verify_eq:
        bte = BasicTypeExist(variables)
        ASTVisitor(bte).preorder(eq)
        bte.report(eq)

        cte = PairingTypeCheck(variables)
        ASTVisitor(cte).preorder(eq)
        cte.report(eq)

    # process settings
    for i in range(len(verify_eq)):
        if VERBOSE: print("\nRunning batcher....\n")
        runBatcher(file + str(i), verify_eq[i], ast_struct, i)
コード例 #5
0
        for i in sys.argv:
            if i == "-b": THRESHOLD_FLAG = True
            elif i == "-c": CODEGEN_FLAG = True
            elif i == "-v": VERBOSE = True
            elif i == "-p": PROOFGEN_FLAG = True
            elif i == "-d": PRECOMP_CHECK = True
            elif i == "-s": CHOOSE_STRATEGY = True
            elif i == "-t": TEST_STATEMENT = True
        if not TEST_STATEMENT: ast_struct = parseFile(file)
    except:
        print("An error occured while processing batch inputs.")
        exit(-1)
    if TEST_STATEMENT:
        debug = levels.all
        statement = sys.argv[2]
        parser = BatchParser()
        final = parser.parse(statement)
        print("Final statement(%s): '%s'" % (type(final), final))
        exit(0)

    verify_eq, N = [], None
    cnt = 0
    for n in ast_struct[OTHER]:
        if 'verify' in str(n.left):
            result = handleVerifyEq(n, cnt)
            cnt += 1
            if type(result) != list: verify_eq.append(result)
            else: verify_eq.extend(result)

    # process settings
    for i in range(len(verify_eq)):
コード例 #6
0
ファイル: batchverify.py プロジェクト: JHUISI/auto-tools
        for i in sys.argv:
            if i == "-b": THRESHOLD_FLAG = True
            elif i == "-c": CODEGEN_FLAG = True
            elif i == "-v": VERBOSE = True
            elif i == "-p": PROOFGEN_FLAG = True
            elif i == "-d": PRECOMP_CHECK = True
            elif i == "-s": CHOOSE_STRATEGY = True
            elif i == "-t": TEST_STATEMENT = True
        if not TEST_STATEMENT: ast_struct = parseFile(file)
    except:
        print("An error occured while processing batch inputs.")
        exit(-1)
    if TEST_STATEMENT:
        debug = levels.all
        statement = sys.argv[2]
        parser = BatchParser()
        final = parser.parse(statement)
        print("Final statement(%s): '%s'" % (type(final), final))
        exit(0)

    verify_eq, N = [], None; cnt = 0
    for n in ast_struct[ OTHER ]:
        if 'verify' in str(n.left):
            result = handleVerifyEq(n, cnt); cnt += 1
            if type(result) != list: verify_eq.append(result)
            else: verify_eq.extend(result)

    # process settings
    for i in range(len(verify_eq)):    
        print("\nRunning batcher....\n")
        runBatcher(file + str(i), verify_eq[i], ast_struct, i)