コード例 #1
0
ファイル: testMySecondMul.py プロジェクト: dom8509/libcumffa
    def testMySecondMul(self, bits, func):

        # do cuda arithmetic
        f_gpu = GF2nStub.GF2nStub("Cuda", bits)

        a_gpu = f_gpu()
        b_gpu = f_gpu()

        res_gpu = GF2nStub.run(func, a_gpu, b_gpu)

        rand_a = GF2nStub.getRandomNumber(bits, 42)
        rand_b = GF2nStub.getRandomNumber(bits, 84)

        print "a = ", rand_a
        print "b = ", rand_b

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)
        b_ref = f_ref(rand_b)

        res_ref = a_ref * b_ref

        print "res_ref = ", res_ref

        # compare results
        self.assertEqual(res_gpu, res_ref)
コード例 #2
0
ファイル: testOpenSSL.py プロジェクト: dom8509/libcumffa
    def testOpenSSLMultiplication(self, bits):

        # do OpenSSL arithmetic
        f_cpu = GF2nStub.GF2nStub("OpenSSL", bits)

        a_cpu = f_cpu()
        b_cpu = f_cpu()

        res_cpu = a_cpu * b_cpu

        # calcualte reference
        rand_a = GF2nStub.getRandomNumber(bits, 42)
        rand_b = GF2nStub.getRandomNumber(bits, 84)

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)
        b_ref = f_ref(rand_b)

        res_ref = a_ref * b_ref

        # compare results
        self.assertEqual(res_cpu, res_ref)
コード例 #3
0
ファイル: testCuda.py プロジェクト: dom8509/libcumffa
    def testCudaMultiplication(self, bits, func):

        # do cuda arithmetic
        f_gpu = GF2nStub.GF2nStub("Cuda", bits)

        a_gpu = f_gpu()
        b_gpu = f_gpu()

        res_gpu = GF2nStub.run(func, a_gpu, b_gpu)

        # calcualte reference
        rand_a = GF2nStub.getRandomNumber(bits, 42)
        rand_b = GF2nStub.getRandomNumber(bits, 84)

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)
        b_ref = f_ref(rand_b)

        res_ref = a_ref * b_ref

        # compare results
        self.assertEqual(res_gpu, res_ref)
コード例 #4
0
ファイル: testOpenSSL.py プロジェクト: dom8509/libcumffa
    def testOpenSSLAddition(self, bits):

        # do OpenSSL arithmetic
        f_cpu = GF2nStub.GF2nStub("OpenSSL", bits, -1)

        a_cpu = f_cpu()
        b_cpu = f_cpu()

        res_cpu = a_cpu + b_cpu

        # calcualte reference
        rand_irred_poly = GF2nStub.getRandomNumber(bits + 1, 23)
        rand_a = GF2nStub.getRandomNumber(bits, 42)
        rand_b = GF2nStub.getRandomNumber(bits, 84)

        f_ref = GF2n.GF2n(bits, rand_irred_poly)

        a_ref = f_ref(rand_a)
        b_ref = f_ref(rand_b)

        res_ref = a_ref + b_ref

        # compare results
        self.assertEqual(res_cpu, res_ref)
コード例 #5
0
    def testExpPerformance(self, bits, k, function, framework):

        runs = 10

        rand_irred_poly = GF2nStub.getRandomNumber(bits + 1, 23)
        f = GF2nStub.GF2nStub(framework, bits, rand_irred_poly | 1)

        a = f()

        if framework == "OpenSSL":
            res = GF2nStub.run("exp", a, k, 0, runs)
        else:
            res = GF2nStub.run(function, a, k, 0, runs)

        times = GF2nStub.getEllapsedTime_ms()
        for time in times:
            PerformanceDataLogger().addPerfResult(function + ", k=" + str(k),
                                                  bits, framework, time)
コード例 #6
0
ファイル: testOpenSSL.py プロジェクト: dom8509/libcumffa
    def testOpenSSLExponentiation(self, bits, exp):

        # do cuda arithmetic
        f_gpu = GF2nStub.GF2nStub("OpenSSL", bits)

        a_gpu = f_gpu()

        res_gpu = GF2nStub.run("exp", a_gpu, exp)

        # calcualte reference
        rand_a = GF2nStub.getRandomNumber(bits, 42)

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)

        res_ref = a_ref**exp

        # compare results
        self.assertEqual(res_gpu, res_ref)
コード例 #7
0
ファイル: testOpenSSL.py プロジェクト: dom8509/libcumffa
    def testOpenSSLInverseElement(self, bits):

        # do cuda arithmetic
        f_gpu = GF2nStub.GF2nStub("OpenSSL", bits)

        a_gpu = f_gpu()

        res_gpu = GF2nStub.run("inverse", a_gpu, 0)

        # calcualte reference
        rand_a = GF2nStub.getRandomNumber(bits, 42)

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)

        res_ref = a_ref.inverse()

        # compare results
        self.assertEqual(res_gpu, res_ref)
コード例 #8
0
ファイル: testCuda.py プロジェクト: dom8509/libcumffa
    def testCudaExponentiation(self, bits, k, func):

        # do cuda arithmetic
        f_gpu = GF2nStub.GF2nStub("Cuda", bits)

        a_gpu = f_gpu()

        res_gpu = GF2nStub.run(func, a_gpu, k)

        # calcualte reference
        rand_a = GF2nStub.getRandomNumber(bits, 42)

        f_ref = GF2n.GF2n(bits)

        a_ref = f_ref(rand_a)

        res_ref = a_ref**k

        # compare results
        self.assertEqual(res_gpu, res_ref)