Ejemplo n.º 1
0
    def test_point_vector_hadamard(self):
        l = 3
        V = PointVector([random_point() for i in range(l)])
        W = PointVector([random_point() for i in range(l)])
        X = V*W

        self.assertEqual(len(X),l)
        for i in range(l):
            self.assertEqual(X[i],V[i]+W[i])
Ejemplo n.º 2
0
    def test_point_vector_sub(self):
        l = 3
        V = PointVector([random_point() for i in range(l)])
        W = PointVector([random_point() for i in range(l)])
        X = V-W

        self.assertEqual(len(X),l)
        for i in range(l):
            self.assertEqual(X[i],V[i]-W[i])
Ejemplo n.º 3
0
    def test_point_vector_slice(self):
        l = 3
        points = [random_point() for i in range(2*l)]
        V = PointVector(points)
        W = V[:l]

        self.assertEqual(len(W),l)
        self.assertEqual(W.points,points[:l])
Ejemplo n.º 4
0
    def test_point_vector_mul_scalar(self):
        l = 3
        V = PointVector([random_point() for i in range(l)])
        s = random_scalar()
        W = V*s

        self.assertEqual(len(W),l)
        for i in range(l):
            self.assertEqual(W[i],V[i]*s)
Ejemplo n.º 5
0
    def test_point_vector_extend(self):
        l = 3
        points = [random_point() for i in range(2*l)]
        V = PointVector(points[:l])
        W = PointVector(points[l:])
        V.extend(W)

        T = PointVector(points)
        self.assertEqual(len(V),len(T))
        self.assertEqual(V.points,T.points)
Ejemplo n.º 6
0
    def test_point_vector_mul_scalar_vector(self):
        l = 3
        V = PointVector([random_point() for i in range(l)])
        v = ScalarVector([random_scalar() for i in range(l)])
        W = V*v

        R = dumb25519.Z
        for i in range(l):
            R += V[i]*v[i]
        self.assertEqual(W,R)
Ejemplo n.º 7
0
    def test_bad_hash(self):
        # xG is replaced with a random point
        proof = prove(2)
        proof.xG = dumb25519.random_point()
        with self.assertRaises(ArithmeticError):
            verify(proof)

        # xH is replaced with a random point
        proof = prove(2)
        proof.xH = dumb448.random_point()
        with self.assertRaises(ArithmeticError):
            verify(proof)
Ejemplo n.º 8
0
 def test_random(self):
     random_scalar()
     random_point()
Ejemplo n.º 9
0
 def test_8_random(self):
     data = [[random_point(),random_scalar()] for i in range(8)]
     result = Z
     for datum in data:
         result += datum[0]*datum[1]
     self.assertEqual(dumb25519.multiexp(data),result)